Module: Essential Math Group: LU Factorization classes
Does not inherit
#include <rw/math/genfact.h> #include <rw/math/genmat.h> RWGenMat<T> matrix; template <class T> RWGenFact<T> LUFactor(matrix);
Class RWGenFact<T> is a templatized LU factorization class. This class holds the LU factorization of a general square matrix of type T. Once such a factorization is built, it can be used to invert a matrix, calculate its determinant, or solve a set of simultaneous linear equations.
Optionally, a condition number can be calculated and then recovered via member function condition(), which returns the reciprocal of the standard definition for the condition number of a matrix.
The result is in the range [0,1]. The closer the result is to 0, the closer the matrix is to being singular. See Dongarra et al. (1979) for additional information.
RWGenFact();
Sets up an empty LU factorization. Member function factor() can then be used to actually calculate the factorization.
RWGenFact(const RWGenMat<T>& m, bool ce = true);
Constructs an LU factorization from the matrix m. If the argument ce is true, a condition number is also calculated. Setting ce to false saves some time (perhaps 20%), but gives you less information about how ill-conditioned the matrix is. If the matrix m is not square, an exception with value LPAK_NOTSQUARE occurs. This constructor also serves as a type conversion from RWGenMat<T> to RWGenFact<T>.
RWGenFact(const RWGenFact<T>&);
Copy constructor. Reference semantics are used; that is, a shallow copy of the argument is made.
double condition() const;
An exception with value LPAK_NOCONDITION occurs if the condition number is not calculated.
bool fail() const;
Returns true if the factorization fails, perhaps due to singularity, otherwise returns false.
void factor(const RWGenMat<T>& m, bool ce = true);
Recalculates the factorization, this time using the matrix m. If the argument ce is true, a condition number is also calculated.
bool good() const;
Returns true if the factorization succeeds.
int isSingular() const;
Checks to see if the matrix is singular. If isSingular() returns a non-zero value, the matrix is singular. Note that the LU factorization is still defined; however, an attempt to use it to compute the matrix inverse fails.
unsigned order() const;
Returns the order of the matrix from which the LU factorization is constructed.
double condition(const RWGenFact<T>& m); double condition(const RWGenMat<T>& A);
Returns the inverse condition number of matrix A or of the matrix whose LU factorization is m.
T determinant(const RWGenFact<T>& m);
Returns the determinant of the matrix from which an LU factorization m is constructed.
RWGenMat<T> inverse(const RWGenFact<T>& m); RWGenMat<T> inverse(const RWGenMat<T>& A);
Calculates the inverse of the matrix from which an existing LU factorization m is constructed.
RWMathVec<T> solve(const RWGenFact<T>& m, const RWMathVec<T>& b); RWGenMat<T> solve(const RWGenFact<T>& m, const RWGenMat<T>& b); RWMathVec<T> solve(const RWGenMat<T>& A, const RWMathVec<T>& b); RWGenMat<T> solve(const RWGenMat<T>& A, const RWGenMat<T>& b);
Calculates the solution to A*x = b, where m is an LU factorization constructed from the RWGenMat<T> A.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.