Eigen::MINRES< MatrixType_, UpLo_, Preconditioner_ > Class Template Reference

A minimal residual solver for sparse symmetric problems. More...

+ Inheritance diagram for Eigen::MINRES< MatrixType_, UpLo_, Preconditioner_ >:

Public Types

enum  { UpLo }
 
typedef MatrixType_ MatrixType
 
typedef Preconditioner_ Preconditioner
 
typedef MatrixType::RealScalar RealScalar
 
typedef MatrixType::Scalar Scalar
 
- Public Types inherited from Eigen::IterativeSolverBase< MINRES< MatrixType_, UpLo_, Preconditioner_ > >
typedef internal::traits< Derived >::MatrixType MatrixType
 
typedef internal::traits< Derived >::Preconditioner Preconditioner
 
typedef MatrixType::RealScalar RealScalar
 
typedef MatrixType::Scalar Scalar
 
typedef MatrixType::StorageIndex StorageIndex
 

Public Member Functions

void _solve_impl (const Rhs &b, Dest &x) const
 
template<typename Rhs , typename Dest >
void _solve_vector_with_guess_impl (const Rhs &b, Dest &x) const
 
 MINRES ()
 
template<typename MatrixDerived >
 MINRES (const EigenBase< MatrixDerived > &A)
 
 ~MINRES ()
 
- Public Member Functions inherited from Eigen::IterativeSolverBase< MINRES< MatrixType_, UpLo_, Preconditioner_ > >
void _solve_impl (const Rhs &b, Dest &x) const
 
std::enable_if_t< Rhs::ColsAtCompileTime!=1 &&DestDerived::ColsAtCompileTime!=1 > _solve_with_guess_impl (const Rhs &b, MatrixBase< DestDerived > &aDest) const
 
std::enable_if_t< Rhs::ColsAtCompileTime==1||DestDerived::ColsAtCompileTime==1 > _solve_with_guess_impl (const Rhs &b, MatrixBase< DestDerived > &dest) const
 
void _solve_with_guess_impl (const Rhs &b, SparseMatrixBase< DestDerived > &aDest) const
 
Derived & analyzePattern (const EigenBase< MatrixDerived > &A)
 
EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
Derived & compute (const EigenBase< MatrixDerived > &A)
 
Derived & derived ()
 
const Derived & derived () const
 
RealScalar error () const
 
Derived & factorize (const EigenBase< MatrixDerived > &A)
 
ComputationInfo info () const
 
Index iterations () const
 
 IterativeSolverBase ()
 
 IterativeSolverBase (const EigenBase< MatrixDerived > &A)
 
 IterativeSolverBase (IterativeSolverBase &&)=default
 
Index maxIterations () const
 
Preconditionerpreconditioner ()
 
const Preconditionerpreconditioner () const
 
EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
Derived & setMaxIterations (Index maxIters)
 
Derived & setTolerance (const RealScalar &tolerance)
 
const SolveWithGuess< Derived, Rhs, Guess > solveWithGuess (const MatrixBase< Rhs > &b, const Guess &x0) const
 
RealScalar tolerance () const
 
 ~IterativeSolverBase ()
 
- Public Member Functions inherited from Eigen::SparseSolverBase< class >
Derived & derived ()
 
const Derived & derived () const
 
const Solve< Derived, Rhs > solve (const MatrixBase< Rhs > &b) const
 
const Solve< Derived, Rhs > solve (const SparseMatrixBase< Rhs > &b) const
 
 SparseSolverBase ()
 
 SparseSolverBase (SparseSolverBase &&other)
 
 ~SparseSolverBase ()
 

Private Types

typedef IterativeSolverBase< MINRESBase
 

Private Member Functions

const ActualMatrixTypematrix () const
 

Private Attributes

RealScalar m_error
 
ComputationInfo m_info
 
bool m_isInitialized
 
Index m_iterations
 

