From 225ec02b06e013fd60dceeb6dc83cd08193719b9 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 7 Sep 2009 11:15:38 +0200 Subject: [PATCH] fix another .stride() issue in Cholmod support --- Eigen/src/Sparse/CholmodSupport.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Eigen/src/Sparse/CholmodSupport.h b/Eigen/src/Sparse/CholmodSupport.h index ad59c89af..30a33c3dc 100644 --- a/Eigen/src/Sparse/CholmodSupport.h +++ b/Eigen/src/Sparse/CholmodSupport.h @@ -99,7 +99,7 @@ cholmod_dense ei_cholmod_map_eigen_to_dense(MatrixBase& mat) res.nrow = mat.rows(); res.ncol = mat.cols(); res.nzmax = res.nrow * res.ncol; - res.d = mat.derived().stride(); + res.d = Derived::IsVectorAtCompileTime ? mat.derived().size() : mat.derived().stride(); res.x = mat.derived().data(); res.z = 0; @@ -157,7 +157,7 @@ class SparseLLT : public SparseLLT inline const typename Base::CholMatrixType& matrixL(void) const; template - void solveInPlace(MatrixBase &b) const; + bool solveInPlace(MatrixBase &b) const; void compute(const MatrixType& matrix); @@ -216,7 +216,7 @@ SparseLLT::matrixL() const template template -void SparseLLT::solveInPlace(MatrixBase &b) const +bool SparseLLT::solveInPlace(MatrixBase &b) const { const int size = m_cholmodFactor->n; ei_assert(size==b.rows()); @@ -228,9 +228,16 @@ void SparseLLT::solveInPlace(MatrixBase &b) const // as long as our own triangular sparse solver is not fully optimal, // let's use CHOLMOD's one: cholmod_dense cdb = ei_cholmod_map_eigen_to_dense(b); - cholmod_dense* x = cholmod_solve(CHOLMOD_LDLt, m_cholmodFactor, &cdb, &m_cholmod); + //cholmod_dense* x = cholmod_solve(CHOLMOD_LDLt, m_cholmodFactor, &cdb, &m_cholmod); + cholmod_dense* x = cholmod_solve(CHOLMOD_A, m_cholmodFactor, &cdb, &m_cholmod); + if(!x) + { + std::cerr << "Eigen: cholmod_solve failed\n"; + return false; + } b = Matrix::Map(reinterpret_cast(x->x),b.rows()); cholmod_free_dense(&x, &m_cholmod); + return true; } #endif // EIGEN_CHOLMODSUPPORT_H