Solves a real system of linear equations with multiple right-hand sides.
int ocmath_lu_solve( double * pA, double * pB, long * pIpiv, int n, int nRhs = 1 )
- [modify](input)pointer to matrix A, of size n by n
- (output)overwritten by the factors L and U; the unit diagonal elements of
- L are not stored.
- [modify](input)pointer to right-hand side matrix B, of size n by r
- (output)pointer to n by r solution matrix
- [output]pointer to the pivot indices of size n by 1. Row i of the original
- matrix is interchanged with row mIpiv[i - 1] for i = 1,2, ..., n.
- [input] order the matrix A
- [input] The number of right hand sides, i.e., the number of columns of the matrix B
= OE_NOERROR: successful exit
= OE_INT_ARG_LT: n or nRhs 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 and Matrix2 contain data
int m = matB.GetNumRows();
int n = matB.GetNumCols();
ocmath_lu_solve(matA, matB, matIPIV, m , n);
Solves a real system of linear equations with multiple right-hand sides, Ax = B, using LU decomposition.
Then, the equation Ax = B can be transformed to two equations Ly = B and Ux = y. First, from solving the equation Ly = B, get y, and then from Ux = y, gain roots of the equation Ax = B.
Header to Include
nag_dgetrf(f07adc)nag_dgetrf(f07adc), nag_dgetrs(f07aec)nag_dgetrf(f07adc)nag_dgetrf(f07adc), nag_dgetrs(f07aec), Nag Manual