add the possibility to configure the preconditioner

This commit is contained in:
Gael Guennebaud 2011-07-26 09:22:18 +02:00
parent 66fa6f39a2
commit 51f706b916

View File

@ -135,6 +135,7 @@ class conjugate_gradient_solve_retval_with_guess;
* \endcode * \endcode
* Note that such a step by step excution is slightly slower. * Note that such a step by step excution is slightly slower.
* *
* \sa class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner
*/ */
template< typename _MatrixType, int _UpLo=Lower, template< typename _MatrixType, int _UpLo=Lower,
typename _Preconditioner = DiagonalPreconditioner<typename _MatrixType::Scalar> > typename _Preconditioner = DiagonalPreconditioner<typename _MatrixType::Scalar> >
@ -161,6 +162,9 @@ public:
} }
/** Initialize the solver with matrix \a A for further \c Ax=b solving. /** Initialize the solver with matrix \a A for further \c 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 * \warning this class stores a reference to the matrix A as well as some
* precomputed values that depend on it. Therefore, if \a A is changed * precomputed values that depend on it. Therefore, if \a A is changed
@ -176,6 +180,9 @@ public:
~ConjugateGradient() {} ~ConjugateGradient() {}
/** Initializes the iterative solver with the matrix \a A for further solving \c Ax=b problems. /** Initializes the iterative solver with the matrix \a A for further solving \c 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 * \warning this class stores a reference to the matrix A as well as some
* precomputed values that depend on it. Therefore, if \a A is changed * precomputed values that depend on it. Therefore, if \a A is changed
@ -205,6 +212,12 @@ public:
return *this; return *this;
} }
/** \returns a read-write reference to the preconditioner for custom configuration. */
Preconditioner& preconditioner() { return m_preconditioner; }
/** \returns a read-only reference to the preconditioner. */
const Preconditioner& preconditioner() const { return m_preconditioner; }
/** \returns the max number of iterations */ /** \returns the max number of iterations */
int maxIterations() const { return m_maxIterations; } int maxIterations() const { return m_maxIterations; }