SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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 Symbols

(Note that these are not member symbols.)

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 >
RWGenMat< T > solve (const RWGenFact< T > &m, const RWGenMat< T > &b)
 
template<class T >
RWMathVec< T > solve (const RWGenFact< T > &m, const RWMathVec< T > &b)
 
template<class T >
RWGenMat< T > solve (const RWGenMat< T > &A, const RWGenMat< T > &b)
 
template<class T >
RWMathVec< T > solve (const RWGenMat< T > &A, const RWMathVec< 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);
A templatized LU factorization class that holds the LU factorization of a general square matrix of ty...
Definition genfact.h:50
A templatized general matrix class.
Definition genmat.h:741

Member Typedef Documentation

◆ norm_type

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

◆ RWGenFact() [1/3]

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

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

◆ RWGenFact() [2/3]

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.

◆ RWGenFact() [3/3]

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

◆ condition()

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

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

◆ factor()

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.

◆ fail()

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

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

◆ good()

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

Returns true if the factorization succeeds.

◆ isSingular()

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 Symbol Documentation

◆ condition() [1/2]

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

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

◆ condition() [2/2]

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

Returns the inverse condition number of matrix A

◆ determinant()

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

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

◆ inverse() [1/2]

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.

◆ inverse() [2/2]

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.

◆ solve() [1/4]

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.

◆ solve() [2/4]

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.

◆ solve() [3/4]

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

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

◆ solve() [4/4]

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

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

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