SourcePro® API Reference Guide

 
List of all members | Public Types | Public Member Functions | Related Functions
RWGenFact< T > Class Template Reference

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)
 
norm_type condition () const
 
void factor (const RWGenMat< T > &A, bool estimateCondition=true)
 
bool fail () const
 
bool good () const
 
bool isSingular () const
 

Related Functions

(Note that these are not member functions.)

template<class T >
double condition (const RWGenFact< T > &A)
 
template<class T >
double condition (const RWGenMat< T > &A)
 
template<class 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 >
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)
 

Detailed Description

template<class T>
class RWGenFact< T >

Class RWGenFact 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.

Synopsis
#include <rw/math/genfact.h>
#include <rw/math/genmat.h>
RWGenMat<T> matrix;
template <class T>
RWGenFact<T> LUFactor(matrix);

Member Typedef Documentation

template<class T>
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.

Constructor & Destructor Documentation

template<class T>
RWGenFact< T >::RWGenFact ( )

Sets up an empty LU factorization. Member function factor() can then be used to actually calculate the factorization.

template<class T>
RWGenFact< T >::RWGenFact ( const RWGenFact< T > &  A)

Copy constructor. Reference semantics are used; that is, a shallow copy of the argument is made.

template<class T>
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 to RWGenFact

Member Function Documentation

template<class T>
norm_type RWGenFact< T >::condition ( ) const

An exception with value RWMATH_NOCONDITION occurs if the condition number is not calculated.

template<class T>
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.

template<class T>
bool RWGenFact< T >::fail ( ) const

Returns true if the factorization fails, perhaps due to singularity, otherwise returns false.

template<class T>
bool RWGenFact< T >::good ( ) const
inline

Returns true if the factorization succeeds.

template<class T>
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.

Friends And Related Function Documentation

template<class T >
double condition ( const RWGenFact< T > &  A)
related

Returns the inverse condition number of the matrix whose LU factorization is A.

template<class T >
double condition ( const RWGenMat< T > &  A)
related

Returns the inverse condition number of matrix A

template<class T >
T determinant ( const RWGenFact< T > &  A)
related

Returns the determinant of the matrix from which an LU factorization A is constructed.

template<class T >
RWGenMat< T > inverse ( const RWGenFact< T > &  A)
related

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.

template<class T >
RWGenMat< T > inverse ( const RWGenMat< T > &  A)
related

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.

template<class T >
RWMathVec< T > solve ( const RWGenFact< T > &  m,
const RWMathVec< T > &  b 
)
related

Calculates the solution to \( A*x = b \), where m is an LU factorization constructed from the RWGenMat 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.

template<class T >
RWMathVec< T > solve ( const RWGenMat< T > &  A,
const RWMathVec< T > &  b 
)
related

Calculates the solution to \( A*x = b \).

template<class T >
RWGenMat< T > solve ( const RWGenFact< T > &  m,
const RWGenMat< T > &  b 
)
related

Calculates the solution to \( A*x = b \), where b is an LU factorization constructed from the RWGenMat 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.

template<class T >
RWGenMat< T > solve ( const RWGenMat< T > &  A,
const RWGenMat< T > &  b 
)
related

Calculates the solution to \( A*x = b \).

Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.