aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2014-09-01 15:00:19 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2014-09-01 15:00:19 +0200
commit85c765957418cd2fd24b46ca3a14e6fcbad43f05 (patch)
tree01111ad07068a8d03fab51c277e0026de2a441cb /Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
parentbc065c75d2a8df928cb368d0352b8fcb25791fa8 (diff)
Refactoring of sparse solvers through a SparseSolverBase class and usage of the Solve<> expression. Introduce a SolveWithGuess expression on top of Solve.
Diffstat (limited to 'Eigen/src/IterativeLinearSolvers/BiCGSTAB.h')
-rw-r--r--Eigen/src/IterativeLinearSolvers/BiCGSTAB.h41
1 files changed, 30 insertions, 11 deletions
diff --git a/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h b/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
index 27824b9d5..2cad946d3 100644
--- a/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
+++ b/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
@@ -1,7 +1,7 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
-// Copyright (C) 2011 Gael Guennebaud <gael.guennebaud@inria.fr>
+// Copyright (C) 2011-2014 Gael Guennebaud <gael.guennebaud@inria.fr>
// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>
//
// This Source Code Form is subject to the terms of the Mozilla
@@ -181,7 +181,8 @@ public:
BiCGSTAB(const MatrixType& A) : Base(A) {}
~BiCGSTAB() {}
-
+
+#ifndef EIGEN_TEST_EVALUATORS
/** \returns the solution x of \f$ A x = b \f$ using the current decomposition of A
* \a x0 as an initial solution.
*
@@ -197,10 +198,26 @@ public:
return internal::solve_retval_with_guess
<BiCGSTAB, Rhs, Guess>(*this, b.derived(), x0);
}
-
+#else
+ /** \returns the solution x of \f$ A x = b \f$ using the current decomposition of A
+ * \a x0 as an initial solution.
+ *
+ * \sa compute()
+ */
+ template<typename Rhs,typename Guess>
+ inline const SolveWithGuess<BiCGSTAB, Rhs, Guess>
+ solveWithGuess(const MatrixBase<Rhs>& b, const Guess& x0) const
+ {
+ eigen_assert(m_isInitialized && "BiCGSTAB is not initialized.");
+ eigen_assert(Base::rows()==b.rows()
+ && "BiCGSTAB::solve(): invalid number of rows of the right hand side matrix b");
+ return SolveWithGuess<BiCGSTAB, Rhs, Guess>(*this, b.derived(), x0);
+ }
+#endif
+
/** \internal */
template<typename Rhs,typename Dest>
- void _solveWithGuess(const Rhs& b, Dest& x) const
+ void _solve_with_guess_impl(const Rhs& b, Dest& x) const
{
bool failed = false;
for(int j=0; j<b.cols(); ++j)
@@ -219,22 +236,23 @@ public:
}
/** \internal */
+ using Base::_solve_impl;
template<typename Rhs,typename Dest>
- void _solve(const Rhs& b, Dest& x) const
+ void _solve_impl(const MatrixBase<Rhs>& b, Dest& x) const
{
-// x.setZero();
- x = b;
- _solveWithGuess(b,x);
+ // x.setZero();
+ x = b;
+ _solve_with_guess_impl(b,x);
}
protected:
};
-
+#ifndef EIGEN_TEST_EVALUATORS
namespace internal {
- template<typename _MatrixType, typename _Preconditioner, typename Rhs>
+template<typename _MatrixType, typename _Preconditioner, typename Rhs>
struct solve_retval<BiCGSTAB<_MatrixType, _Preconditioner>, Rhs>
: solve_retval_base<BiCGSTAB<_MatrixType, _Preconditioner>, Rhs>
{
@@ -243,11 +261,12 @@ struct solve_retval<BiCGSTAB<_MatrixType, _Preconditioner>, Rhs>
template<typename Dest> void evalTo(Dest& dst) const
{
- dec()._solve(rhs(),dst);
+ dec()._solve_impl(rhs(),dst);
}
};
} // end namespace internal
+#endif
} // end namespace Eigen