golib  0.5
goMath::LU< Real > Class Template Reference

LU Decomposition. More...

#include <golu.h>

Public Member Functions

 LU (const goMath::Matrix< Real > &A)
 
int isNonsingular ()
 
goMath::Matrix< Real > getL ()
 
goMath::Matrix< Real > getU ()
 
goMath::Vector< int > getPivot ()
 
Real det ()
 
bool solve (const goMath::Matrix< Real > &B, goMath::Matrix< Real > &retValue)
 
bool solve (const goMath::Vector< Real > &b, goMath::Vector< Real > &retValue)
 

Detailed Description

template<class Real>
class goMath::LU< Real >

LU Decomposition.

Taken in large parts from the JAMA library (free of copyright).

For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n unit lower triangular matrix L, an n-by-n upper triangular matrix U, and a permutation vector piv of length m so that A(piv,:) = L*U. If m < n, then L is m-by-m and U is m-by-n.

The LU decompostion with pivoting always exists, even if the matrix is singular, so the constructor will never fail. The primary use of the LU decomposition is in the solution of square systems of simultaneous linear equations. This will fail if isNonsingular() returns false.

Constructor & Destructor Documentation

◆ LU()

template<class Real >
goMath::LU< Real >::LU ( const goMath::Matrix< Real > &  A)
inline

LU Decomposition

Parameters
ARectangular matrix
Returns
LU Decomposition object to access L, U and piv.

Member Function Documentation

◆ det()

template<class Real >
Real goMath::LU< Real >::det ( )
inline

Compute determinant using LU factors.

Returns
determinant of A, or 0 if A is not square.

◆ getL()

template<class Real >
goMath::Matrix<Real> goMath::LU< Real >::getL ( )
inline

Return lower triangular factor

Returns
L

◆ getPivot()

template<class Real >
goMath::Vector<int> goMath::LU< Real >::getPivot ( )
inline

Return pivot permutation vector

Returns
piv

◆ getU()

template<class Real >
goMath::Matrix<Real> goMath::LU< Real >::getU ( )
inline

Return upper triangular factor

Returns
U portion of LU factorization.

◆ isNonsingular()

template<class Real >
int goMath::LU< Real >::isNonsingular ( )
inline

Is the matrix nonsingular?

Returns
1 (true) if upper triangular factor U (and hence A) is nonsingular, 0 otherwise.

◆ solve() [1/2]

template<class Real >
bool goMath::LU< Real >::solve ( const goMath::Matrix< Real > &  B,
goMath::Matrix< Real > &  retValue 
)
inline

Solve A*X = B

Parameters
BA Matrix with as many rows as A and any number of columns.
Returns
X so that L*U*X = B(piv,:), if B is nonconformant, returns 0x0 (null) array.

◆ solve() [2/2]

template<class Real >
bool goMath::LU< Real >::solve ( const goMath::Vector< Real > &  b,
goMath::Vector< Real > &  retValue 
)
inline

Solve A*x = b, where x and b are vectors of length equal
to the number of rows in A.

Parameters
ba vector (goMath::Vector> of length equal to the first dimension of A.
Returns
x a vector (goMath::Vector> so that L*U*x = b(piv), if B is nonconformant, returns 0x0 (null) array.

The documentation for this class was generated from the following file: