107 void operator()(
const MatrixType& mat, PermutationType& perm)
const {
108 using MatrixStorageIndex =
typename MatrixType::StorageIndex;
110 internal::SparsityPatternRef<MatrixStorageIndex> pat =
111 internal::make_col_major_pattern_ref(mat, outer_buf, inner_buf);
112 const StorageIndex m = internal::convert_index<StorageIndex>(pat.innerSize);
113 const StorageIndex n = internal::convert_index<StorageIndex>(pat.outerSize);
119 for (Index j = 0; j < pat.outerSize; ++j) total_nnz += pat.nonZeros(j);
120 const StorageIndex nnz = internal::convert_index<StorageIndex>(total_nnz);
122 StorageIndex Alen = internal::Colamd::recommended(nnz, m, n);
123 double knobs[internal::Colamd::NKnobs];
124 StorageIndex stats[internal::Colamd::NStats];
125 internal::Colamd::set_defaults(knobs);
130 IndexVector p(n + 1), A(Alen);
132 for (StorageIndex j = 0; j < n; ++j) {
133 const Index nz = pat.nonZeros(j);
134 const MatrixStorageIndex* src = pat.inner + pat.outer[j];
135 copy_colamd_indices(src, nz, A.
data() + p(j), std::is_same<MatrixStorageIndex, StorageIndex>());
136 p(j + 1) = p(j) +
static_cast<StorageIndex
>(nz);
139 StorageIndex info = internal::Colamd::compute_ordering(m, n, Alen, A.
data(), p.data(), knobs, stats);
140 EIGEN_UNUSED_VARIABLE(info);
141 eigen_assert(info &&
"COLAMD failed");
144 for (StorageIndex i = 0; i < n; i++) perm.
indices()(p(i)) = i;
149 static void copy_colamd_indices(
const SrcStorageIndex* src, Index nz, StorageIndex* dst, std::true_type) {
154 static void copy_colamd_indices(
const SrcStorageIndex* src, Index nz, StorageIndex* dst, std::false_type) {