Uses partial pivoting, with row interchanges.
int ocmath_lu( double * pMatIO, long * pIpiv, int m, int n )
- [modify] input:pointer to original matrix, of size m by n
- output: overwritten by the factors L and U; the unit diagonal
- elements of L are not stored.
- [output] pointer to the pivot indices of size min(m, n) by 1.
- Row i of the original matrix is interchanged
- with row pIpiv[i - 1] for i = 1,2, ..., min(m, n).
- [input] row number of matrix
- [input] column number of matrix
- = OE_NOERROR(0): successful exit
- = -1: m or n is less than 1
- = NE_SINGULAR: u(<value>, <value>) is exactly zero. The factorization has been completed but the factor U is exactly singular, and division by zero will occur if it is subsequently used to solve a system of linear equations or to invert A.
- = NE_ALLOC_FAIL: Memory allocation failed.
- = NE_BAD_PARAM: On entry, parameter had an illegal value.
- = NE_INTERNAL_ERROR: An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please consult NAG for assistance.
//assume Matrix1(datatype: double) contains data
int m = matIO.GetNumRows();
int n = matIO.GetNumCols();
ocmath_lu(matIO, matIPIV, m, n);
- Forms the LU factorization of a real m by n matrix A as A = PLU, where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n) and U is upper triangular (upper trapezoidal if m < n).
- Usually A is square(m = n), and both L and U are triangular.
- The function uses partial pivoting, with row interchanges.
Header to Include
nag_dgetrf(f07adc)nag_dgetrf(f07adc), Nag Manual