Ifpack_SerialTriDiSolver: A class for solving TriDi linear problems. More...
#include <Ifpack_SerialTriDiSolver.h>
Public Member Functions | |
Constructor/Destructor Methods | |
Ifpack_SerialTriDiSolver () | |
Default constructor; matrix should be set using SetMatrix(), LHS and RHS set with SetVectors(). | |
virtual | ~Ifpack_SerialTriDiSolver () |
Ifpack_SerialTriDiSolver destructor. | |
Set Methods | |
int | SetMatrix (Ifpack_SerialTriDiMatrix &A) |
Sets the pointers for coefficient matrix. | |
int | SetVectors (Epetra_SerialDenseMatrix &X, Epetra_SerialDenseMatrix &B) |
Sets the pointers for left and right hand side vector(s). More... | |
Strategy modifying Methods | |
void | SolveWithTranspose (bool Flag) |
Causes equilibration to be called just before the matrix factorization as part of the call to Factor. More... | |
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. More... | |
Factor/Solve/Invert Methods | |
virtual int | Factor (void) |
Computes the in-place LU factorization of the matrix using the LAPACK routine DGETRF. More... | |
virtual int | Solve (void) |
Computes the solution X to AX = B for the this matrix and the B provided to SetVectors().. More... | |
virtual int | Invert (void) |
Inverts the this matrix. More... | |
virtual int | ApplyRefinement (void) |
Apply Iterative Refinement. More... | |
virtual int | ReciprocalConditionEstimate (double &Value) |
Unscales the solution vectors if equilibration was used to solve the system. More... | |
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 | 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 | |
Ifpack_SerialTriDiMatrix * | Matrix () const |
Returns pointer to current matrix. | |
Ifpack_SerialTriDiMatrix * | FactoredMatrix () const |
Returns pointer to factored matrix (assuming factorization has been performed). | |
Epetra_SerialDenseMatrix * | LHS () const |
Returns pointer to current LHS. | |
Epetra_SerialDenseMatrix * | RHS () const |
Returns pointer to current RHS. | |
int | N () const |
Returns column dimension of system. | |
double * | A () const |
Returns pointer to the this matrix. | |
int | LDA () const |
Returns the leading dimension of the this matrix. | |
double * | B () const |
Returns pointer to current RHS. | |
int | LDB () const |
Returns the leading dimension of the RHS. | |
int | NRHS () const |
Returns the number of current right hand sides and solution vectors. | |
double * | X () const |
Returns pointer to current solution. | |
int | LDX () const |
Returns the leading dimension of the solution. | |
double * | AF () const |
Returns pointer to the factored matrix (may be the same as A() if factorization done in place). | |
int | LDAF () const |
Returns the leading dimension of the factored matrix. | |
int * | IPIV () const |
Returns pointer to pivot vector (if factorization has been computed), zero otherwise. | |
double | ANORM () const |
Returns the 1-Norm of the this matrix (returns -1 if not yet computed). | |
double | RCOND () const |
Returns the reciprocal of the condition number of the this matrix (returns -1 if not yet computed). | |
double | ROWCND () const |
Ratio of smallest to largest row scale factors for the this matrix (returns -1 if not yet computed). More... | |
double | COLCND () const |
Ratio of smallest to largest column scale factors for the this matrix (returns -1 if not yet computed). More... | |
double | AMAX () const |
Returns the absolute value of the largest entry of the this matrix (returns -1 if not yet computed). | |
double * | FERR () const |
Returns a pointer to the forward error estimates computed by LAPACK. | |
double * | BERR () const |
Returns a pointer to the backward error estimates computed by LAPACK. | |
I/O methods | |
virtual void | Print (std::ostream &os) const |
Print service methods; defines behavior of ostream << operator. | |
Public Member Functions inherited from Epetra_BLAS | |
Epetra_BLAS (const Epetra_BLAS &BLAS) | |
float | ASUM (const int N, const float *X, const int INCX=1) const |
double | ASUM (const int N, const double *X, const int INCX=1) const |
float | DOT (const int N, const float *X, const float *Y, const int INCX=1, const int INCY=1) const |
double | DOT (const int N, const double *X, const double *Y, const int INCX=1, const int INCY=1) const |
float | NRM2 (const int N, const float *X, const int INCX=1) const |
double | NRM2 (const int N, const double *X, const int INCX=1) const |
void | SCAL (const int N, const float ALPHA, float *X, const int INCX=1) const |
void | SCAL (const int N, const double ALPHA, double *X, const int INCX=1) const |
void | COPY (const int N, const float *X, float *Y, const int INCX=1, const int INCY=1) const |
void | COPY (const int N, const double *X, double *Y, const int INCX=1, const int INCY=1) const |
int | IAMAX (const int N, const float *X, const int INCX=1) const |
int | IAMAX (const int N, const double *X, const int INCX=1) const |
void | AXPY (const int N, const float ALPHA, const float *X, float *Y, const int INCX=1, const int INCY=1) const |
void | AXPY (const int N, const double ALPHA, const double *X, double *Y, const int INCX=1, const int INCY=1) const |
void | GEMV (const char TRANS, const int M, const int N, const float ALPHA, const float *A, const int LDA, const float *X, const float BETA, float *Y, const int INCX=1, const int INCY=1) const |
void | GEMV (const char TRANS, const int M, const int N, const double ALPHA, const double *A, const int LDA, const double *X, const double BETA, double *Y, const int INCX=1, const int INCY=1) const |
void | GEMM (const char TRANSA, const char TRANSB, const int M, const int N, const int K, const float ALPHA, const float *A, const int LDA, const float *B, const int LDB, const float BETA, float *C, const int LDC) const |
void | GEMM (const char TRANSA, const char TRANSB, const int M, const int N, const int K, const double ALPHA, const double *A, const int LDA, const double *B, const int LDB, const double BETA, double *C, const int LDC) const |
void | SYMM (const char SIDE, const char UPLO, const int M, const int N, const float ALPHA, const float *A, const int LDA, const float *B, const int LDB, const float BETA, float *C, const int LDC) const |
void | SYMM (const char SIDE, const char UPLO, const int M, const int N, const double ALPHA, const double *A, const int LDA, const double *B, const int LDB, const double BETA, double *C, const int LDC) const |
void | TRMM (const char SIDE, const char UPLO, const char TRANSA, const char DIAG, const int M, const int N, const float ALPHA, const float *A, const int LDA, float *B, const int LDB) const |
void | TRMM (const char SIDE, const char UPLO, const char TRANSA, const char DIAG, const int M, const int N, const double ALPHA, const double *A, const int LDA, double *B, const int LDB) const |
void | SYRK (const char UPLO, const char TRANS, const int N, const int K, const float ALPHA, const float *A, const int LDA, const float BETA, float *C, const int LDC) const |
void | SYRK (const char UPLO, const char TRANS, const int N, const int K, const double ALPHA, const double *A, const int LDA, const double BETA, double *C, const int LDC) const |
Protected Member Functions | |
void | AllocateWORK () |
void | AllocateIWORK () |
void | InitPointers () |
void | DeleteArrays () |
void | ResetMatrix () |
void | ResetVectors () |
Protected Attributes | |
bool | Transpose_ |
bool | Factored_ |
bool | EstimateSolutionErrors_ |
bool | SolutionErrorsEstimated_ |
bool | Solved_ |
bool | Inverted_ |
bool | ReciprocalConditionEstimated_ |
bool | RefineSolution_ |
bool | SolutionRefined_ |
char | TRANS_ |
int | N_ |
int | Min_MN_ |
int | NRHS_ |
int | LDA_ |
int | LDAF_ |
int | LDB_ |
int | LDX_ |
int | INFO_ |
int | LWORK_ |
int * | IPIV_ |
int * | IWORK_ |
double | ANORM_ |
double | RCOND_ |
double | ROWCND_ |
double | COLCND_ |
double | AMAX_ |
Ifpack_SerialTriDiMatrix * | Matrix_ |
Epetra_SerialDenseMatrix * | LHS_ |
Epetra_SerialDenseMatrix * | RHS_ |
Ifpack_SerialTriDiMatrix * | Factor_ |
double * | A_ |
double * | FERR_ |
double * | BERR_ |
double * | AF_ |
double * | WORK_ |
double * | B_ |
double * | X_ |
Ifpack_SerialTriDiSolver: A class for solving TriDi linear problems.
The Ifpack_SerialTriDiSolver class enables the definition, in terms of Ifpack_SerialTriDiMatrix and Ifpack_SerialTriDiVector objects, of a TriDi linear problem, followed by the solution of that problem via the most sophisticated techniques available in LAPACK.
The Ifpack_SerialTriDiSolver class is intended to provide full-featured support for solving linear problems for general TriDi rectangular (or square) 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.
Ifpack_SerialTriDiSolver vs. Epetra_LAPACK
The Epetra_LAPACK class provides access to most of the same functionality as Ifpack_SerialTriDiSolver. The primary difference is that Epetra_LAPACK is a "thin" layer on top of LAPACK and Ifpack_SerialTriDiSolver attempts to provide easy access to the more sophisticated aspects of solving TriDi linear and eigensystems.
When you should use Ifpack_SerialTriDiSolver: If you want to (or potentially want to) solve ill-conditioned problems or want to work with a more object-oriented interface, you should probably use Ifpack_SerialTriDiSolver.
Constructing Ifpack_SerialTriDiSolver Objects
There is a single Ifpack_SerialTriDiSolver constructor. However, the matrix, right hand side and solution vectors must be set prior to executing most methods in this class.
Setting vectors used for linear solves
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 an Ifpack_SerialTriDiMatrix or and Epetra_SerialDenseVector object. The set methods are as follows:
Vector and Utility Functions
Once a Ifpack_SerialTriDiSolver is constructed, several mathematical functions can be applied to the object. Specifically:
Counting floating point operations The Ifpack_SerialTriDiSolver class has Epetra_CompObject as a base class. Thus, floating point operations are counted and accumulated in the Epetra_Flop object (if any) that was set using the SetFlopCounter() method in the Epetra_CompObject base class.
Strategies for Solving Linear Systems 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.
LAPACK does not provide an equilibration functionality for tridiagonal data structures.
Ifpack_SerialTriDiSolver 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 Ifpack_SerialTriDiSolver can be found in the Epetra test directories.
Definition at line 130 of file Ifpack_SerialTriDiSolver.h.
|
virtual |
Apply Iterative Refinement.
Definition at line 295 of file Ifpack_SerialTriDiSolver.cpp.
Referenced by Solve().
|
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 310 of file Ifpack_SerialTriDiSolver.h.
void Ifpack_SerialTriDiSolver::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 192 of file Ifpack_SerialTriDiSolver.cpp.
|
virtual |
Computes the in-place LU factorization of the matrix using the LAPACK routine DGETRF.
Definition at line 199 of file Ifpack_SerialTriDiSolver.cpp.
References Ifpack_SerialTriDiMatrix::A(), Ifpack_SerialTriDiMatrix::DL(), Factored(), Inverted(), and Ifpack_SerialTriDiMatrix::OneNorm().
Referenced by Ifpack_TriDiContainer::Compute(), Invert(), ReciprocalConditionEstimate(), and Solve().
|
virtual |
Inverts the this matrix.
Definition at line 303 of file Ifpack_SerialTriDiSolver.cpp.
References Factor(), and Factored().
|
virtual |
Unscales the solution vectors if equilibration was used to solve the system.
Value | Out On return contains the reciprocal of the 1-norm condition number of the this matrix. |
Definition at line 322 of file Ifpack_SerialTriDiSolver.cpp.
References Factor(), Factored(), Ifpack_SerialTriDiMatrix::OneNorm(), and ReciprocalConditionEstimated().
|
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 305 of file Ifpack_SerialTriDiSolver.h.
int Ifpack_SerialTriDiSolver::SetVectors | ( | Epetra_SerialDenseMatrix & | X, |
Epetra_SerialDenseMatrix & | 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 176 of file Ifpack_SerialTriDiSolver.cpp.
References Epetra_SerialDenseMatrix::A(), and Epetra_SerialDenseMatrix::N().
Referenced by Ifpack_TriDiContainer::Initialize(), and Ifpack_TriDiContainer::SetNumVectors().
|
virtual |
Computes the solution X to AX = B for the this matrix and the B provided to SetVectors()..
Definition at line 237 of file Ifpack_SerialTriDiSolver.cpp.
References Epetra_SerialDenseMatrix::A(), ApplyRefinement(), Ifpack_SerialTriDiMatrix::DL(), Factor(), Factored(), and Inverted().
Referenced by Ifpack_TriDiContainer::ApplyInverse().
|
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.If Flag is true, causes all subsequent function calls to work with the transpose of this matrix, otherwise not.
Definition at line 168 of file Ifpack_SerialTriDiSolver.h.