extend BiCGSTAB to arbitrary rhs

This commit is contained in:
Gael Guennebaud 2011-10-11 19:53:18 +02:00
parent 21d27c6f71
commit 15cb4f5b09

View File

@ -45,7 +45,7 @@ void bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x,
using std::abs; using std::abs;
typedef typename Dest::RealScalar RealScalar; typedef typename Dest::RealScalar RealScalar;
typedef typename Dest::Scalar Scalar; typedef typename Dest::Scalar Scalar;
typedef Dest VectorType; typedef Matrix<Scalar,Dynamic,1> VectorType;
RealScalar tol = tol_error; RealScalar tol = tol_error;
int maxIters = iters; int maxIters = iters;
@ -217,11 +217,15 @@ public:
/** \internal */ /** \internal */
template<typename Rhs,typename Dest> template<typename Rhs,typename Dest>
void _solve(const Rhs& b, Dest& x) const void _solve(const Rhs& b, Dest& x) const
{ {
m_iterations = Base::m_maxIterations; for(int j=0; j<b.cols(); ++j)
m_error = Base::m_tolerance; {
m_iterations = Base::m_maxIterations;
internal::bicgstab(*mp_matrix, b, x, Base::m_preconditioner, m_iterations, m_error); m_error = Base::m_tolerance;
typename Dest::ColXpr xj(x,j);
internal::bicgstab(*mp_matrix, b.col(j), xj, Base::m_preconditioner, m_iterations, m_error);
}
m_isInitialized = true; m_isInitialized = true;
m_info = m_error <= Base::m_tolerance ? Success : NoConvergence; m_info = m_error <= Base::m_tolerance ? Success : NoConvergence;