From 0412dff97b7628ac539bd51c2854216fdab11f11 Mon Sep 17 00:00:00 2001 From: Desire NUENTSA Date: Tue, 13 Nov 2012 18:13:13 +0100 Subject: [PATCH] Add more useful functions to SPQR interface --- Eigen/src/SPQRSupport/SuiteSparseQRSupport.h | 31 +++++++++++++++----- cmake/FindSPQR.cmake | 27 +++++++++++++++++ 2 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 cmake/FindSPQR.cmake diff --git a/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h b/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h index 35dba2e68..2647d22f0 100644 --- a/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +++ b/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h @@ -36,7 +36,7 @@ namespace Eigen { * \class SPQR * \brief Sparse QR factorization based on SuiteSparseQR library * - * This class is used to perform a multithreaded and multifrontal QR decomposition + * This class is used to perform a multithreaded and multifrontal rank-revealing QR decomposition * of sparse matrices. The result is then used to solve linear leasts_square systems. * Clearly, a QR factorization is returned such that A*P = Q*R where : * @@ -61,6 +61,7 @@ class SPQR typedef typename _MatrixType::RealScalar RealScalar; typedef UF_long Index ; typedef SparseMatrix MatrixType; + typedef PermutationMatrix PermutationType; public: SPQR() : m_ordering(SPQR_ORDERING_DEFAULT), @@ -115,8 +116,8 @@ class SPQR // Solves with the triangular matrix R Dest y; y = this->matrixQR().template triangularView().solve(dest.derived()); - // Apply the column permutation //TODO Check the terminology behind the permutation - for (int j = 0; j < y.size(); j++) dest(m_E[j]) = y(j); + // Apply the column permutation + dest = colsPermutation() * y; m_info = Success; } @@ -133,13 +134,29 @@ class SPQR return SPQRMatrixQReturnType(*this); } /// Get the permutation that was applied to columns of A - Index *colsPermutation() { return m_E; } - + PermutationType colsPermutation() const + { + eigen_assert(m_isInitialized && "Decomposition is not initialized."); + Index n = m_cR->ncol; + PermutationType colsPerm(n); + for(Index j = 0; j