From 1c4b69c5fb4ec6a8b71a64f39ea82dacf50a8bfd Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 1 Sep 2014 17:19:51 +0200 Subject: [PATCH] Factorize solveWithGuess in IterativeSolverBase --- Eigen/src/IterativeLinearSolvers/BiCGSTAB.h | 15 --------------- .../IterativeLinearSolvers/ConjugateGradient.h | 15 --------------- .../IterativeLinearSolvers/IterativeSolverBase.h | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 30 deletions(-) diff --git a/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h b/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h index 2cad946d3..b4d1d2a79 100644 --- a/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +++ b/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h @@ -198,21 +198,6 @@ public: return internal::solve_retval_with_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 - inline const SolveWithGuess - solveWithGuess(const MatrixBase& 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(*this, b.derived(), x0); - } #endif /** \internal */ diff --git a/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h b/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h index 000780eff..b0273aaaf 100644 --- a/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +++ b/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h @@ -209,21 +209,6 @@ public: return internal::solve_retval_with_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 - inline const SolveWithGuess - solveWithGuess(const MatrixBase& b, const Guess& x0) const - { - eigen_assert(m_isInitialized && "ConjugateGradient is not initialized."); - eigen_assert(Base::rows()==b.rows() - && "ConjugateGradient::solve(): invalid number of rows of the right hand side matrix b"); - return SolveWithGuess(*this, b.derived(), x0); - } #endif /** \internal */ diff --git a/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h b/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h index 2fc1a511b..26487dbb2 100644 --- a/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +++ b/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h @@ -193,6 +193,22 @@ public: } #endif // EIGEN_TEST_EVALUATORS +#ifdef EIGEN_TEST_EVALUATORS + /** \returns the solution x of \f$ A x = b \f$ using the current decomposition of A + * and \a x0 as an initial solution. + * + * \sa solve(), compute() + */ + template + inline const SolveWithGuess + solveWithGuess(const MatrixBase& b, const Guess& x0) const + { + 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(), b.derived(), x0); + } +#endif // EIGEN_TEST_EVALUATORS + /** \returns Success if the iterations converged, and NoConvergence otherwise. */ ComputationInfo info() const {