From bbaef8ebbaca890267062bbd605c218f2d765d29 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 17 Jul 2013 09:30:25 +0200 Subject: [PATCH] SparseLU: make COLAMDOrdering the default ordering method. --- Eigen/src/SparseLU/SparseLU.h | 111 +++++++++++++++++----------------- test/sparselu.cpp | 4 +- 2 files changed, 59 insertions(+), 56 deletions(-) diff --git a/Eigen/src/SparseLU/SparseLU.h b/Eigen/src/SparseLU/SparseLU.h index 503942b84..dd9eab2c2 100644 --- a/Eigen/src/SparseLU/SparseLU.h +++ b/Eigen/src/SparseLU/SparseLU.h @@ -14,9 +14,10 @@ namespace Eigen { -template class SparseLU; +template > class SparseLU; template struct SparseLUMatrixLReturnType; template struct SparseLUMatrixUReturnType; + /** \ingroup SparseLU_Module * \class SparseLU * @@ -62,7 +63,7 @@ template struct SparseLUMatrixURetu * "unsupported/Eigen/src/IterativeSolvers/Scaling.h" * * \tparam _MatrixType The type of the sparse matrix. It must be a column-major SparseMatrix<> - * \tparam _OrderingType The ordering method to use, either AMD, COLAMD or METIS + * \tparam _OrderingType The ordering method to use, either AMD, COLAMD or METIS. Default is COLMAD * * * \sa \ref TutorialSparseDirectSolvers @@ -105,9 +106,9 @@ class SparseLU : public internal::SparseLUImpl matrixL() const { return SparseLUMatrixLReturnType(m_Lstore); } /** \returns an expression of the matrix U, - * The only operation available with this expression is the triangular solve - * \code - * y = b; matrixU().solveInPlace(y); - * \endcode - */ + * The only operation available with this expression is the triangular solve + * \code + * y = b; matrixU().solveInPlace(y); + * \endcode + */ SparseLUMatrixUReturnType > matrixU() const { return SparseLUMatrixUReturnType >(m_Lstore, m_Ustore); } /** - * \returns a reference to the row matrix permutation \f$ P_r \f$ such that \f$P_r A P_c^T = L U\f$ - * \sa colsPermutation() - */ + * \returns a reference to the row matrix permutation \f$ P_r \f$ such that \f$P_r A P_c^T = L U\f$ + * \sa colsPermutation() + */ inline const PermutationType& rowsPermutation() const { return m_perm_r; } /** - * \returns a reference to the column matrix permutation\f$ P_c^T \f$ such that \f$P_r A P_c^T = L U\f$ - * \sa rowsPermutation() - */ + * \returns a reference to the column matrix permutation\f$ P_c^T \f$ such that \f$P_r A P_c^T = L U\f$ + * \sa rowsPermutation() + */ inline const PermutationType& colsPermutation() const { return m_perm_c; @@ -182,7 +183,7 @@ class SparseLU : public internal::SparseLUImpl(*this, B.derived()); } - /** \returns the solution X of \f$ A X = B \f$ using the current decomposition of A. + /** \returns the solution X of \f$ A X = B \f$ using the current decomposition of A. * * \sa compute() */ @@ -195,7 +196,7 @@ class SparseLU : public internal::SparseLUImpl(*this, B.derived()); } - /** \brief Reports whether previous computation was successful. + /** \brief Reports whether previous computation was successful. * * \returns \c Success if computation was succesful, * \c NumericalIssue if the LU factorization reports a problem, zero diagonal for instance @@ -208,9 +209,10 @@ class SparseLU : public internal::SparseLUImpl void SparseLU::analyzePattern(const MatrixType& mat) { @@ -428,23 +431,23 @@ void SparseLU::analyzePattern(const MatrixType& mat) /** - * - Numerical factorization - * - Interleaved with the symbolic factorization - * On exit, info is - * - * = 0: successful factorization - * - * > 0: if info = i, and i is - * - * <= A->ncol: U(i,i) is exactly zero. The factorization has - * been completed, but the factor U is exactly singular, - * and division by zero will occur if it is used to solve a - * system of equations. - * - * > A->ncol: number of bytes allocated when memory allocation - * failure occurred, plus A->ncol. If lwork = -1, it is - * the estimated amount of space needed, plus A->ncol. - */ + * - Numerical factorization + * - Interleaved with the symbolic factorization + * On exit, info is + * + * = 0: successful factorization + * + * > 0: if info = i, and i is + * + * <= A->ncol: U(i,i) is exactly zero. The factorization has + * been completed, but the factor U is exactly singular, + * and division by zero will occur if it is used to solve a + * system of equations. + * + * > A->ncol: number of bytes allocated when memory allocation + * failure occurred, plus A->ncol. If lwork = -1, it is + * the estimated amount of space needed, plus A->ncol. + */ template void SparseLU::factorize(const MatrixType& matrix) { diff --git a/test/sparselu.cpp b/test/sparselu.cpp index 6a9eac065..37980defc 100644 --- a/test/sparselu.cpp +++ b/test/sparselu.cpp @@ -26,7 +26,7 @@ // SparseLU solve does not accept column major matrices for the destination. // However, as expected, the generic check_sparse_square_solving routines produces row-major // rhs and destination matrices when compiled with EIGEN_DEFAULT_TO_ROW_MAJOR -// + #ifdef EIGEN_DEFAULT_TO_ROW_MAJOR #undef EIGEN_DEFAULT_TO_ROW_MAJOR #endif @@ -37,7 +37,7 @@ template void test_sparselu_T() { - SparseLU, COLAMDOrdering > sparselu_colamd; + SparseLU /*, COLAMDOrdering*/ > sparselu_colamd; // COLAMDOrdering is the default SparseLU, AMDOrdering > sparselu_amd; SparseLU, NaturalOrdering > sparselu_natural;