MOAB
4.9.3pre
|
Base class for linear iterative solvers. More...
#include <IterativeSolverBase.h>
Public Types | |
enum | { ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime } |
typedef internal::traits < Derived >::MatrixType | MatrixType |
typedef internal::traits < Derived >::Preconditioner | Preconditioner |
typedef MatrixType::Scalar | Scalar |
typedef MatrixType::StorageIndex | StorageIndex |
typedef MatrixType::RealScalar | RealScalar |
Public Member Functions | |
IterativeSolverBase () | |
template<typename MatrixDerived > | |
IterativeSolverBase (const EigenBase< MatrixDerived > &A) | |
~IterativeSolverBase () | |
template<typename MatrixDerived > | |
Derived & | analyzePattern (const EigenBase< MatrixDerived > &A) |
template<typename MatrixDerived > | |
Derived & | factorize (const EigenBase< MatrixDerived > &A) |
template<typename MatrixDerived > | |
Derived & | compute (const EigenBase< MatrixDerived > &A) |
Index | rows () const |
Index | cols () const |
RealScalar | tolerance () const |
Derived & | setTolerance (const RealScalar &tolerance) |
Preconditioner & | preconditioner () |
const Preconditioner & | preconditioner () const |
Index | maxIterations () const |
Derived & | setMaxIterations (Index maxIters) |
Index | iterations () const |
RealScalar | error () const |
template<typename Rhs , typename Guess > | |
const SolveWithGuess< Derived, Rhs, Guess > | solveWithGuess (const MatrixBase< Rhs > &b, const Guess &x0) const |
ComputationInfo | info () const |
template<typename Rhs , typename DestScalar , int DestOptions, typename DestIndex > | |
void | _solve_impl (const Rhs &b, SparseMatrix< DestScalar, DestOptions, DestIndex > &dest) const |
Protected Types | |
typedef SparseSolverBase< Derived > | Base |
typedef internal::generic_matrix_wrapper < MatrixType > | MatrixWrapper |
typedef MatrixWrapper::ActualMatrixType | ActualMatrixType |
Protected Member Functions | |
void | init () |
const ActualMatrixType & | matrix () const |
template<typename InputType > | |
void | grab (const InputType &A) |
Protected Attributes | |
MatrixWrapper | m_matrixWrapper |
Preconditioner | m_preconditioner |
Index | m_maxIterations |
RealScalar | m_tolerance |
RealScalar | m_error |
Index | m_iterations |
ComputationInfo | m_info |
bool | m_analysisIsOk |
bool | m_factorizationIsOk |
Base class for linear iterative solvers.
Definition at line 143 of file IterativeSolverBase.h.
typedef MatrixWrapper::ActualMatrixType Eigen::IterativeSolverBase< Derived >::ActualMatrixType [protected] |
Definition at line 365 of file IterativeSolverBase.h.
typedef SparseSolverBase<Derived> Eigen::IterativeSolverBase< Derived >::Base [protected] |
Reimplemented in Eigen::BiCGSTAB< _MatrixType, _Preconditioner >, Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >, and Eigen::LeastSquaresConjugateGradient< _MatrixType, _Preconditioner >.
Definition at line 146 of file IterativeSolverBase.h.
typedef internal::traits<Derived>::MatrixType Eigen::IterativeSolverBase< Derived >::MatrixType |
Reimplemented in Eigen::BiCGSTAB< _MatrixType, _Preconditioner >, Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >, and Eigen::LeastSquaresConjugateGradient< _MatrixType, _Preconditioner >.
Definition at line 150 of file IterativeSolverBase.h.
typedef internal::generic_matrix_wrapper<MatrixType> Eigen::IterativeSolverBase< Derived >::MatrixWrapper [protected] |
Definition at line 364 of file IterativeSolverBase.h.
typedef internal::traits<Derived>::Preconditioner Eigen::IterativeSolverBase< Derived >::Preconditioner |
Reimplemented in Eigen::BiCGSTAB< _MatrixType, _Preconditioner >, Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >, and Eigen::LeastSquaresConjugateGradient< _MatrixType, _Preconditioner >.
Definition at line 151 of file IterativeSolverBase.h.
typedef MatrixType::RealScalar Eigen::IterativeSolverBase< Derived >::RealScalar |
Reimplemented in Eigen::BiCGSTAB< _MatrixType, _Preconditioner >, Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >, and Eigen::LeastSquaresConjugateGradient< _MatrixType, _Preconditioner >.
Definition at line 154 of file IterativeSolverBase.h.
typedef MatrixType::Scalar Eigen::IterativeSolverBase< Derived >::Scalar |
Reimplemented in Eigen::BiCGSTAB< _MatrixType, _Preconditioner >, Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >, and Eigen::LeastSquaresConjugateGradient< _MatrixType, _Preconditioner >.
Definition at line 152 of file IterativeSolverBase.h.
typedef MatrixType::StorageIndex Eigen::IterativeSolverBase< Derived >::StorageIndex |
Definition at line 153 of file IterativeSolverBase.h.
anonymous enum |
Definition at line 156 of file IterativeSolverBase.h.
{ ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime };
Eigen::IterativeSolverBase< Derived >::IterativeSolverBase | ( | ) | [inline] |
Eigen::IterativeSolverBase< Derived >::IterativeSolverBase | ( | const EigenBase< MatrixDerived > & | A | ) | [inline, explicit] |
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().
Definition at line 182 of file IterativeSolverBase.h.
: m_matrixWrapper(A.derived()) { init(); compute(matrix()); }
Eigen::IterativeSolverBase< Derived >::~IterativeSolverBase | ( | ) | [inline] |
Definition at line 189 of file IterativeSolverBase.h.
{}
void Eigen::IterativeSolverBase< Derived >::_solve_impl | ( | const Rhs & | b, |
SparseMatrix< DestScalar, DestOptions, DestIndex > & | dest | ||
) | const [inline] |
Definition at line 334 of file IterativeSolverBase.h.
{ eigen_assert(rows()==b.rows()); Index rhsCols = b.cols(); Index size = b.rows(); Eigen::Matrix<DestScalar,Dynamic,1> tb(size); Eigen::Matrix<DestScalar,Dynamic,1> tx(cols()); // We do not directly fill dest because sparse expressions have to be free of aliasing issue. // For non square least-square problems, b and dest might not have the same size whereas they might alias each-other. SparseMatrix<DestScalar,DestOptions,DestIndex> tmp(cols(),rhsCols); for(Index k=0; k<rhsCols; ++k) { tb = b.col(k); tx = derived().solve(tb); tmp.col(k) = tx.sparseView(0); } tmp.swap(dest); }
Derived& Eigen::IterativeSolverBase< Derived >::analyzePattern | ( | const EigenBase< MatrixDerived > & | A | ) | [inline] |
Initializes the iterative solver for the sparsity pattern of the matrix A for further solving Ax=b
problems.
Currently, this function mostly calls analyzePattern on the preconditioner. In the future we might, for instance, implement column reordering for faster matrix vector products.
Definition at line 197 of file IterativeSolverBase.h.
{ grab(A.derived()); m_preconditioner.analyzePattern(matrix()); m_isInitialized = true; m_analysisIsOk = true; m_info = m_preconditioner.info(); return derived(); }
Index Eigen::IterativeSolverBase< Derived >::cols | ( | void | ) | const [inline] |
Definition at line 253 of file IterativeSolverBase.h.
{ return matrix().cols(); }
Derived& Eigen::IterativeSolverBase< Derived >::compute | ( | const EigenBase< MatrixDerived > & | A | ) | [inline] |
Initializes the iterative solver with the matrix A for further solving Ax=b
problems.
Currently, this function mostly initializes/computes the preconditioner. In the future we might, for instance, implement column reordering for faster matrix vector products.
Definition at line 238 of file IterativeSolverBase.h.
{ grab(A.derived()); m_preconditioner.compute(matrix()); m_isInitialized = true; m_analysisIsOk = true; m_factorizationIsOk = true; m_info = m_preconditioner.info(); return derived(); }
RealScalar Eigen::IterativeSolverBase< Derived >::error | ( | ) | const [inline] |
Definition at line 305 of file IterativeSolverBase.h.
{ eigen_assert(m_isInitialized && "ConjugateGradient is not initialized."); return m_error; }
Derived& Eigen::IterativeSolverBase< Derived >::factorize | ( | const EigenBase< MatrixDerived > & | A | ) | [inline] |
Initializes the iterative solver with the numerical values of the matrix A for further solving Ax=b
problems.
Currently, this function mostly calls factorize on the preconditioner.
Definition at line 217 of file IterativeSolverBase.h.
{ eigen_assert(m_analysisIsOk && "You must first call analyzePattern()"); grab(A.derived()); m_preconditioner.factorize(matrix()); m_factorizationIsOk = true; m_info = m_preconditioner.info(); return derived(); }
void Eigen::IterativeSolverBase< Derived >::grab | ( | const InputType & | A | ) | [inline, protected] |
Definition at line 373 of file IterativeSolverBase.h.
{ m_matrixWrapper.grab(A); }
ComputationInfo Eigen::IterativeSolverBase< Derived >::info | ( | ) | const [inline] |
Definition at line 326 of file IterativeSolverBase.h.
{ eigen_assert(m_isInitialized && "IterativeSolverBase is not initialized."); return m_info; }
void Eigen::IterativeSolverBase< Derived >::init | ( | ) | [inline, protected] |
Definition at line 355 of file IterativeSolverBase.h.
{ m_isInitialized = false; m_analysisIsOk = false; m_factorizationIsOk = false; m_maxIterations = -1; m_tolerance = NumTraits<Scalar>::epsilon(); }
Index Eigen::IterativeSolverBase< Derived >::iterations | ( | ) | const [inline] |
Definition at line 296 of file IterativeSolverBase.h.
{ eigen_assert(m_isInitialized && "ConjugateGradient is not initialized."); return m_iterations; }
const ActualMatrixType& Eigen::IterativeSolverBase< Derived >::matrix | ( | ) | const [inline, protected] |
Definition at line 367 of file IterativeSolverBase.h.
{ return m_matrixWrapper.matrix(); }
Index Eigen::IterativeSolverBase< Derived >::maxIterations | ( | ) | const [inline] |
Definition at line 281 of file IterativeSolverBase.h.
{ return (m_maxIterations<0) ? 2*matrix().cols() : m_maxIterations; }
Preconditioner& Eigen::IterativeSolverBase< Derived >::preconditioner | ( | ) | [inline] |
Definition at line 272 of file IterativeSolverBase.h.
{ return m_preconditioner; }
const Preconditioner& Eigen::IterativeSolverBase< Derived >::preconditioner | ( | ) | const [inline] |
Definition at line 275 of file IterativeSolverBase.h.
{ return m_preconditioner; }
Index Eigen::IterativeSolverBase< Derived >::rows | ( | void | ) | const [inline] |
Definition at line 250 of file IterativeSolverBase.h.
{ return matrix().rows(); }
Derived& Eigen::IterativeSolverBase< Derived >::setMaxIterations | ( | Index | maxIters | ) | [inline] |
Sets the max number of iterations. Default is twice the number of columns of the matrix.
Definition at line 289 of file IterativeSolverBase.h.
{ m_maxIterations = maxIters; return derived(); }
Derived& Eigen::IterativeSolverBase< Derived >::setTolerance | ( | const RealScalar & | tolerance | ) | [inline] |
Sets the tolerance threshold used by the stopping criteria.
This value is used as an upper bound to the relative residual error: |Ax-b|/|b|. The default value is the machine precision given by NumTraits<Scalar>::epsilon()
Definition at line 265 of file IterativeSolverBase.h.
{ m_tolerance = tolerance; return derived(); }
const SolveWithGuess<Derived, Rhs, Guess> Eigen::IterativeSolverBase< Derived >::solveWithGuess | ( | const MatrixBase< Rhs > & | b, |
const Guess & | x0 | ||
) | const [inline] |
Definition at line 318 of file IterativeSolverBase.h.
{ eigen_assert(m_isInitialized && "Solver is not initialized."); eigen_assert(derived().rows()==b.rows() && "solve(): invalid number of rows of the right hand side matrix b"); return SolveWithGuess<Derived, Rhs, Guess>(derived(), b.derived(), x0); }
RealScalar Eigen::IterativeSolverBase< Derived >::tolerance | ( | ) | const [inline] |
Definition at line 258 of file IterativeSolverBase.h.
{ return m_tolerance; }
bool Eigen::IterativeSolverBase< Derived >::m_analysisIsOk [mutable, protected] |
Definition at line 387 of file IterativeSolverBase.h.
RealScalar Eigen::IterativeSolverBase< Derived >::m_error [mutable, protected] |
Definition at line 384 of file IterativeSolverBase.h.
bool Eigen::IterativeSolverBase< Derived >::m_factorizationIsOk [mutable, protected] |
Definition at line 387 of file IterativeSolverBase.h.
ComputationInfo Eigen::IterativeSolverBase< Derived >::m_info [mutable, protected] |
Definition at line 386 of file IterativeSolverBase.h.
Index Eigen::IterativeSolverBase< Derived >::m_iterations [mutable, protected] |
Definition at line 385 of file IterativeSolverBase.h.
MatrixWrapper Eigen::IterativeSolverBase< Derived >::m_matrixWrapper [protected] |
Definition at line 378 of file IterativeSolverBase.h.
Index Eigen::IterativeSolverBase< Derived >::m_maxIterations [protected] |
Definition at line 381 of file IterativeSolverBase.h.
Preconditioner Eigen::IterativeSolverBase< Derived >::m_preconditioner [protected] |
Definition at line 379 of file IterativeSolverBase.h.
RealScalar Eigen::IterativeSolverBase< Derived >::m_tolerance [protected] |
Definition at line 382 of file IterativeSolverBase.h.