diff --git a/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h b/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h index de576edc90..5f0159e521 100644 --- a/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +++ b/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h @@ -185,10 +185,13 @@ public: template void _solve_with_guess_impl(const Rhs& b, Dest& x) const { + typedef Ref MatRef; + typedef typename internal::conditional::IsComplex), + Transpose, MatRef const&>::type RowMajorWrapper; typedef typename internal::conditional&, - typename Ref::template ConstSelfAdjointViewReturnType::Type - >::type MatrixWrapperType; + RowMajorWrapper, + typename MatRef::template ConstSelfAdjointViewReturnType::Type + >::type SelfAdjointWrapper; m_iterations = Base::maxIterations(); m_error = Base::m_tolerance; @@ -198,7 +201,8 @@ public: m_error = Base::m_tolerance; typename Dest::ColXpr xj(x,j); - internal::conjugate_gradient(MatrixWrapperType(mp_matrix), b.col(j), xj, Base::m_preconditioner, m_iterations, m_error); + RowMajorWrapper row_mat(mp_matrix); + internal::conjugate_gradient(SelfAdjointWrapper(row_mat), b.col(j), xj, Base::m_preconditioner, m_iterations, m_error); } m_isInitialized = true;