Additional Inherited Members

- Public Attributes inherited from Eigen::IterativeSolverBase< MINRES< MatrixType_, UpLo_, Preconditioner_ > >
 ColsAtCompileTime
 
 MaxColsAtCompileTime
 
- Protected Types inherited from Eigen::IterativeSolverBase< MINRES< MatrixType_, UpLo_, Preconditioner_ > >
typedef MatrixWrapper::ActualMatrixType ActualMatrixType
 
typedef SparseSolverBase< Derived > Base
 
typedef internal::generic_matrix_wrapper< MatrixTypeMatrixWrapper
 
- Protected Member Functions inherited from Eigen::IterativeSolverBase< MINRES< MatrixType_, UpLo_, Preconditioner_ > >
void grab (const InputType &A)
 
void init ()
 
const ActualMatrixTypematrix () const
 
- Protected Attributes inherited from Eigen::IterativeSolverBase< MINRES< MatrixType_, UpLo_, Preconditioner_ > >
bool m_analysisIsOk
 
RealScalar m_error
 
bool m_factorizationIsOk
 
ComputationInfo m_info
 
bool m_isInitialized
 
Index m_iterations
 
MatrixWrapper m_matrixWrapper
 
Index m_maxIterations
 
Preconditioner m_preconditioner
 
RealScalar m_tolerance
 
- Protected Attributes inherited from Eigen::SparseSolverBase< class >
bool m_isInitialized
 

Detailed Description

template<typename MatrixType_, int UpLo_, typename Preconditioner_>
class Eigen::MINRES< MatrixType_, UpLo_, Preconditioner_ >

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.

Template Parameters
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 DiagonalPreconditioner

The maximal number of iterations and tolerance value can be controlled via the setMaxIterations() and setTolerance() methods. The defaults are the size of the problem for the maximal number of iterations and NumTraits<Scalar>::epsilon() for the tolerance.

This class can be used as the direct solver classes. Here is a typical usage example:

int n = 10000;
VectorXd x(n), b(n);
// fill A and b
MINRES<SparseMatrix<double> > mr;
mr.compute(A);
x = mr.solve(b);
std::cout << "#iterations: " << mr.iterations() << std::endl;
std::cout << "estimated error: " << mr.error() << std::endl;
// update b, and solve again
x = mr.solve(b);
int n
SparseMatrix< double > A(n, n)
Matrix< double, Dynamic, 1 > VectorXd

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 .

See also
class ConjugateGradient, BiCGSTAB, SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner

Definition at line 197 of file MINRES.h.

Member Typedef Documentation

◆ Base

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
typedef IterativeSolverBase<MINRES> Eigen::MINRES< MatrixType_, UpLo_, Preconditioner_ >::Base
private

Definition at line 200 of file MINRES.h.

◆ MatrixType

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
typedef MatrixType_ Eigen::MINRES< MatrixType_, UpLo_, Preconditioner_ >::MatrixType

Definition at line 208 of file MINRES.h.

◆ Preconditioner

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
typedef Preconditioner_ Eigen::MINRES< MatrixType_, UpLo_, Preconditioner_ >::Preconditioner

Definition at line 211 of file MINRES.h.

◆ RealScalar

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
typedef MatrixType::RealScalar Eigen::MINRES< MatrixType_, UpLo_, Preconditioner_ >::RealScalar

Definition at line 210 of file MINRES.h.

◆ Scalar

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
typedef MatrixType::Scalar Eigen::MINRES< MatrixType_, UpLo_, Preconditioner_ >::Scalar

Definition at line 209 of file MINRES.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
anonymous enum
Enumerator
UpLo 

Definition at line 213 of file MINRES.h.

213 {UpLo = UpLo_};

Constructor & Destructor Documentation

◆ MINRES() [1/2]

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
Eigen::MINRES< MatrixType_, UpLo_, Preconditioner_ >::MINRES ( )
inline

