MOAB
4.9.3pre
|
A bi conjugate gradient stabilized solver for sparse square problems. More...
#include <BiCGSTAB.h>
Public Types | |
typedef _MatrixType | MatrixType |
typedef MatrixType::Scalar | Scalar |
typedef MatrixType::RealScalar | RealScalar |
typedef _Preconditioner | Preconditioner |
Public Member Functions | |
BiCGSTAB () | |
template<typename MatrixDerived > | |
BiCGSTAB (const EigenBase< MatrixDerived > &A) | |
~BiCGSTAB () | |
template<typename Rhs , typename Dest > | |
void | _solve_with_guess_impl (const Rhs &b, Dest &x) const |
template<typename Rhs , typename Dest > | |
void | _solve_impl (const MatrixBase< Rhs > &b, Dest &x) const |
Private Types | |
typedef IterativeSolverBase < BiCGSTAB > | Base |
A bi conjugate gradient stabilized solver for sparse square problems.
This class allows to solve for A.x = b sparse linear problems using a bi conjugate gradient stabilized algorithm. 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. |
_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.
The tolerance corresponds to the relative residual error: |Ax-b|/|b|
Performance: when using sparse matrices, best performance is achied for a row-major sparse matrix format. Moreover, in this case multi-threading can be exploited if the user code is compiled with OpenMP enabled. See TopicMultiThreading for details.
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.
BiCGSTAB can also be used in a matrix-free context, see the following example .
Definition at line 158 of file BiCGSTAB.h.
typedef IterativeSolverBase<BiCGSTAB> Eigen::BiCGSTAB< _MatrixType, _Preconditioner >::Base [private] |
Reimplemented from Eigen::IterativeSolverBase< BiCGSTAB< _MatrixType, _Preconditioner > >.
Definition at line 160 of file BiCGSTAB.h.
typedef _MatrixType Eigen::BiCGSTAB< _MatrixType, _Preconditioner >::MatrixType |
Reimplemented from Eigen::IterativeSolverBase< BiCGSTAB< _MatrixType, _Preconditioner > >.
Definition at line 167 of file BiCGSTAB.h.
typedef _Preconditioner Eigen::BiCGSTAB< _MatrixType, _Preconditioner >::Preconditioner |
Reimplemented from Eigen::IterativeSolverBase< BiCGSTAB< _MatrixType, _Preconditioner > >.
Definition at line 170 of file BiCGSTAB.h.
typedef MatrixType::RealScalar Eigen::BiCGSTAB< _MatrixType, _Preconditioner >::RealScalar |
Reimplemented from Eigen::IterativeSolverBase< BiCGSTAB< _MatrixType, _Preconditioner > >.
Definition at line 169 of file BiCGSTAB.h.
typedef MatrixType::Scalar Eigen::BiCGSTAB< _MatrixType, _Preconditioner >::Scalar |
Reimplemented from Eigen::IterativeSolverBase< BiCGSTAB< _MatrixType, _Preconditioner > >.
Definition at line 168 of file BiCGSTAB.h.
Eigen::BiCGSTAB< _MatrixType, _Preconditioner >::BiCGSTAB | ( | ) | [inline] |
Eigen::BiCGSTAB< _MatrixType, _Preconditioner >::BiCGSTAB | ( | 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 188 of file BiCGSTAB.h.
: Base(A.derived()) {}
Eigen::BiCGSTAB< _MatrixType, _Preconditioner >::~BiCGSTAB | ( | ) | [inline] |
Definition at line 190 of file BiCGSTAB.h.
{}
void Eigen::BiCGSTAB< _MatrixType, _Preconditioner >::_solve_impl | ( | const MatrixBase< Rhs > & | b, |
Dest & | x | ||
) | const [inline] |
Definition at line 215 of file BiCGSTAB.h.
{ x.resize(this->rows(),b.cols()); x.setZero(); _solve_with_guess_impl(b,x); }
void Eigen::BiCGSTAB< _MatrixType, _Preconditioner >::_solve_with_guess_impl | ( | const Rhs & | b, |
Dest & | x | ||
) | const [inline] |
Definition at line 194 of file BiCGSTAB.h.
{ bool failed = false; for(Index j=0; j<b.cols(); ++j) { m_iterations = Base::maxIterations(); m_error = Base::m_tolerance; typename Dest::ColXpr xj(x,j); if(!internal::bicgstab(matrix(), b.col(j), xj, Base::m_preconditioner, m_iterations, m_error)) failed = true; } m_info = failed ? NumericalIssue : m_error <= Base::m_tolerance ? Success : NoConvergence; m_isInitialized = true; }