11#ifndef EIGEN_ORDERING_H
12#define EIGEN_ORDERING_H
15#include "./InternalHeaderCheck.h"
19#include "Eigen_Colamd.h"
29template <
typename MatrixType>
30void ordering_helper_at_plus_a(
const MatrixType& A, MatrixType& symmat) {
33 for (
int i = 0; i < C.rows(); i++) {
34 for (
typename MatrixType::InnerIterator it(C, i); it; ++it) it.valueRef() =
typename MatrixType::Scalar(0);
49template <
typename StorageIndex>
57 template <
typename MatrixType>
61 internal::ordering_helper_at_plus_a(mat, symm);
65 internal::minimum_degree_ordering(symm, perm);
69 template <
typename SrcType,
unsigned int SrcUpLo>
76 internal::minimum_degree_ordering(C, perm);
88template <
typename StorageIndex>
94 template <
typename MatrixType>
108template <
typename StorageIndex>
117 template <
typename MatrixType>
119 eigen_assert(mat.isCompressed() &&
120 "COLAMDOrdering requires a sparse matrix in compressed mode. Call .makeCompressed() before passing it "
121 "to COLAMDOrdering");
123 StorageIndex m = StorageIndex(mat.rows());
124 StorageIndex n = StorageIndex(mat.cols());
125 StorageIndex nnz = StorageIndex(mat.nonZeros());
127 StorageIndex Alen = internal::Colamd::recommended(nnz, m, n);
129 double knobs[internal::Colamd::NKnobs];
130 StorageIndex stats[internal::Colamd::NStats];
131 internal::Colamd::set_defaults(knobs);
134 for (StorageIndex i = 0; i <= n; i++) p(i) = mat.outerIndexPtr()[i];
135 for (StorageIndex i = 0; i < nnz; i++) A(i) = mat.innerIndexPtr()[i];
137 StorageIndex info = internal::Colamd::compute_ordering(m, n, Alen, A.
data(), p.data(), knobs, stats);
138 EIGEN_UNUSED_VARIABLE(info);
139 eigen_assert(info &&
"COLAMD failed ");
142 for (StorageIndex i = 0; i < n; i++) perm.
indices()(p(i)) = i;
void operator()(const SparseSelfAdjointView< SrcType, SrcUpLo > &mat, PermutationType &perm)
Definition Ordering.h:70
void operator()(const MatrixType &mat, PermutationType &perm)
Definition Ordering.h:58
Definition Ordering.h:109
void operator()(const MatrixType &mat, PermutationType &perm)
Definition Ordering.h:118
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:186
void operator()(const MatrixType &, PermutationType &perm)
Definition Ordering.h:95
void resize(Index newSize)
Definition PermutationMatrix.h:119
Permutation matrix.
Definition PermutationMatrix.h:280
const IndicesType & indices() const
Definition PermutationMatrix.h:334
const Scalar * data() const
Definition PlainObjectBase.h:273
A versatible sparse matrix representation.
Definition SparseUtil.h:47
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
Definition SparseUtil.h:52
Namespace containing all symbols from the Eigen library.
Definition Core:137