|
Teuchos - Trilinos Tools Package
Version of the Day
|
A class for constructing and using Hermitian positive definite dense matrices. More...
#include <Teuchos_SerialSpdDenseSolver.hpp>
Public Member Functions | |
Constructor/Destructor Methods | |
| SerialSpdDenseSolver () | |
| Default constructor; matrix should be set using setMatrix(), LHS and RHS set with setVectors(). | |
| virtual | ~SerialSpdDenseSolver () |
| SerialSpdDenseSolver destructor. | |
Set Methods | |
| int | setMatrix (const RCP< SerialSymDenseMatrix< OrdinalType, ScalarType > > &A_in) |
| Sets the pointers for coefficient matrix. | |
| int | setVectors (const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &X, const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &B) |
| Sets the pointers for left and right hand side vector(s). | |
Strategy Modifying Methods | |
| void | factorWithEquilibration (bool flag) |
Causes equilibration to be called just before the matrix factorization as part of the call to factor. | |
| void | solveToRefinedSolution (bool flag) |
| Causes all solves to compute solution to best ability using iterative refinement. | |
| void | estimateSolutionErrors (bool flag) |
| Causes all solves to estimate the forward and backward solution error. | |
Factor/Solve/Invert Methods | |
| int | factor () |
| Computes the in-place Cholesky factorization of the matrix using the LAPACK routine DPOTRF. | |
| int | solve () |
| Computes the solution X to AX = B for the this matrix and the B provided to SetVectors().. | |
| int | invert () |
| Inverts the this matrix. | |
| int | computeEquilibrateScaling () |
| Computes the scaling vector S(i) = 1/sqrt(A(i,i) of the this matrix. | |
| int | equilibrateMatrix () |
| Equilibrates the this matrix. | |
| int | equilibrateRHS () |
| Equilibrates the current RHS. | |
| int | applyRefinement () |
| Apply Iterative Refinement. | |
| int | unequilibrateLHS () |
| Unscales the solution vectors if equilibration was used to solve the system. | |
| int | reciprocalConditionEstimate (MagnitudeType &Value) |
| Returns the reciprocal of the 1-norm condition number of the this matrix. | |
Query methods | |
| bool | transpose () |
| Returns true if transpose of this matrix has and will be used. | |
| bool | factored () |
| Returns true if matrix is factored (factor available via AF() and LDAF()). | |
| bool | equilibratedA () |
| Returns true if factor is equilibrated (factor available via AF() and LDAF()). | |
| bool | equilibratedB () |
| Returns true if RHS is equilibrated (RHS available via B() and LDB()). | |
| bool | shouldEquilibrate () |
| Returns true if the LAPACK general rules for equilibration suggest you should equilibrate the system. | |
| bool | solutionErrorsEstimated () |
| Returns true if forward and backward error estimated have been computed (available via FERR() and BERR()). | |
| bool | inverted () |
| Returns true if matrix inverse has been computed (inverse available via AF() and LDAF()). | |
| bool | reciprocalConditionEstimated () |
| Returns true if the condition number of the this matrix has been computed (value available via ReciprocalConditionEstimate()). | |
| bool | solved () |
| Returns true if the current set of vectors has been solved. | |
| bool | solutionRefined () |
| Returns true if the current set of vectors has been refined. | |
Data Accessor methods | |
| RCP< SerialSymDenseMatrix < OrdinalType, ScalarType > > | getMatrix () const |
| Returns pointer to current matrix. | |
| RCP< SerialSymDenseMatrix < OrdinalType, ScalarType > > | getFactoredMatrix () const |
| Returns pointer to factored matrix (assuming factorization has been performed). | |
| RCP< SerialDenseMatrix < OrdinalType, ScalarType > > | getLHS () const |
| Returns pointer to current LHS. | |
| RCP< SerialDenseMatrix < OrdinalType, ScalarType > > | getRHS () const |
| Returns pointer to current RHS. | |
| OrdinalType | numRows () const |
| Returns row dimension of system. | |
| OrdinalType | numCols () const |
| Returns column dimension of system. | |
| MagnitudeType | ANORM () const |
| Returns the 1-Norm of the this matrix (returns -1 if not yet computed). | |
| MagnitudeType | RCOND () const |
| Returns the reciprocal of the condition number of the this matrix (returns -1 if not yet computed). | |
| MagnitudeType | SCOND () |
| Ratio of smallest to largest equilibration scale factors for the this matrix (returns -1 if not yet computed). | |
| MagnitudeType | AMAX () const |
| Returns the absolute value of the largest entry of the this matrix (returns -1 if not yet computed). | |
| std::vector< MagnitudeType > | FERR () const |
| Returns a pointer to the forward error estimates computed by LAPACK. | |
| std::vector< MagnitudeType > | BERR () const |
| Returns a pointer to the backward error estimates computed by LAPACK. | |
| std::vector< MagnitudeType > | R () const |
| Returns a pointer to the row scaling vector used for equilibration. | |
I/O methods | |
| void | Print (std::ostream &os) const |
| Print service methods; defines behavior of ostream << operator. | |
A class for constructing and using Hermitian positive definite dense matrices.
The Teuchos::SerialSpdDenseSolver class enables the construction and use of a templated, Hermitian positive definite, double-precision dense matrices. It is built on the BLAS and LAPACK via the Teuchos::BLAS and Teuchos::LAPACK classes.
The Teuchos::SerialSpdDenseSolver class is intended to provide full-featured support for solving linear system problems for Hermitian positive definite matrices. It is written on top of BLAS and LAPACK and thus has excellent performance and numerical capabilities. Using this class, one can either perform simple factorizations and solves or apply all the tricks available in LAPACK to get the best possible solution for very ill-conditioned problems.
Teuchos::SerialSpdDenseSolver vs. Teuchos::LAPACK
The Teuchos::LAPACK class provides access to most of the same functionality as Teuchos::SerialSpdDenseSolver. The primary difference is that Teuchos::LAPACK is a "thin" layer on top of LAPACK and Teuchos::SerialSpdDenseSolver attempts to provide easy access to the more sophisticated aspects of solving dense linear and eigensystems.
Extracting Data from Teuchos::SerialSpdDenseSolver Objects
Once a Teuchos::SerialSpdDenseSolver is constructed, it is possible to view the data via access functions.
Vector and Utility Functions
Once a Teuchos::SerialSpdDenseSolver is constructed, several mathematical functions can be applied to the object. Specifically:
Strategies for Solving Linear Systems In many cases, linear systems can be accurately solved by simply computing the Cholesky factorization of the matrix and then performing a forward back solve with a given set of right hand side vectors. However, in some instances, the factorization may be very poorly conditioned and the simple approach may not work. In these situations, equilibration and iterative refinement may improve the accuracy, or prevent a breakdown in the factorization.
Teuchos::SerialSpdDenseSolver will use equilibration with the factorization if, once the object is constructed and before it is factored, you call the function FactorWithEquilibration(true) to force equilibration to be used. If you are uncertain if equilibration should be used, you may call the function ShouldEquilibrate() which will return true if equilibration could possibly help. ShouldEquilibrate() uses guidelines specified in the LAPACK User Guide, namely if SCOND < 0.1 and AMAX < Underflow or AMAX > Overflow, to determine if equilibration might be useful.
Teuchos::SerialSpdDenseSolver will use iterative refinement after a forward/back solve if you call SolveToRefinedSolution(true). It will also compute forward and backward error estimates if you call EstimateSolutionErrors(true). Access to the forward (back) error estimates is available via FERR() (BERR()).
Examples using Teuchos::SerialSpdDenseSolver can be found in the Teuchos test directories.
Definition at line 133 of file Teuchos_SerialSpdDenseSolver.hpp.
| Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::SerialSpdDenseSolver | ( | ) |
Default constructor; matrix should be set using setMatrix(), LHS and RHS set with setVectors().
Definition at line 411 of file Teuchos_SerialSpdDenseSolver.hpp.
| Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::~SerialSpdDenseSolver | ( | ) | [virtual] |
SerialSpdDenseSolver destructor.
Definition at line 444 of file Teuchos_SerialSpdDenseSolver.hpp.
| int Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::setMatrix | ( | const RCP< SerialSymDenseMatrix< OrdinalType, ScalarType > > & | A_in | ) |
Sets the pointers for coefficient matrix.
Definition at line 485 of file Teuchos_SerialSpdDenseSolver.hpp.
| int Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::setVectors | ( | const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > & | X, |
| const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > & | B | ||
| ) |
Sets the pointers for left and right hand side vector(s).
Row dimension of X must match column dimension of matrix A, row dimension of B must match row dimension of A. X and B must have the same dimensions.
Definition at line 500 of file Teuchos_SerialSpdDenseSolver.hpp.
| void Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::factorWithEquilibration | ( | bool | flag | ) | [inline] |
Causes equilibration to be called just before the matrix factorization as part of the call to factor.
This function must be called before the factorization is performed.
Definition at line 185 of file Teuchos_SerialSpdDenseSolver.hpp.
| void Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::solveToRefinedSolution | ( | bool | flag | ) | [inline] |
Causes all solves to compute solution to best ability using iterative refinement.
Definition at line 188 of file Teuchos_SerialSpdDenseSolver.hpp.
| void Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::estimateSolutionErrors | ( | bool | flag | ) |
Causes all solves to estimate the forward and backward solution error.
Error estimates will be in the arrays FERR and BERR, resp, after the solve step is complete. These arrays are accessible via the FERR() and BERR() access functions.
Definition at line 523 of file Teuchos_SerialSpdDenseSolver.hpp.
| int Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::factor | ( | ) |
Computes the in-place Cholesky factorization of the matrix using the LAPACK routine DPOTRF.
Definition at line 533 of file Teuchos_SerialSpdDenseSolver.hpp.
| int Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::solve | ( | ) |
Computes the solution X to AX = B for the this matrix and the B provided to SetVectors()..
Definition at line 580 of file Teuchos_SerialSpdDenseSolver.hpp.
| int Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::invert | ( | ) |
Inverts the this matrix.
Note: This function works a little differently that DPOTRI in that it fills the entire matrix with the inverse, independent of the UPLO specification.
Definition at line 835 of file Teuchos_SerialSpdDenseSolver.hpp.
| int Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::computeEquilibrateScaling | ( | ) |
Computes the scaling vector S(i) = 1/sqrt(A(i,i) of the this matrix.
Definition at line 692 of file Teuchos_SerialSpdDenseSolver.hpp.
| int Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::equilibrateMatrix | ( | ) |
Equilibrates the this matrix.
Definition at line 711 of file Teuchos_SerialSpdDenseSolver.hpp.
| int Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::equilibrateRHS | ( | ) |
Equilibrates the current RHS.
Definition at line 784 of file Teuchos_SerialSpdDenseSolver.hpp.
| int Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::applyRefinement | ( | ) |
Apply Iterative Refinement.
Definition at line 657 of file Teuchos_SerialSpdDenseSolver.hpp.
| int Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::unequilibrateLHS | ( | ) |
Unscales the solution vectors if equilibration was used to solve the system.
Definition at line 812 of file Teuchos_SerialSpdDenseSolver.hpp.
| int Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::reciprocalConditionEstimate | ( | MagnitudeType & | Value | ) |
Returns the reciprocal of the 1-norm condition number of the this matrix.
| Value | Out On return contains the reciprocal of the 1-norm condition number of the this matrix. |
Definition at line 862 of file Teuchos_SerialSpdDenseSolver.hpp.
| bool Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::transpose | ( | ) | [inline] |
Returns true if transpose of this matrix has and will be used.
Definition at line 265 of file Teuchos_SerialSpdDenseSolver.hpp.
| bool Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::factored | ( | ) | [inline] |
Returns true if matrix is factored (factor available via AF() and LDAF()).
Definition at line 268 of file Teuchos_SerialSpdDenseSolver.hpp.
| bool Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::equilibratedA | ( | ) | [inline] |
Returns true if factor is equilibrated (factor available via AF() and LDAF()).
Definition at line 271 of file Teuchos_SerialSpdDenseSolver.hpp.
| bool Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::equilibratedB | ( | ) | [inline] |
Returns true if RHS is equilibrated (RHS available via B() and LDB()).
Definition at line 274 of file Teuchos_SerialSpdDenseSolver.hpp.
| bool Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::shouldEquilibrate | ( | ) | [inline] |
Returns true if the LAPACK general rules for equilibration suggest you should equilibrate the system.
Definition at line 277 of file Teuchos_SerialSpdDenseSolver.hpp.
| bool Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::solutionErrorsEstimated | ( | ) | [inline] |
Returns true if forward and backward error estimated have been computed (available via FERR() and BERR()).
Definition at line 280 of file Teuchos_SerialSpdDenseSolver.hpp.
| bool Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::inverted | ( | ) | [inline] |
Returns true if matrix inverse has been computed (inverse available via AF() and LDAF()).
Definition at line 283 of file Teuchos_SerialSpdDenseSolver.hpp.
| bool Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::reciprocalConditionEstimated | ( | ) | [inline] |
Returns true if the condition number of the this matrix has been computed (value available via ReciprocalConditionEstimate()).
Definition at line 286 of file Teuchos_SerialSpdDenseSolver.hpp.
| bool Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::solved | ( | ) | [inline] |
Returns true if the current set of vectors has been solved.
Definition at line 289 of file Teuchos_SerialSpdDenseSolver.hpp.
| bool Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::solutionRefined | ( | ) | [inline] |
Returns true if the current set of vectors has been refined.
Definition at line 292 of file Teuchos_SerialSpdDenseSolver.hpp.
| RCP<SerialSymDenseMatrix<OrdinalType, ScalarType> > Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::getMatrix | ( | ) | const [inline] |
Returns pointer to current matrix.
Definition at line 299 of file Teuchos_SerialSpdDenseSolver.hpp.
| RCP<SerialSymDenseMatrix<OrdinalType, ScalarType> > Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::getFactoredMatrix | ( | ) | const [inline] |
Returns pointer to factored matrix (assuming factorization has been performed).
Definition at line 302 of file Teuchos_SerialSpdDenseSolver.hpp.
| RCP<SerialDenseMatrix<OrdinalType, ScalarType> > Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::getLHS | ( | ) | const [inline] |
Returns pointer to current LHS.
Definition at line 305 of file Teuchos_SerialSpdDenseSolver.hpp.
| RCP<SerialDenseMatrix<OrdinalType, ScalarType> > Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::getRHS | ( | ) | const [inline] |
Returns pointer to current RHS.
Definition at line 308 of file Teuchos_SerialSpdDenseSolver.hpp.
| OrdinalType Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::numRows | ( | ) | const [inline] |
Returns row dimension of system.
Definition at line 311 of file Teuchos_SerialSpdDenseSolver.hpp.
| OrdinalType Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::numCols | ( | ) | const [inline] |
Returns column dimension of system.
Definition at line 314 of file Teuchos_SerialSpdDenseSolver.hpp.
| MagnitudeType Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::ANORM | ( | ) | const [inline] |
Returns the 1-Norm of the this matrix (returns -1 if not yet computed).
Definition at line 317 of file Teuchos_SerialSpdDenseSolver.hpp.
| MagnitudeType Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::RCOND | ( | ) | const [inline] |
Returns the reciprocal of the condition number of the this matrix (returns -1 if not yet computed).
Definition at line 320 of file Teuchos_SerialSpdDenseSolver.hpp.
| MagnitudeType Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::SCOND | ( | ) | [inline] |
Ratio of smallest to largest equilibration scale factors for the this matrix (returns -1 if not yet computed).
If SCOND() is >= 0.1 and AMAX() is not close to overflow or underflow, then equilibration is not needed.
Definition at line 325 of file Teuchos_SerialSpdDenseSolver.hpp.
| MagnitudeType Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::AMAX | ( | ) | const [inline] |
Returns the absolute value of the largest entry of the this matrix (returns -1 if not yet computed).
Definition at line 328 of file Teuchos_SerialSpdDenseSolver.hpp.
| std::vector<MagnitudeType> Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::FERR | ( | ) | const [inline] |
Returns a pointer to the forward error estimates computed by LAPACK.
Definition at line 331 of file Teuchos_SerialSpdDenseSolver.hpp.
| std::vector<MagnitudeType> Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::BERR | ( | ) | const [inline] |
Returns a pointer to the backward error estimates computed by LAPACK.
Definition at line 334 of file Teuchos_SerialSpdDenseSolver.hpp.
| std::vector<MagnitudeType> Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::R | ( | ) | const [inline] |
Returns a pointer to the row scaling vector used for equilibration.
Definition at line 337 of file Teuchos_SerialSpdDenseSolver.hpp.
| void Teuchos::SerialSpdDenseSolver< OrdinalType, ScalarType >::Print | ( | std::ostream & | os | ) | const |
Print service methods; defines behavior of ostream << operator.
Definition at line 895 of file Teuchos_SerialSpdDenseSolver.hpp.
1.7.6.1