![]() |
Eigen
5.0.1-dev+master
|
#include <Eigen/src/IterativeLinearSolvers/MINRES.h>
A minimal residual solver for sparse symmetric problems.
This class allows to solve for A.x = b sparse linear problems using the MINRES algorithm of Paige and Saunders (1975). The sparse matrix A must be symmetric (possibly indefinite). The vectors x and b can be either dense or sparse.
| MatrixType_ | the type of the sparse matrix A, can be a dense or a sparse matrix. |
| UpLo_ | the triangular part that will be used for the computations. It can be Lower, Upper, or Lower|Upper in which the full matrix entries will be considered. Default is Lower. |
| Preconditioner_ | the type of the preconditioner. Default is IdentityPreconditioner |
The maximal number of iterations and tolerance value can be controlled via the setMaxIterations() and setTolerance() methods. The defaults are twice the number of columns of the matrix for the maximal number of iterations and NumTraits<Scalar>::epsilon() for the tolerance, see tolerance().
The tolerance corresponds to the relative residual error: |Ax-b|/|b|. The solver reports Success only when \( \| b - A x \| / \| b \| \), computed from the returned x, meets it, or, with the default tolerance, the confirmable bound \( 8 \sqrt{n}\, \epsilon \), see tolerance().
This class can be used as the direct solver classes. Here is a typical usage example:
By default the iterations start with x=0 as an initial guess of the solution. One can control the start using the solveWithGuess() method.
MINRES can also be used in a matrix-free context, see the following example .
Inheritance diagram for Eigen::MINRES< MatrixType_, UpLo_, Preconditioner_ >:Public Member Functions | |
| MINRES () | |
| template<typename MatrixDerived> | |
| MINRES (const EigenBase< MatrixDerived > &A) | |
| RealScalar | tolerance () const |
Public Member Functions inherited from Eigen::IterativeSolverBase< MINRES< MatrixType_, UpLo_, Preconditioner_ > > | |
| MINRES< MatrixType_, UpLo_, Preconditioner_ > & | analyzePattern (const EigenBase< MatrixDerived > &A) |
| MINRES< MatrixType_, UpLo_, Preconditioner_ > & | compute (const EigenBase< MatrixDerived > &A) |
| RealScalar | error () const |
| MINRES< MatrixType_, UpLo_, Preconditioner_ > & | factorize (const EigenBase< MatrixDerived > &A) |
| ComputationInfo | info () const |
| Index | iterations () const |
| IterativeSolverBase () | |
| IterativeSolverBase (const EigenBase< MatrixDerived > &A) | |
| Index | maxIterations () const |
| Preconditioner & | preconditioner () |
| const Preconditioner & | preconditioner () const |
| MINRES< MatrixType_, UpLo_, Preconditioner_ > & | setMaxIterations (Index maxIters) |
| MINRES< MatrixType_, UpLo_, Preconditioner_ > & | setTolerance (const RealScalar &tolerance) |
| const SolveWithGuess< MINRES< MatrixType_, UpLo_, Preconditioner_ >, Rhs, Guess > | solveWithGuess (const MatrixBase< Rhs > &b, const Guess &x0) const |
| void | solveWithGuessInPlace (const Rhs &b, Dest &x) const |
| RealScalar | tolerance () const |
Public Member Functions inherited from Eigen::SparseSolverBase< MINRES< MatrixType_, UpLo_, Preconditioner_ > > | |
| Solve< MINRES< MatrixType_, UpLo_, Preconditioner_ >, Rhs > | solve (const MatrixBase< Rhs > &b) const |
| Solve< MINRES< MatrixType_, UpLo_, Preconditioner_ >, Rhs > | solve (const SparseMatrixBase< Rhs > &b) const |
| SparseSolverBase ()=default | |
|
inline |
Default constructor.
|
inlineexplicit |
Initialize the solver with matrix A for further Ax=b solving.
This constructor is a shortcut for the default constructor followed by a call to compute().
|
inline |
MINRES reports Success only when \( \| b - A x \| / \| b \| \), computed from the returned x, meets the tolerance. The rounding error of b - A x is of order \( \sqrt{m+1}\, \epsilon\, (|b_i| + (|A| |x|)_i) \) per component for m nonzeros in a row of A (Higham and Mary, A new approach to probabilistic rounding error analysis, SIAM J. Sci. Comput. 41(5), 2019), and the recurrence for x adds to it, so the residual of the computed x stagnates at a level that depends on the matrix and often exceeds \( \epsilon \). With the default tolerance the iteration therefore aims at \( \epsilon \), and whichever way it ends (stagnation of the computed residual, maxIterations(), or an exhausted Krylov space) it reports Success if the computed \( \| b - A x \| / \| b \| \) is at most \( 8 \sqrt{n}\, \epsilon \) for an n x n matrix, the default tolerance of IDRS. A tolerance set by setTolerance() is never relaxed, so a tolerance below what the arithmetic can confirm ends in NoConvergence with the best iterate and its residual in error().
The default is selected by a negative stored tolerance, which no residual can meet, so setTolerance() with a negative value restores the default behavior instead of asking for the impossible.