31 #ifndef SPARSE_COLETREE_H
32 #define SPARSE_COLETREE_H
39 template<
typename Index,
typename IndexVector>
60 template <
typename MatrixType,
typename IndexVector>
63 typedef typename MatrixType::StorageIndex StorageIndex;
64 StorageIndex
nc = convert_index<StorageIndex>(
mat.cols());
65 StorageIndex
m = convert_index<StorageIndex>(
mat.rows());
71 parent.resize(
mat.cols());
73 firstRowElt.resize(
m);
74 firstRowElt.setConstant(
nc);
75 firstRowElt.segment(0, diagSize).setLinSpaced(diagSize, 0, diagSize-1);
79 StorageIndex pcol =
col;
81 for (
typename MatrixType::InnerIterator it(
mat, pcol); it; ++it)
91 StorageIndex
rset, cset, rroot;
101 StorageIndex pcol =
col;
103 for (
typename MatrixType::InnerIterator it(
mat, pcol); it||!found_diag; ++it)
106 if(it)
i = it.index();
107 if (
i ==
col) found_diag =
true;
109 StorageIndex
row = firstRowElt(
i);
129 template <
typename IndexVector>
133 StorageIndex current =
n,
first, next;
137 first = first_kid(current);
143 post(current) = postnum++;
146 next = next_kid(current);
150 current = parent(current);
152 post(current) = postnum++;
155 next = next_kid(current);
158 if (postnum ==
n+1)
return;
177 template <
typename IndexVector>
181 IndexVector first_kid, next_kid;
182 StorageIndex postnum;
184 first_kid.resize(
n+1);
185 next_kid.setZero(
n+1);
189 first_kid.setConstant(-1);
190 for (StorageIndex
v =
n-1;
v >= 0;
v--)
192 StorageIndex dad = parent(
v);
193 next_kid(
v) = first_kid(dad);
206 #endif // SPARSE_COLETREE_H