rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWSymFact< TypeT > Class Template Reference
[Factorization]

Encapsulates factorizations of symmetric matrices. More...

#include <rw/lapack/symfct.h>

List of all members.

Public Member Functions

 RWSymFact ()
 RWSymFact (const RWSymMat< TypeT > &A, bool estimateCondition=true)
void factor (const RWSymMat< TypeT > &A, bool estimateCondition=true)
bool good () const
bool fail () const
bool isSingular () const
int rows () const
int cols () const
rw_numeric_traits< TypeT >
::norm_type 
condition () const
RWMathVec< TypeT > solve (const RWMathVec< TypeT > &b) const
RWGenMat< TypeT > solve (const RWGenMat< TypeT > &b) const
TypeT determinant () const
RWSymMat< TypeT > inverse () const

Related Functions

(Note that these are not member functions.)



template<class TypeT >
RWMathVec< TypeT > solve (const RWSymFact< TypeT > &A, const RWMathVec< TypeT > &b)
template<class TypeT >
RWGenMat< TypeT > solve (const RWSymFact< TypeT > &A, const RWGenMat< TypeT > &B)
template<class TypeT >
TypeT determinant (const RWSymFact< TypeT > &A)
template<class TypeT >
RWSymMat< TypeT > inverse (const RWSymFact< TypeT > &A)
template<class TypeT >
rw_numeric_traits< TypeT >
::norm_type 
condition (const RWSymFact< TypeT > &A)

Detailed Description

template<class TypeT>
class RWSymFact< TypeT >

A factorization is a representation of a matrix that can be used to efficiently solve systems of equations, and to compute the inverse, determinant, and condition number of a matrix. The class RWSymFact<T> encapsulates factorizations of symmetric matrices. Provided the matrix being factored is nonsingular, the resulting factorization can always be used to solve a system of equations.

Synopsis

 #include <rw/lapack/symfct.h>
 
 RWSymFact<double> LU2(B);       // B is a RWSymMat<double>

Examples

 #include <iostream>
 #include <rw/lapack/symfct.h>
 
 int main()
 {
    // Read in a matrix and a right-hand side and
    // print the solution
    RWSymMat<double> A;
    RWMathVec<double> b;
    std::cin >> A >> b;

    RWSymFact<double> LU(A);
    if (LU.good()) {
       std::cout << "solution is " << solve(LU, b) << std::endl;
    } else {
       std::cout << "Could not factor A, perhaps it is singular"
                 << std::endl;
    }

    return 0;
 }

Constructor & Destructor Documentation

template<class TypeT>
RWSymFact< TypeT >::RWSymFact (  ) 

Default constructor. Builds a factorization of a 0 x 0 matrix. You use the member function factor() to fill in the factorization.

template<class TypeT>
RWSymFact< TypeT >::RWSymFact ( const RWSymMat< TypeT > &  A,
bool  estimateCondition = true 
)

Constructs a factorization of the matrix A. This factorization can be used to solve systems of equations, and to calculate inverses and determinants. If the parameter estimateCondition is true, you can use the function condition() to obtain an estimate of the condition number of the matrix. Setting estimateCondition to false can save some computation if the condition number is not needed.


Member Function Documentation

template<class TypeT>
int RWSymFact< TypeT >::cols (  )  const [inline]

Returns the number of columns in the matrix represented by this factorization.

template<class TypeT>
rw_numeric_traits<TypeT>::norm_type RWSymFact< TypeT >::condition (  )  const

Calculates the reciprocal condition number of the matrix represented by this factorization. If this number is near 0, the matrix is ill-conditioned and solutions to systems of equations computed using this factorization may not be accurate. If the number is near 1, the matrix is well-conditioned. For the condition number to be computed, the norm of the matrix must be computed at the time the factorization is constructed. If you set the optional boolean parameter in the constructor or factor() to false, calling condition() generates an exception.

template<class TypeT>
TypeT RWSymFact< TypeT >::determinant (  )  const

Calculates the determinant of the matrix represented by this factorization.

