Shapeworks Studio  2.1
Shape analysis software suite
List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
Eigen::IterativeSolverBase< Derived > Class Template Reference

Base class for linear iterative solvers. More...

#include <IterativeSolverBase.h>

+ Inheritance diagram for Eigen::IterativeSolverBase< Derived >:
+ Collaboration diagram for Eigen::IterativeSolverBase< Derived >:

Public Types

typedef internal::traits< Derived >::MatrixType MatrixType
 
typedef internal::traits< Derived >::Preconditioner Preconditioner
 
typedef MatrixType::Scalar Scalar
 
typedef MatrixType::Index Index
 
typedef MatrixType::RealScalar RealScalar
 

Public Member Functions

Derived & derived ()
 
const Derived & derived () const
 
 IterativeSolverBase ()
 
 IterativeSolverBase (const MatrixType &A)
 
Derived & analyzePattern (const MatrixType &A)
 
Derived & factorize (const MatrixType &A)
 
Derived & compute (const MatrixType &A)
 
Index rows () const
 
Index cols () const
 
RealScalar tolerance () const
 
Derived & setTolerance (const RealScalar &tolerance)
 
Preconditioner & preconditioner ()
 
const Preconditioner & preconditioner () const
 
int maxIterations () const
 
Derived & setMaxIterations (int maxIters)
 
int iterations () const
 
RealScalar error () const
 
template<typename Rhs >
const internal::solve_retval< Derived, Rhs > solve (const MatrixBase< Rhs > &b) const
 
template<typename Rhs >
const internal::sparse_solve_retval< IterativeSolverBase, Rhs > solve (const SparseMatrixBase< Rhs > &b) const
 
ComputationInfo info () const
 
template<typename Rhs , typename DestScalar , int DestOptions, typename DestIndex >
void _solve_sparse (const Rhs &b, SparseMatrix< DestScalar, DestOptions, DestIndex > &dest) const
 

Protected Member Functions

void init ()
 

Protected Attributes

const MatrixType * mp_matrix
 
Preconditioner m_preconditioner
 
int m_maxIterations
 
RealScalar m_tolerance
 
RealScalar m_error
 
int m_iterations
 
ComputationInfo m_info
 
bool m_isInitialized
 
bool m_analysisIsOk
 
bool m_factorizationIsOk
 

Detailed Description

template<typename Derived>
class Eigen::IterativeSolverBase< Derived >

Base class for linear iterative solvers.

See also
class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner

Definition at line 21 of file IterativeSolverBase.h.

Constructor & Destructor Documentation

template<typename Derived>
Eigen::IterativeSolverBase< Derived >::IterativeSolverBase ( )
inline

Default constructor.

Definition at line 36 of file IterativeSolverBase.h.

37  : mp_matrix(0)
38  {
39  init();
40  }
template<typename Derived>
Eigen::IterativeSolverBase< Derived >::IterativeSolverBase ( const MatrixType &  A)
inline

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 52 of file IterativeSolverBase.h.

53  {
54  init();
55  compute(A);
56  }
Derived & compute(const MatrixType &A)

Member Function Documentation

template<typename Derived>
Derived& Eigen::IterativeSolverBase< Derived >::analyzePattern ( const MatrixType &  A)
inline

Initializes the iterative solver for the sparcity pattern of the matrix A for further solving Ax=b problems.

Currently, this function mostly call analyzePattern on the preconditioner. In the future we might, for instance, implement column reodering for faster matrix vector products.

Definition at line 65 of file IterativeSolverBase.h.

66  {
67  m_preconditioner.analyzePattern(A);
68  m_isInitialized = true;
69  m_analysisIsOk = true;
70  m_info = Success;
71  return derived();
72  }
template<typename Derived>
Derived& Eigen::IterativeSolverBase< Derived >::compute ( const MatrixType &  A)
inline

Initializes the iterative solver with the matrix A for further solving Ax=b problems.

Currently, this function mostly initialized/compute the preconditioner. In the future we might, for instance, implement column reodering for faster matrix vector products.

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 103 of file IterativeSolverBase.h.

104  {
105  mp_matrix = &A;
106  m_preconditioner.compute(A);
107  m_isInitialized = true;
108  m_analysisIsOk = true;
109  m_factorizationIsOk = true;
110  m_info = Success;
111  return derived();
112  }
template<typename Derived>
RealScalar Eigen::IterativeSolverBase< Derived >::error ( ) const
inline
Returns
the tolerance error reached during the last solve

Definition at line 156 of file IterativeSolverBase.h.

