30 #ifndef SPARSE_COLETREE_H
31 #define SPARSE_COLETREE_H
41 template <
typename Index,
typename IndexVector>
60 template <
typename MatrixType,
typename IndexVector>
62 typename MatrixType::StorageIndex* perm = 0) {
63 typedef typename MatrixType::StorageIndex StorageIndex;
64 StorageIndex nc = convert_index<StorageIndex>(
mat.
cols());
65 StorageIndex
m = convert_index<StorageIndex>(
mat.
rows());
66 StorageIndex diagSize = (
std::min)(nc,
m);
73 firstRowElt.resize(
m);
74 firstRowElt.setConstant(nc);
75 firstRowElt.segment(0, diagSize).setLinSpaced(diagSize, 0, diagSize - 1);
77 for (StorageIndex
col = 0;
col < nc;
col++) {
78 StorageIndex pcol =
col;
79 if (perm) pcol = perm[
col];
80 for (
typename MatrixType::InnerIterator it(
mat, pcol); it; ++it) {
89 StorageIndex rset, cset, rroot;
90 for (StorageIndex
col = 0;
col < nc;
col++) {
91 found_diag =
col >=
m;
98 StorageIndex pcol =
col;
99 if (perm) pcol = perm[
col];
100 for (
typename MatrixType::InnerIterator it(
mat, pcol); it || !found_diag;
103 if (it)
i = it.index();
104 if (
i ==
col) found_diag =
true;
106 StorageIndex
row = firstRowElt(
i);
125 template <
typename IndexVector>
129 StorageIndex current =
n, first, next;
130 while (postnum !=
n) {
132 first = first_kid(current);
137 post(current) = postnum++;
140 next = next_kid(current);
143 current = parent(current);
145 post(current) = postnum++;
148 next = next_kid(current);
151 if (postnum ==
n + 1)
return;
167 template <
typename IndexVector>
170 IndexVector first_kid, next_kid;
171 StorageIndex postnum;
173 first_kid.resize(
n + 1);
174 next_kid.setZero(
n + 1);
178 first_kid.setConstant(-1);
179 for (StorageIndex
v =
n - 1;
v >= 0;
v--) {
180 StorageIndex dad = parent(
v);
181 next_kid(
v) = first_kid(dad);
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
float * p
Definition: Tutorial_Map_using.cpp:9
SCALAR Scalar
Definition: bench_gemm.cpp:45
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
Index cols() const
Definition: SparseMatrix.h:161
Index rows() const
Definition: SparseMatrix.h:159
#define min(a, b)
Definition: datatypes.h:22
int * m
Definition: level2_cplx_impl.h:294
int coletree(const MatrixType &mat, IndexVector &parent, IndexVector &firstRowElt, typename MatrixType::StorageIndex *perm=0)
Definition: SparseColEtree.h:61
void treePostorder(typename IndexVector::Scalar n, IndexVector &parent, IndexVector &post)
Post order a tree.
Definition: SparseColEtree.h:168
void nr_etdfs(typename IndexVector::Scalar n, IndexVector &parent, IndexVector &first_kid, IndexVector &next_kid, IndexVector &post, typename IndexVector::Scalar postnum)
Definition: SparseColEtree.h:126
Index etree_find(Index i, IndexVector &pp)
Definition: SparseColEtree.h:42
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
Definition: Eigen_Colamd.h:49