template<class TypeT>
void RWSymFact< TypeT >::factor ( const RWSymMat< TypeT > &  A,
bool  estimateCondition = true 
)

Factors a matrix. Calling factor() replaces the current factorization with the factorization of the matrix A. This is commonly used to initialize a factorization constructed with the default (no parameters) constructor.

template<class TypeT>
bool RWSymFact< TypeT >::fail (  )  const

Checks whether the factorization is successfully constructed. If fail() returns true, attempting to use the factorization to solve a system of equations results in an exception being thrown.

template<class TypeT>
bool RWSymFact< TypeT >::good (  )  const [inline]

Checks whether the factorization is successfully constructed. If good() returns false, attempting to use the factorization to solve a system of equations results in an exception being thrown.

template<class TypeT>
RWSymMat<TypeT> RWSymFact< TypeT >::inverse (  )  const

Computes the inverse of the matrix represented by this factorization. Although matrix inverses are very useful in theoretical analysis, they are rarely necessary in implementation. A factorization is nearly always as useful as the actual inverse, and can be constructed at far less cost.

template<class TypeT>
bool RWSymFact< TypeT >::isSingular (  )  const

Tests if the matrix is singular to within machine precision. If the factorization is a positive definite type and the matrix that was factored is not actually positive definite, then isSingular() may return true regardless of whether or not the matrix is actually singular.

template<class TypeT>
int RWSymFact< TypeT >::rows (  )  const [inline]

Returns the number of rows in the matrix represented by this factorization.

template<class TypeT>
RWGenMat<TypeT> RWSymFact< TypeT >::solve ( const RWGenMat< TypeT > &  b  )  const

Solves a system of equations. Returns the matrix x, which satisfies $ Ax = b $, where A is the matrix represented by this factorization. It is wise to call good() or fail() to make sure that the factorization was successfully constructed.

template<class TypeT>
RWMathVec<TypeT> RWSymFact< TypeT >::solve ( const RWMathVec< TypeT > &  b  )  const

Solves a system of equations. Returns the vector x, which satisfies $ Ax = b $, where A is the matrix represented by this factorization. It is wise to call good() or fail() to make sure that the factorization was successfully constructed.


Friends And Related Function Documentation

template<class TypeT >
rw_numeric_traits< TypeT >::norm_type condition ( const RWSymFact< TypeT > &  A  )  [related]

Calculates the reciprocal condition number of the matrix represented by the factorization A. If this number is near 0, the matrix is ill-conditioned and solutions to systems of equations computed using this factorization may not be accurate. If the number is near 1, the matrix is well-conditioned. For the condition number to be computed, the norm of the matrix must be computed at the time the factorization is constructed. If you set the optional boolean parameter in the constructor or the factor() member function of A to false, calling condition() generates an exception.

template<class TypeT >
TypeT determinant ( const RWSymFact< TypeT > &  A  )  [related]

Calculates the determinant of the matrix represented by factorization A.

template<class TypeT >
RWSymMat< TypeT > inverse ( const RWSymFact< TypeT > &  A  )  [related]

Computes the inverse of the matrix represented by factorization A. Although matrix inverses are very useful in theoretical analysis, they are rarely necessary in implementation. A factorization is nearly always as useful as the actual inverse, and can be constructed at far less cost.

template<class TypeT >
RWGenMat< TypeT > solve ( const RWSymFact< TypeT > &  A,
const RWGenMat< TypeT > &  B 
) [related]

Solves a system of equations. Returns the matrix X, which satisfies $ AX = B $, where A is the matrix represented by the factorization A. It is wise to call one of the member functions good() or fail() of A to make sure that the factorization was successfully constructed.

template<class TypeT >
RWMathVec< TypeT > solve ( const RWSymFact< TypeT > &  A,
const RWMathVec< TypeT > &  b 
) [related]

Solves a system of equations. Returns the vector x, which satisfies $ Ax = b $, where A is the matrix represented by the factorization A. It is wise to call one of the member functions good() or fail() of A to make sure that the factorization was successfully constructed.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© 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.