|
Teuchos - Trilinos Tools Package
Version of the Day
|
A class for representing and solving banded dense linear systems. More...
#include <Teuchos_SerialBandDenseSolver.hpp>
Public Member Functions | |
Constructor/Destructor Methods | |
| SerialBandDenseSolver () | |
| Default constructor; matrix should be set using setMatrix(), LHS and RHS set with setVectors(). | |
| virtual | ~SerialBandDenseSolver () |
| SerialBandDenseSolver destructor. | |
Set Methods | |
| int | setMatrix (const RCP< SerialBandDenseMatrix< OrdinalType, ScalarType > > &AB) |
| Sets the pointer 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) |
| void | solveWithTranspose (bool flag) |
| void | solveWithTransposeFlag (Teuchos::ETransp trans) |
| void | solveToRefinedSolution (bool flag) |
| Set whether or not to use iterative refinement to improve solutions to linear systems. | |
| void | estimateSolutionErrors (bool flag) |
| Causes all solves to estimate the forward and backward solution error. | |
Factor/Solve Methods | |
| int | factor () |
| Computes the in-place LU factorization of the matrix using the LAPACK routine _GBTRF. | |
| int | solve () |
| Computes the solution X to AX = B for the this matrix and the B provided to SetVectors().. | |
| 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 | 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< SerialBandDenseMatrix < OrdinalType, ScalarType > > | getMatrix () const |
| Returns pointer to current matrix. | |
| RCP< SerialBandDenseMatrix < 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. | |
| OrdinalType | numLower () const |
| Returns lower bandwidth of system. | |
| OrdinalType | numUpper () const |
| Returns upper bandwidth of system. | |
| std::vector< OrdinalType > | IPIV () const |
| Returns pointer to pivot vector (if factorization has been computed), zero otherwise. | |
| 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 | ROWCND () const |
| Ratio of smallest to largest row scale factors for the this matrix (returns -1 if not yet computed). | |
| MagnitudeType | COLCND () const |
| Ratio of smallest to largest column 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. | |
| std::vector< MagnitudeType > | C () const |
| Returns a pointer to the column scale vector used for equilibration. | |
I/O methods | |
| void | Print (std::ostream &os) const |
| Print service methods; defines behavior of ostream << operator. | |
A class for representing and solving banded dense linear systems.
| OrdinalType | The index type used by the linear algebra implementation. This should always be int. |
| ScalarType | The type of entries in the matrix. |
This class defines a banded dense matrix, which may have any number of rows or columns (not necessarily equal). It's called "serial" because the matrix lives in a single memory space. Thus, it's the kind of matrix that one might give to the BLAS or LAPACK, not a distributed matrix like one would give to ScaLAPACK.
This class also has methods for computing the (banded) LU factorization of the matrix, and solving linear systems with the matrix. We use instances of SerialDenseVector to represent the right-hand side b or the solution x in the linear system
. The instance of this class used store the banded matrix must contain KL extra superdiagonals to store the L and U factors (see details below).
Users have the option to do equilibration before factoring the matrix. This may improve accuracy when solving ill-conditioned problems.
Teuchos' LAPACK class wraps LAPACK's LU factorizations, including the banded factorizations. It thus gives access to most of the same functionality as SerialBandDenseSolver. The main difference is that SerialBandDenseSolver offers a higher level of abstraction. It hides the details of which LAPACK routines to call. Furthermore, if you have built Teuchos with support for the third-party library Eigen, SerialBandDenseSolver lets you solve linear systems for ScalarType other than the four supported by the LAPACK library.
There is a single Teuchos::SerialBandDenseSolver constructor. However, the matrix, right hand side and solution vectors must be set prior to executing most methods in this class.
The matrix A, the left hand side X and the right hand side B (when solving AX = B, for X), can be set by appropriate set methods. Each of these three objects must be a SerialDenseMatrix or a SerialDenseVector object. The set methods are as follows:
The SerialBandDenseMatrix must contain KL extra superdiagonals to store the L and U factors, where KL is the upper bandwidth. Consider using the non-member conversion routines generalToBanded and bandedToGeneral if the full SerialDenseMatrix is already in storage. However, it is more efficient simply to construct the SerialBandDenseMatrix with the desired parameters and use the provided matrix access operators so that the full rectangular matrix need not be stored. The conversion routine generalToBanded has a flag to store the input Teuchos::SerialDenseMatrix in banded format with KL extra superdiagonals so this class can use it. Again, it is more efficient to simply construct a Teuchos::SerialBandDenseMatrix object with KL extra superdiagonals than are needed for the matrix data and fill the matrix using the matrix access operators.
See the documentation of Teuchos::SerialBandDenseMatrix for further details on the storage format.
Once a Teuchos::SerialBandDenseSolver is constructed, several mathematical functions can be applied to the object. Specifically:
In many cases, linear systems can be accurately solved by simply computing the LU 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 this simple approach may not work. In these situations, equilibration and iterative refinement may improve the accuracy, or prevent a breakdown in the factorization.
SerialBandDenseSolver 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.
SerialBandDenseSolver 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 SerialBandDenseSolver can be found in the Teuchos test directories.
Definition at line 166 of file Teuchos_SerialBandDenseSolver.hpp.
| Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::SerialBandDenseSolver | ( | ) |
Default constructor; matrix should be set using setMatrix(), LHS and RHS set with setVectors().
Definition at line 464 of file Teuchos_SerialBandDenseSolver.hpp.
| Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::~SerialBandDenseSolver | ( | ) | [virtual] |
SerialBandDenseSolver destructor.
Definition at line 502 of file Teuchos_SerialBandDenseSolver.hpp.
| int Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::setMatrix | ( | const RCP< SerialBandDenseMatrix< OrdinalType, ScalarType > > & | AB | ) |
Sets the pointer for coefficient matrix.
Definition at line 547 of file Teuchos_SerialBandDenseSolver.hpp.
| int Teuchos::SerialBandDenseSolver< 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 577 of file Teuchos_SerialBandDenseSolver.hpp.
| void Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::factorWithEquilibration | ( | bool | flag | ) | [inline] |
Set whether or not to equilibrate just before the matrix factorization. This function must be called before the factorization is performed.
Definition at line 219 of file Teuchos_SerialBandDenseSolver.hpp.
| void Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::solveWithTranspose | ( | bool | flag | ) | [inline] |
If flag is true, causes all subsequent function calls to work with the transpose of this matrix, otherwise not.
Definition at line 224 of file Teuchos_SerialBandDenseSolver.hpp.
| void Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::solveWithTransposeFlag | ( | Teuchos::ETransp | trans | ) | [inline] |
All subsequent function calls will work with the transpose-type set by this method (Teuchos::NO_TRANS, Teuchos::TRANS, and Teuchos::CONJ_TRANS).
Definition at line 228 of file Teuchos_SerialBandDenseSolver.hpp.
| void Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::solveToRefinedSolution | ( | bool | flag | ) | [inline] |
Set whether or not to use iterative refinement to improve solutions to linear systems.
Definition at line 231 of file Teuchos_SerialBandDenseSolver.hpp.
| void Teuchos::SerialBandDenseSolver< 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 600 of file Teuchos_SerialBandDenseSolver.hpp.
| int Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::factor | ( | ) |
Computes the in-place LU factorization of the matrix using the LAPACK routine _GBTRF.
Definition at line 610 of file Teuchos_SerialBandDenseSolver.hpp.
| int Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::solve | ( | ) |
Computes the solution X to AX = B for the this matrix and the B provided to SetVectors()..
Definition at line 668 of file Teuchos_SerialBandDenseSolver.hpp.
| int Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::computeEquilibrateScaling | ( | ) |
Computes the scaling vector S(i) = 1/sqrt(A(i,i)) of the this matrix.
Definition at line 768 of file Teuchos_SerialBandDenseSolver.hpp.
| int Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::equilibrateMatrix | ( | ) |
Equilibrates the this matrix.
Definition at line 789 of file Teuchos_SerialBandDenseSolver.hpp.
| int Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::equilibrateRHS | ( | ) |
Equilibrates the current RHS.
Definition at line 845 of file Teuchos_SerialBandDenseSolver.hpp.
| int Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::applyRefinement | ( | ) |
Apply Iterative Refinement.
Definition at line 734 of file Teuchos_SerialBandDenseSolver.hpp.
| int Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::unequilibrateLHS | ( | ) |
Unscales the solution vectors if equilibration was used to solve the system.
Definition at line 877 of file Teuchos_SerialBandDenseSolver.hpp.
| int Teuchos::SerialBandDenseSolver< 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 903 of file Teuchos_SerialBandDenseSolver.hpp.
| bool Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::transpose | ( | ) | [inline] |
Returns true if transpose of this matrix has and will be used.
Definition at line 299 of file Teuchos_SerialBandDenseSolver.hpp.
| bool Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::factored | ( | ) | [inline] |
Returns true if matrix is factored (factor available via AF() and LDAF()).
Definition at line 302 of file Teuchos_SerialBandDenseSolver.hpp.
| bool Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::equilibratedA | ( | ) | [inline] |
Returns true if factor is equilibrated (factor available via AF() and LDAF()).
Definition at line 305 of file Teuchos_SerialBandDenseSolver.hpp.
| bool Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::equilibratedB | ( | ) | [inline] |
Returns true if RHS is equilibrated (RHS available via B() and LDB()).
Definition at line 308 of file Teuchos_SerialBandDenseSolver.hpp.
| bool Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::shouldEquilibrate | ( | ) | [inline] |
Returns true if the LAPACK general rules for equilibration suggest you should equilibrate the system.
Definition at line 311 of file Teuchos_SerialBandDenseSolver.hpp.
| bool Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::solutionErrorsEstimated | ( | ) | [inline] |
Returns true if forward and backward error estimated have been computed (available via FERR() and BERR()).
Definition at line 314 of file Teuchos_SerialBandDenseSolver.hpp.
| bool Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::reciprocalConditionEstimated | ( | ) | [inline] |
Returns true if the condition number of the this matrix has been computed (value available via ReciprocalConditionEstimate()).
Definition at line 317 of file Teuchos_SerialBandDenseSolver.hpp.
| bool Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::solved | ( | ) | [inline] |
Returns true if the current set of vectors has been solved.
Definition at line 320 of file Teuchos_SerialBandDenseSolver.hpp.
| bool Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::solutionRefined | ( | ) | [inline] |
Returns true if the current set of vectors has been refined.
Definition at line 323 of file Teuchos_SerialBandDenseSolver.hpp.
| RCP<SerialBandDenseMatrix<OrdinalType, ScalarType> > Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::getMatrix | ( | ) | const [inline] |
Returns pointer to current matrix.
Definition at line 330 of file Teuchos_SerialBandDenseSolver.hpp.
| RCP<SerialBandDenseMatrix<OrdinalType, ScalarType> > Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::getFactoredMatrix | ( | ) | const [inline] |
Returns pointer to factored matrix (assuming factorization has been performed).
Definition at line 333 of file Teuchos_SerialBandDenseSolver.hpp.
| RCP<SerialDenseMatrix<OrdinalType, ScalarType> > Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::getLHS | ( | ) | const [inline] |
Returns pointer to current LHS.
Definition at line 336 of file Teuchos_SerialBandDenseSolver.hpp.
| RCP<SerialDenseMatrix<OrdinalType, ScalarType> > Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::getRHS | ( | ) | const [inline] |
Returns pointer to current RHS.
Definition at line 339 of file Teuchos_SerialBandDenseSolver.hpp.
| OrdinalType Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::numRows | ( | ) | const [inline] |
Returns row dimension of system.
Definition at line 342 of file Teuchos_SerialBandDenseSolver.hpp.
| OrdinalType Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::numCols | ( | ) | const [inline] |
Returns column dimension of system.
Definition at line 345 of file Teuchos_SerialBandDenseSolver.hpp.
| OrdinalType Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::numLower | ( | ) | const [inline] |
Returns lower bandwidth of system.
Definition at line 348 of file Teuchos_SerialBandDenseSolver.hpp.
| OrdinalType Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::numUpper | ( | ) | const [inline] |
Returns upper bandwidth of system.
Definition at line 351 of file Teuchos_SerialBandDenseSolver.hpp.
| std::vector<OrdinalType> Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::IPIV | ( | ) | const [inline] |
Returns pointer to pivot vector (if factorization has been computed), zero otherwise.
Definition at line 354 of file Teuchos_SerialBandDenseSolver.hpp.
| MagnitudeType Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::ANORM | ( | ) | const [inline] |
Returns the 1-Norm of the this matrix (returns -1 if not yet computed).
Definition at line 357 of file Teuchos_SerialBandDenseSolver.hpp.
| MagnitudeType Teuchos::SerialBandDenseSolver< 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 360 of file Teuchos_SerialBandDenseSolver.hpp.
| MagnitudeType Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::ROWCND | ( | ) | const [inline] |
Ratio of smallest to largest row scale factors for the this matrix (returns -1 if not yet computed).
If ROWCND() is >= 0.1 and AMAX() is not close to overflow or underflow, then equilibration is not needed.
Definition at line 365 of file Teuchos_SerialBandDenseSolver.hpp.
| MagnitudeType Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::COLCND | ( | ) | const [inline] |
Ratio of smallest to largest column scale factors for the this matrix (returns -1 if not yet computed).
If COLCND() is >= 0.1 then equilibration is not needed.
Definition at line 370 of file Teuchos_SerialBandDenseSolver.hpp.
| MagnitudeType Teuchos::SerialBandDenseSolver< 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 373 of file Teuchos_SerialBandDenseSolver.hpp.
| std::vector<MagnitudeType> Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::FERR | ( | ) | const [inline] |
Returns a pointer to the forward error estimates computed by LAPACK.
Definition at line 376 of file Teuchos_SerialBandDenseSolver.hpp.
| std::vector<MagnitudeType> Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::BERR | ( | ) | const [inline] |
Returns a pointer to the backward error estimates computed by LAPACK.
Definition at line 379 of file Teuchos_SerialBandDenseSolver.hpp.
| std::vector<MagnitudeType> Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::R | ( | ) | const [inline] |
Returns a pointer to the row scaling vector used for equilibration.
Definition at line 382 of file Teuchos_SerialBandDenseSolver.hpp.
| std::vector<MagnitudeType> Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::C | ( | ) | const [inline] |
Returns a pointer to the column scale vector used for equilibration.
Definition at line 385 of file Teuchos_SerialBandDenseSolver.hpp.
| void Teuchos::SerialBandDenseSolver< OrdinalType, ScalarType >::Print | ( | std::ostream & | os | ) | const |
Print service methods; defines behavior of ostream << operator.
Definition at line 936 of file Teuchos_SerialBandDenseSolver.hpp.
1.7.6.1