157  {
158  eigen_assert(m_isInitialized && "ConjugateGradient is not initialized.");
159  return m_error;
160  }
template<typename Derived>
Derived& Eigen::IterativeSolverBase< Derived >::factorize ( const MatrixType &  A)
inline

Initializes the iterative solver with the numerical values of the matrix A for further solving Ax=b problems.

Currently, this function mostly call factorize on the preconditioner.

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 83 of file IterativeSolverBase.h.

84  {
85  eigen_assert(m_analysisIsOk && "You must first call analyzePattern()");
86  mp_matrix = &A;
87  m_preconditioner.factorize(A);
88  m_factorizationIsOk = true;
89  m_info = Success;
90  return derived();
91  }
template<typename Derived>
ComputationInfo Eigen::IterativeSolverBase< Derived >::info ( ) const
inline
Returns
Success if the iterations converged, and NoConvergence otherwise.

Definition at line 190 of file IterativeSolverBase.h.

191  {
192  eigen_assert(m_isInitialized && "IterativeSolverBase is not initialized.");
193  return m_info;
194  }
template<typename Derived>
int Eigen::IterativeSolverBase< Derived >::iterations ( ) const
inline
Returns
the number of iterations performed during the last solve

Definition at line 149 of file IterativeSolverBase.h.

150  {
151  eigen_assert(m_isInitialized && "ConjugateGradient is not initialized.");
152  return m_iterations;
153  }
template<typename Derived>
int Eigen::IterativeSolverBase< Derived >::maxIterations ( ) const
inline
Returns
the max number of iterations

Definition at line 136 of file IterativeSolverBase.h.

137  {
138  return (mp_matrix && m_maxIterations<0) ? mp_matrix->cols() : m_maxIterations;
139  }
template<typename Derived>
Preconditioner& Eigen::IterativeSolverBase< Derived >::preconditioner ( )
inline
Returns
a read-write reference to the preconditioner for custom configuration.

Definition at line 130 of file IterativeSolverBase.h.

130 { return m_preconditioner; }
template<typename Derived>
const Preconditioner& Eigen::IterativeSolverBase< Derived >::preconditioner ( ) const
inline
Returns
a read-only reference to the preconditioner.

Definition at line 133 of file IterativeSolverBase.h.

133 { return m_preconditioner; }
template<typename Derived>
Derived& Eigen::IterativeSolverBase< Derived >::setMaxIterations ( int  maxIters)
inline

Sets the max number of iterations

Definition at line 142 of file IterativeSolverBase.h.

143  {
144  m_maxIterations = maxIters;
145  return derived();
146  }
template<typename Derived>
Derived& Eigen::IterativeSolverBase< Derived >::setTolerance ( const RealScalar &  tolerance)
inline

Sets the tolerance threshold used by the stopping criteria

Definition at line 123 of file IterativeSolverBase.h.

124  {
125  m_tolerance = tolerance;
126  return derived();
127  }
template<typename Derived>
template<typename Rhs >
const internal::solve_retval<Derived, Rhs> Eigen::IterativeSolverBase< Derived >::solve ( const MatrixBase< Rhs > &  b) const
inline
Returns
the solution x of $ A x = b $ using the current decomposition of A.
See also
compute()

Definition at line 167 of file IterativeSolverBase.h.

168  {
169  eigen_assert(m_isInitialized && "IterativeSolverBase is not initialized.");
170  eigen_assert(rows()==b.rows()
171  && "IterativeSolverBase::solve(): invalid number of rows of the right hand side matrix b");
172  return internal::solve_retval<Derived, Rhs>(derived(), b.derived());
173  }
template<typename Derived>
template<typename Rhs >
const internal::sparse_solve_retval<IterativeSolverBase, Rhs> Eigen::IterativeSolverBase< Derived >::solve ( const SparseMatrixBase< Rhs > &  b) const
inline
Returns
the solution x of $ A x = b $ using the current decomposition of A.
See also
compute()

Definition at line 181 of file IterativeSolverBase.h.

182  {
183  eigen_assert(m_isInitialized && "IterativeSolverBase is not initialized.");
184  eigen_assert(rows()==b.rows()
185  && "IterativeSolverBase::solve(): invalid number of rows of the right hand side matrix b");
186  return internal::sparse_solve_retval<IterativeSolverBase, Rhs>(*this, b.derived());
187  }
template<typename Derived>
RealScalar Eigen::IterativeSolverBase< Derived >::tolerance ( ) const
inline
Returns
the tolerance threshold used by the stopping criteria

Definition at line 120 of file IterativeSolverBase.h.

120 { return m_tolerance; }

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