From f4a6a8e29568a01a4c04eee53f87242ec6afc684 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 26 Oct 2010 16:47:47 +0200 Subject: [PATCH] rm the useless SparseSolverBase class and provide more compile time traits --- .../Eigen/src/SparseExtra/CholmodSupport.h | 90 +++++++------------ 1 file changed, 33 insertions(+), 57 deletions(-) diff --git a/unsupported/Eigen/src/SparseExtra/CholmodSupport.h b/unsupported/Eigen/src/SparseExtra/CholmodSupport.h index ac9f59e82..08f01a6e6 100644 --- a/unsupported/Eigen/src/SparseExtra/CholmodSupport.h +++ b/unsupported/Eigen/src/SparseExtra/CholmodSupport.h @@ -138,57 +138,6 @@ MappedSparseMatrix viewAsEigen(cholmod_sparse& cm) reinterpret_cast(cm.p), reinterpret_cast(cm.i),reinterpret_cast(cm.x) ); } -template -class SparseSolverBase -{ - public: - - SparseSolverBase() - : m_info(Success), m_isInitialized(false) - {} - - Derived& derived() { return *static_cast(this); } - const Derived& derived() const { return *static_cast(this); } - - #ifdef EIGEN_PARSED_BY_DOXYGEN - /** Computes the sparse Cholesky decomposition of \a matrix */ - void compute(const typename Derived::MatrixType& matrix) - { - derived().compute(matrix); - } - #endif // EIGEN_PARSED_BY_DOXYGEN - - /** \returns the solution x of \f$ A x = b \f$ using the current decomposition of A. - * - * \sa compute() - */ - template - inline const internal::solve_retval - solve(const MatrixBase& b) const - { - eigen_assert(m_isInitialized && "LLT is not initialized."); -// eigen_assert(m_matrix.rows()==b.rows() -// && "LLT::solve(): invalid number of rows of the right hand side matrix b"); - return internal::solve_retval(derived(), b.derived()); - } - - /** \brief Reports whether previous computation was successful. - * - * \returns \c Success if computation was succesful, - * \c NumericalIssue if the matrix.appears to be negative. - */ - ComputationInfo info() const - { - eigen_assert(m_isInitialized && "Decomposition is not initialized."); - return m_info; - } - - protected: - - mutable ComputationInfo m_info; - bool m_isInitialized; -}; - enum CholmodMode { CholmodAuto, CholmodSimplicialLLt, CholmodSupernodalLLt, CholmodLDLt }; @@ -205,13 +154,11 @@ enum CholmodMode { * */ template -class CholmodDecomposition : public SparseSolverBase > +class CholmodDecomposition { public: typedef _MatrixType MatrixType; enum { UpLo = _UpLo }; - protected: - typedef SparseSolverBase Base; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; typedef MatrixType CholMatrixType; @@ -220,13 +167,13 @@ class CholmodDecomposition : public SparseSolverBase + inline const internal::solve_retval + solve(const MatrixBase& b) const + { + eigen_assert(m_isInitialized && "LLT is not initialized."); + eigen_assert(rows()==b.rows() + && "CholmodDecomposition::solve(): invalid number of rows of the right hand side matrix b"); + return internal::solve_retval(*this, b.derived()); + } + /** Performs a symbolic decomposition on the sparcity of \a matrix. * * This function is particularly useful when solving for several problems having the same structure. @@ -318,6 +289,7 @@ class CholmodDecomposition : public SparseSolverBase void _solve(const MatrixBase &b, MatrixBase &dest) const @@ -336,10 +308,14 @@ class CholmodDecomposition : public SparseSolverBase::Map(reinterpret_cast(x_cd->x),b.rows()); cholmod_free_dense(&x_cd, &m_cholmod); } + + #endif // EIGEN_PARSED_BY_DOXYGEN protected: mutable cholmod_common m_cholmod; cholmod_factor* m_cholmodFactor; + mutable ComputationInfo m_info; + bool m_isInitialized; int m_factorizationIsOk; int m_analysisIsOk; }; @@ -355,7 +331,7 @@ struct solve_retval, Rhs> template void evalTo(Dest& dst) const { - dec().derived()._solve(rhs(),dst); + dec()._solve(rhs(),dst); } };