SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
A templatized LU factorization class that holds the LU factorization of a general square matrix of type T. More...
#include <rw/math/genfact.h>
Public Types | |
typedef rw_numeric_traits< T > ::norm_type | norm_type |
Public Member Functions | |
RWGenFact () | |
RWGenFact (const RWGenFact< T > &A) | |
RWGenFact (const RWGenMat< T > &A, bool estimateCondition=true) | |
void | factor (const RWGenMat< T > &A, bool estimateCondition=true) |
bool | good () const |
bool | fail () const |
bool | isSingular () const |
norm_type | condition () const |
Related Functions | |
(Note that these are not member functions.) | |
template<class T > | |
RWMathVec< T > | solve (const RWGenFact< T > &m, const RWMathVec< T > &b) |
template<class T > | |
RWMathVec< T > | solve (const RWGenMat< T > &A, const RWMathVec< T > &b) |
template<class T > | |
RWGenMat< T > | solve (const RWGenFact< T > &m, const RWGenMat< T > &b) |
template<class T > | |
RWGenMat< T > | solve (const RWGenMat< T > &A, const RWGenMat< T > &b) |
template<class T > | |
T | determinant (const RWGenFact< T > &A) |
template<class T > | |
RWGenMat< T > | inverse (const RWGenFact< T > &A) |
template<class T > | |
RWGenMat< T > | inverse (const RWGenMat< T > &A) |
template<class T > | |
double | condition (const RWGenFact< T > &A) |
template<class T > | |
double | condition (const RWGenMat< T > &A) |
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.
#include <rw/math/genfact.h> #include <rw/math/genmat.h> RWGenMat<T> matrix; template <class T> RWGenFact<T> LUFactor(matrix);
typedef rw_numeric_traits<T>::norm_type RWGenFact< T >::norm_type |
This is a convenience typedef. The condition numbers have type dependent on the traits class.
Sets up an empty LU factorization. Member function factor() can then be used to actually calculate the factorization.
Copy constructor. Reference semantics are used; that is, a shallow copy of the argument is made.
RWGenFact< T >::RWGenFact | ( | const RWGenMat< T > & | A, | |
bool | estimateCondition = true | |||
) |
Constructs an LU factorization from the matrix m. If the argument estimateCondition is true
, a condition number is also calculated. Setting estimateCondition 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 RWLAPK_NOTSQUARE
occurs. This constructor also serves as a type conversion from RWGenMat<T> to RWGenFact<T>
An exception with value RWMATH_NOCONDITION
occurs if the condition number is not calculated.
void RWGenFact< T >::factor | ( | const RWGenMat< T > & | A, | |
bool | estimateCondition = true | |||
) |
Recalculates the factorization, this time using the matrix m. If the argument estimateCondition is true
, a condition number is also calculated.
bool RWGenFact< T >::fail | ( | ) | const |
Returns true
if the factorization fails, perhaps due to singularity, otherwise returns false
.
bool RWGenFact< T >::good | ( | ) | const [inline] |
Returns true
if the factorization succeeds.
bool RWGenFact< T >::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.
double condition | ( | const RWGenMat< T > & | A | ) | [related] |
Returns the inverse condition number of matrix A
double condition | ( | const RWGenFact< T > & | A | ) | [related] |
Returns the inverse condition number of the matrix whose LU factorization is A.
T determinant | ( | const RWGenFact< T > & | A | ) | [related] |
Returns the determinant of the matrix from which an LU factorization A is constructed.
Returns the inverse of the matrix from which an existing LU factorization was constructed. If the factorization of A is invalid, perhaps because the original matrix was singular, an exception with value LPAK_CANTSOLVE
occurs.
Returns the inverse of the matrix from which an existing LU factorization was constructed. If the factorization A is invalid, perhaps because the original matrix was singular, an exception with value LPAK_CANTSOLVE
occurs.
RWGenMat< T > solve | ( | const RWGenMat< T > & | A, | |
const RWGenMat< T > & | b | |||
) | [related] |
Calculates the solution to .
RWGenMat< T > solve | ( | const RWGenFact< T > & | m, | |
const RWGenMat< T > & | b | |||
) | [related] |
Calculates the solution to , where b is an LU factorization constructed from the RWGenMat<T> A.
If the factorization m is invalid, perhaps because the original matrix A was singular, an exception with value LPAK_CANTSOLVE
occurs. If the number of elements in x does not match the order of A, an exception with value LPAK_VECLENGTH
occurs.
RWMathVec< T > solve | ( | const RWGenMat< T > & | A, | |
const RWMathVec< T > & | b | |||
) | [related] |
Calculates the solution to .
RWMathVec< T > solve | ( | const RWGenFact< T > & | m, | |
const RWMathVec< T > & | b | |||
) | [related] |
Calculates the solution to , where m is an LU factorization constructed from the RWGenMat<T> A
.
If the factorization m is invalid, perhaps because the original matrix A was singular, an exception with value LPAK_CANTSOLVE
occurs. If the number of elements in x does not match the order of A, an exception with value LPAK_VECLENGTH
occurs.
© 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.