ocmath_lu

 

Description

Uses partial pivoting, with row interchanges.

Syntax

int ocmath_lu( double * pMatIO, long * pIpiv, int m, int n )

Parameters

pMatIO
[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.
pIpiv
[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).
m
[input] row number of matrix
n
[input] column number of matrix

Return

= 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.

Examples

EX1

void ocmath_lu_ex1()
{
    //assume Matrix1(datatype: double) contains data
    Matrix    matIO("MBook1");
    matrix<long> matIPIV;
    int m = matIO.GetNumRows();
    int n = matIO.GetNumCols();
    matIPIV.SetSize(min(m,n), 1);
    ocmath_lu(matIO, matIPIV, m, n);
}

Remark

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.

See Also

header to Include

origin.h

Reference

nag_dgetrf(f07adc)nag_dgetrf(f07adc), Nag Manual