From 224a1fe4c6991c863986d8c8bd3d41af5aa4ff80 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 9 Mar 2015 13:55:20 +0100 Subject: bug #963: make IncompleteLUT compatible with non-default storage index types. --- Eigen/src/IterativeLinearSolvers/IncompleteLUT.h | 41 ++++++++++++------------ 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'Eigen/src/IterativeLinearSolvers') diff --git a/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h b/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h index 6d63d45e4..b7f8debb3 100644 --- a/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +++ b/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h @@ -93,21 +93,23 @@ Index QuickSplit(VectorV &row, VectorI &ind, Index ncut) * alternatively, on GMANE: * http://comments.gmane.org/gmane.comp.lib.eigen/3302 */ -template -class IncompleteLUT : public SparseSolverBase > +template +class IncompleteLUT : public SparseSolverBase > { protected: - typedef SparseSolverBase > Base; + typedef SparseSolverBase Base; using Base::m_isInitialized; public: typedef _Scalar Scalar; + typedef _StorageIndex StorageIndex; typedef typename NumTraits::Real RealScalar; typedef Matrix Vector; - typedef SparseMatrix FactorType; - typedef SparseMatrix PermutType; - typedef typename FactorType::StorageIndex StorageIndex; + typedef Matrix VectorI; + typedef SparseMatrix FactorType; public: + + // this typedef is only to export the scalar type and compile-time dimensions to solve_retval typedef Matrix MatrixType; IncompleteLUT() @@ -151,7 +153,7 @@ class IncompleteLUT : public SparseSolverBase > * **/ template - IncompleteLUT& compute(const MatrixType& amat) + IncompleteLUT& compute(const MatrixType& amat) { analyzePattern(amat); factorize(amat); @@ -197,8 +199,8 @@ protected: * Set control parameter droptol * \param droptol Drop any element whose magnitude is less than this tolerance **/ -template -void IncompleteLUT::setDroptol(const RealScalar& droptol) +template +void IncompleteLUT::setDroptol(const RealScalar& droptol) { this->m_droptol = droptol; } @@ -207,15 +209,15 @@ void IncompleteLUT::setDroptol(const RealScalar& droptol) * Set control parameter fillfactor * \param fillfactor This is used to compute the number @p fill_in of largest elements to keep on each row. **/ -template -void IncompleteLUT::setFillfactor(int fillfactor) +template +void IncompleteLUT::setFillfactor(int fillfactor) { this->m_fillfactor = fillfactor; } -template +template template -void IncompleteLUT::analyzePattern(const _MatrixType& amat) +void IncompleteLUT::analyzePattern(const _MatrixType& amat) { // Compute the Fill-reducing permutation SparseMatrix mat1 = amat; @@ -232,9 +234,9 @@ void IncompleteLUT::analyzePattern(const _MatrixType& amat) m_analysisIsOk = true; } -template +template template -void IncompleteLUT::factorize(const _MatrixType& amat) +void IncompleteLUT::factorize(const _MatrixType& amat) { using std::sqrt; using std::swap; @@ -246,8 +248,8 @@ void IncompleteLUT::factorize(const _MatrixType& amat) m_lu.resize(n,n); // Declare Working vectors and variables Vector u(n) ; // real values of the row -- maximum size is n -- - VectorXi ju(n); // column position of the values in u -- maximum size is n - VectorXi jr(n); // Indicate the position of the nonzero elements in the vector u -- A zero location is indicated by -1 + VectorI ju(n); // column position of the values in u -- maximum size is n + VectorI jr(n); // Indicate the position of the nonzero elements in the vector u -- A zero location is indicated by -1 // Apply the fill-reducing permutation eigen_assert(m_analysisIsOk && "You must first call analyzePattern()"); @@ -398,7 +400,7 @@ void IncompleteLUT::factorize(const _MatrixType& amat) sizel = len; len = (std::min)(sizel, nnzL); typename Vector::SegmentReturnType ul(u.segment(0, sizel)); - typename VectorXi::SegmentReturnType jul(ju.segment(0, sizel)); + typename VectorI::SegmentReturnType jul(ju.segment(0, sizel)); internal::QuickSplit(ul, jul, len); // store the largest m_fill elements of the L part @@ -427,14 +429,13 @@ void IncompleteLUT::factorize(const _MatrixType& amat) sizeu = len + 1; // +1 to take into account the diagonal element len = (std::min)(sizeu, nnzU); typename Vector::SegmentReturnType uu(u.segment(ii+1, sizeu-1)); - typename VectorXi::SegmentReturnType juu(ju.segment(ii+1, sizeu-1)); + typename VectorI::SegmentReturnType juu(ju.segment(ii+1, sizeu-1)); internal::QuickSplit(uu, juu, len); // store the largest elements of the U part for(Index k = ii + 1; k < ii + len; k++) m_lu.insertBackByOuterInnerUnordered(ii,ju(k)) = u(k); } - m_lu.finalize(); m_lu.makeCompressed(); -- cgit v1.2.3