Default constructor.

Definition at line 218 of file MINRES.h.

218 : Base() {}
IterativeSolverBase< MINRES > Base
Definition: MINRES.h:200

◆ MINRES() [2/2]

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
template<typename MatrixDerived >
Eigen::MINRES< MatrixType_, UpLo_, Preconditioner_ >::MINRES ( const EigenBase< MatrixDerived > &  A)
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().

Warning
this class stores a reference to the matrix A as well as some precomputed values that depend on it. Therefore, if A is changed this class becomes invalid. Call compute() to update it with the new matrix A, or modify a copy of A.

Definition at line 231 of file MINRES.h.

231 : Base(A.derived()) {}
SparseMatrix< double, Options_, StorageIndex_ > & derived()

◆ ~MINRES()

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
Eigen::MINRES< MatrixType_, UpLo_, Preconditioner_ >::~MINRES ( )
inline

Destructor.

Definition at line 234 of file MINRES.h.

234 {}

Member Function Documentation

◆ _solve_impl()

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
void Eigen::IterativeSolverBase< class >::_solve_impl

◆ _solve_vector_with_guess_impl()

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
template<typename Rhs , typename Dest >
void Eigen::MINRES< MatrixType_, UpLo_, Preconditioner_ >::_solve_vector_with_guess_impl ( const Rhs &  b,
Dest &  x 
) const
inline

Definition at line 238 of file MINRES.h.

239  {
240  typedef typename Base::MatrixWrapper MatrixWrapper;
241  typedef typename Base::ActualMatrixType ActualMatrixType;
242  enum {
243  TransposeInput = (!MatrixWrapper::MatrixFree)
244  && (UpLo==(Lower|Upper))
245  && (!MatrixType::IsRowMajor)
247  };
248  typedef std::conditional_t<TransposeInput,Transpose<const ActualMatrixType>, ActualMatrixType const&> RowMajorWrapper;
249  EIGEN_STATIC_ASSERT(internal::check_implication(MatrixWrapper::MatrixFree, UpLo==(Lower|Upper)),MATRIX_FREE_CONJUGATE_GRADIENT_IS_COMPATIBLE_WITH_UPPER_UNION_LOWER_MODE_ONLY);
250  typedef std::conditional_t<UpLo==(Lower|Upper),
251  RowMajorWrapper,
252  typename MatrixWrapper::template ConstSelfAdjointViewReturnType<UpLo>::Type
253  > SelfAdjointWrapper;
254 
257  RowMajorWrapper row_mat(matrix());
258  internal::minres(SelfAdjointWrapper(row_mat), b, x,
261  }
#define EIGEN_STATIC_ASSERT(X, MSG)
internal::generic_matrix_wrapper< MatrixType > MatrixWrapper
MatrixWrapper::ActualMatrixType ActualMatrixType
Preconditioner m_preconditioner
RealScalar m_error
const ActualMatrixType & matrix() const
ComputationInfo m_info
Index m_iterations
constexpr bool check_implication(bool a, bool b)
EIGEN_DONT_INLINE void minres(const MatrixType &mat, const Rhs &rhs, Dest &x, const Preconditioner &precond, Index &iters, typename Dest::RealScalar &tol_error)
Definition: MINRES.h:34

◆ matrix()

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
const ActualMatrixType & Eigen::IterativeSolverBase< class >::matrix
private

Member Data Documentation

◆ m_error

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
RealScalar Eigen::IterativeSolverBase< class >::m_error
private

◆ m_info

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
ComputationInfo Eigen::IterativeSolverBase< class >::m_info
private

◆ m_isInitialized

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
bool Eigen::IterativeSolverBase< class >::m_isInitialized
private

◆ m_iterations

template<typename MatrixType_ , int UpLo_, typename Preconditioner_ >
Index Eigen::IterativeSolverBase< class >::m_iterations
private

The documentation for this class was generated from the following file: