From afc55b1885138a92f2d8069c32a78874f4c328a5 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sun, 6 Nov 2016 20:28:18 +0100 Subject: [PATCH] Generalize IterativeSolverBase::solve to hanlde any sparse type as the results (instead of SparseMatrix only) --- Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h b/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h index 3d62fef6e..7c2326eb7 100644 --- a/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +++ b/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h @@ -330,25 +330,27 @@ public: } /** \internal */ - template - void _solve_impl(const Rhs& b, SparseMatrix &dest) const + template + void _solve_impl(const Rhs& b, SparseMatrixBase &aDest) const { eigen_assert(rows()==b.rows()); Index rhsCols = b.cols(); Index size = b.rows(); + DestDerived& dest(aDest.derived()); + typedef typename DestDerived::Scalar DestScalar; Eigen::Matrix tb(size); Eigen::Matrix tx(cols()); // We do not directly fill dest because sparse expressions have to be free of aliasing issue. // For non square least-square problems, b and dest might not have the same size whereas they might alias each-other. - SparseMatrix tmp(cols(),rhsCols); + typename DestDerived::PlainObject tmp(cols(),rhsCols); for(Index k=0; k