From 35f7829af10c61e33dd2e2a7a015058e11a11ea0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 25 Mar 2017 14:17:07 +0100 Subject: update --- eigen/Eigen/src/OrderingMethods/Ordering.h | 51 ++++++++++++++++-------------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'eigen/Eigen/src/OrderingMethods/Ordering.h') diff --git a/eigen/Eigen/src/OrderingMethods/Ordering.h b/eigen/Eigen/src/OrderingMethods/Ordering.h index f3c31f9..7ea9b14 100644 --- a/eigen/Eigen/src/OrderingMethods/Ordering.h +++ b/eigen/Eigen/src/OrderingMethods/Ordering.h @@ -19,20 +19,21 @@ namespace internal { /** \internal * \ingroup OrderingMethods_Module - * \returns the symmetric pattern A^T+A from the input matrix A. + * \param[in] A the input non-symmetric matrix + * \param[out] symmat the symmetric pattern A^T+A from the input matrix \a A. * FIXME: The values should not be considered here */ template -void ordering_helper_at_plus_a(const MatrixType& mat, MatrixType& symmat) +void ordering_helper_at_plus_a(const MatrixType& A, MatrixType& symmat) { MatrixType C; - C = mat.transpose(); // NOTE: Could be costly + C = A.transpose(); // NOTE: Could be costly for (int i = 0; i < C.rows(); i++) { for (typename MatrixType::InnerIterator it(C, i); it; ++it) it.valueRef() = 0.0; } - symmat = C + mat; + symmat = C + A; } } @@ -44,14 +45,14 @@ void ordering_helper_at_plus_a(const MatrixType& mat, MatrixType& symmat) * * Functor computing the \em approximate \em minimum \em degree ordering * If the matrix is not structurally symmetric, an ordering of A^T+A is computed - * \tparam Index The type of indices of the matrix + * \tparam StorageIndex The type of indices of the matrix * \sa COLAMDOrdering */ -template +template class AMDOrdering { public: - typedef PermutationMatrix PermutationType; + typedef PermutationMatrix PermutationType; /** Compute the permutation vector from a sparse matrix * This routine is much faster if the input matrix is column-major @@ -60,7 +61,7 @@ class AMDOrdering void operator()(const MatrixType& mat, PermutationType& perm) { // Compute the symmetric pattern - SparseMatrix symm; + SparseMatrix symm; internal::ordering_helper_at_plus_a(mat,symm); // Call the AMD routine @@ -72,7 +73,7 @@ class AMDOrdering template void operator()(const SparseSelfAdjointView& mat, PermutationType& perm) { - SparseMatrix C; C = mat; + SparseMatrix C; C = mat; // Call the AMD routine // m_mat.prune(keep_diag()); //Remove the diagonal elements @@ -88,13 +89,13 @@ class AMDOrdering * Functor computing the natural ordering (identity) * * \note Returns an empty permutation matrix - * \tparam Index The type of indices of the matrix + * \tparam StorageIndex The type of indices of the matrix */ -template +template class NaturalOrdering { public: - typedef PermutationMatrix PermutationType; + typedef PermutationMatrix PermutationType; /** Compute the permutation vector from a column-major sparse matrix */ template @@ -108,15 +109,17 @@ class NaturalOrdering /** \ingroup OrderingMethods_Module * \class COLAMDOrdering * + * \tparam StorageIndex The type of indices of the matrix + * * Functor computing the \em column \em approximate \em minimum \em degree ordering * The matrix should be in column-major and \b compressed format (see SparseMatrix::makeCompressed()). */ -template +template class COLAMDOrdering { public: - typedef PermutationMatrix PermutationType; - typedef Matrix IndexVector; + typedef PermutationMatrix PermutationType; + typedef Matrix IndexVector; /** Compute the permutation vector \a perm form the sparse matrix \a mat * \warning The input sparse matrix \a mat must be in compressed mode (see SparseMatrix::makeCompressed()). @@ -126,26 +129,26 @@ class COLAMDOrdering { eigen_assert(mat.isCompressed() && "COLAMDOrdering requires a sparse matrix in compressed mode. Call .makeCompressed() before passing it to COLAMDOrdering"); - Index m = mat.rows(); - Index n = mat.cols(); - Index nnz = mat.nonZeros(); + StorageIndex m = StorageIndex(mat.rows()); + StorageIndex n = StorageIndex(mat.cols()); + StorageIndex nnz = StorageIndex(mat.nonZeros()); // Get the recommended value of Alen to be used by colamd - Index Alen = internal::colamd_recommended(nnz, m, n); + StorageIndex Alen = internal::colamd_recommended(nnz, m, n); // Set the default parameters double knobs [COLAMD_KNOBS]; - Index stats [COLAMD_STATS]; + StorageIndex stats [COLAMD_STATS]; internal::colamd_set_defaults(knobs); IndexVector p(n+1), A(Alen); - for(Index i=0; i <= n; i++) p(i) = mat.outerIndexPtr()[i]; - for(Index i=0; i < nnz; i++) A(i) = mat.innerIndexPtr()[i]; + for(StorageIndex i=0; i <= n; i++) p(i) = mat.outerIndexPtr()[i]; + for(StorageIndex i=0; i < nnz; i++) A(i) = mat.innerIndexPtr()[i]; // Call Colamd routine to compute the ordering - Index info = internal::colamd(m, n, Alen, A.data(), p.data(), knobs, stats); + StorageIndex info = internal::colamd(m, n, Alen, A.data(), p.data(), knobs, stats); EIGEN_UNUSED_VARIABLE(info); eigen_assert( info && "COLAMD failed " ); perm.resize(n); - for (Index i = 0; i < n; i++) perm.indices()(p(i)) = i; + for (StorageIndex i = 0; i < n; i++) perm.indices()(p(i)) = i; } }; -- cgit v1.2.3