SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWPDTriDiagFact< TypeT > Class Template Reference

Encapsulates factorizations of positive definite symmetric matrices. See also RWPDFact and RWPDBandFact. More...

#include <rw/lapack/pdtdfct.h>

Public Member Functions

 RWPDTriDiagFact ()
 
 RWPDTriDiagFact (const RWTriDiagMat< TypeT > &A, bool ec=true)
 
int cols () const
 
rw_numeric_traits< TypeT >::norm_type condition () const
 
TypeT determinant () const
 
void factor (const RWTriDiagMat< TypeT > &A, bool ec=true)
 
bool fail () const
 
bool good () const
 
bool isPD () const
 
bool isSingular () const
 
int rows () const
 
RWGenMat< TypeT > solve (const RWGenMat< TypeT > &b) const
 
RWMathVec< TypeT > solve (const RWMathVec< TypeT > &b) const
 

Related Symbols

(Note that these are not member symbols.)

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

Detailed Description

template<class TypeT>
class RWPDTriDiagFact< TypeT >

The classes RWPDFact, RWPDBandFact, and RWPDTriDiagFact encapsulate factorizations of positive definite symmetric matrices, which are Hermitians in the complex case. These classes produce a valid factorization only if the matrix being factored is positive definite. If the matrix is not positive definite, attempting to use the factorization to solve a system of equations results in an exception being thrown. To test if the factorization is valid, use the good() or fail() member functions.

Synopsis
#include <rw/lapack/pdbdfct.h>
#include <rw/lapack/pdfct.h>
#include <rw/lapack/pdtdfct.h>
#include <rw/math/genmat.h> // RWGenMat<T>, class T general
RWGenFact<double> LU(A); // A is a RWGenMat<double>
RWPDFact<double> LU4(D); // D is a RWPDMat<double>
RWPDTriDiagFact<double> LU7(G); // G is a RWPDTriDiagMat<double>
A templatized LU factorization class that holds the LU factorization of a general square matrix of ty...
Definition genfact.h:50
Encapsulates factorizations of positive definite symmetric matrices. See also RWPDBandFact and RWPDTr...
Definition pdfct.h:71
Encapsulates factorizations of positive definite symmetric matrices. See also RWPDFact and RWPDBandFa...
Definition pdtdfct.h:71
Example
#include <rw/dgenfct.h>
#include <iostream>
int main() {
// Read in a matrix and a right-hand side and
// print the solution
std::cin >> A >> b;
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;
}
A templatized general matrix class.
Definition genmat.h:741
A templatized vector class.
Definition mathvec.h:667
RWMathVec< TypeT > solve(const RWMathVec< TypeT > &b) const

Constructor & Destructor Documentation

◆ RWPDTriDiagFact() [1/2]

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

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

◆ RWPDTriDiagFact() [2/2]

template<class TypeT >
RWPDTriDiagFact< TypeT >::RWPDTriDiagFact ( const RWTriDiagMat< TypeT > & A,
bool ec = 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 ec is true, you can use the function condition() to obtain an estimate of the condition number of the matrix. Setting ec to false can save some computation if the condition number is not needed.

Member Function Documentation

◆ cols()

template<class TypeT >
int RWPDTriDiagFact< TypeT >::cols ( ) const
inline

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

◆ condition()

template<class TypeT >
rw_numeric_traits< TypeT >::norm_type RWPDTriDiagFact< 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 RWPDTriDiagFact() or factor() to false, calling condition() generates an exception.

◆ determinant()

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

Calculates the determinant of the matrix represented by this factorization.

◆ factor()

template<class TypeT >
void RWPDTriDiagFact< TypeT >::factor ( const RWTriDiagMat< TypeT > & A,
bool ec = 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 arguments) constructor.

◆ fail()

template<class TypeT >
bool RWPDTriDiagFact< 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.

◆ good()

template<class TypeT >
bool RWPDTriDiagFact< 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.

◆ isPD()

template<class TypeT >
bool RWPDTriDiagFact< TypeT >::isPD ( ) const

Tests if the matrix is positive definite. If the matrix is not positive definite, the factorization is not complete and you cannot use the factorization to solve systems of equations.

◆ isSingular()

template<class TypeT >
bool RWPDTriDiagFact< 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.

◆ rows()

template<class TypeT >
int RWPDTriDiagFact< TypeT >::rows ( ) const
inline

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

◆ solve() [1/2]

template<class TypeT >
RWGenMat< TypeT > RWPDTriDiagFact< 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.

◆ solve() [2/2]

template<class TypeT >
RWMathVec< TypeT > RWPDTriDiagFact< 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 Symbol Documentation

◆ condition()

template<class TypeT >
rw_numeric_traits< TypeT >::norm_type condition ( const RWPDTriDiagFact< 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 RWPDTriDiagFact() or the factor() member function to false, calling condition() generates an exception.

◆ determinant()

template<class TypeT >
TypeT determinant ( const RWPDTriDiagFact< TypeT > & A)
related

Calculates the determinant of the matrix represented by the factorization A.

◆ solve() [1/2]

template<class TypeT >
RWGenMat< TypeT > solve ( const RWPDTriDiagFact< 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. It is wise to call one of the member functions good() or fail() to make sure that the factorization was successfully constructed.

◆ solve() [2/2]

template<class TypeT >
RWMathVec< TypeT > solve ( const RWPDTriDiagFact< 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. It is wise to call one of the member functions good() or fail() to make sure that the factorization was successfully constructed.

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