Eigen::internal::simpl_chol_helper< Scalar, StorageIndex > Struct Template Reference

#include <SimplicialCholesky_impl.h>

Classes

struct  DisjointSet
 
struct  Stack
 

Public Types

using CholMatrixType = SparseMatrix< Scalar, ColMajor, StorageIndex >
 
using InnerIterator = typename CholMatrixType::InnerIterator
 
using VectorI = Matrix< StorageIndex, Dynamic, 1 >
 

Static Public Member Functions

static void calc_hadj_outer (const StorageIndex size, const CholMatrixType &ap, StorageIndex *outerIndex)
 
static void calc_hadj_inner (const StorageIndex size, const CholMatrixType &ap, const StorageIndex *outerIndex, StorageIndex *innerIndex, StorageIndex *tmp)
 
static void calc_etree (const StorageIndex size, const CholMatrixType &ap, StorageIndex *parent, StorageIndex *tmp)
 
static void calc_lineage (const StorageIndex size, const StorageIndex *parent, StorageIndex *firstChild, StorageIndex *firstSibling)
 
static void calc_post (const StorageIndex size, const StorageIndex *parent, StorageIndex *firstChild, const StorageIndex *firstSibling, StorageIndex *post, StorageIndex *dfs)
 
static void calc_colcount (const StorageIndex size, const StorageIndex *hadjOuter, const StorageIndex *hadjInner, const StorageIndex *parent, StorageIndex *prevLeaf, StorageIndex *tmp, const StorageIndex *post, StorageIndex *nonZerosPerCol, bool doLDLT)
 
static void init_matrix (const StorageIndex size, const StorageIndex *nonZerosPerCol, CholMatrixType &L)
 
static void run (const StorageIndex size, const CholMatrixType &ap, CholMatrixType &L, VectorI &parent, VectorI &workSpace, bool doLDLT)
 

Static Public Attributes

static constexpr StorageIndex kEmpty = -1
 

Member Typedef Documentation

◆ CholMatrixType

template<typename Scalar , typename StorageIndex >
using Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::CholMatrixType = SparseMatrix<Scalar, ColMajor, StorageIndex>

◆ InnerIterator

template<typename Scalar , typename StorageIndex >
using Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::InnerIterator = typename CholMatrixType::InnerIterator

◆ VectorI

template<typename Scalar , typename StorageIndex >
using Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::VectorI = Matrix<StorageIndex, Dynamic, 1>

Member Function Documentation

◆ calc_colcount()

template<typename Scalar , typename StorageIndex >
static void Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::calc_colcount ( const StorageIndex  size,
const StorageIndex *  hadjOuter,
const StorageIndex *  hadjInner,
const StorageIndex *  parent,
StorageIndex *  prevLeaf,
StorageIndex *  tmp,
const StorageIndex *  post,
StorageIndex *  nonZerosPerCol,
bool  doLDLT 
)
inlinestatic
205  {
206  // initialize nonZerosPerCol with 1 for leaves, 0 for non-leaves
207  std::fill_n(nonZerosPerCol, size, 1);
208  for (StorageIndex j = 0; j < size; j++) {
209  StorageIndex p = parent[j];
210  // p is not a leaf
211  if (p != kEmpty) nonZerosPerCol[p] = 0;
212  }
213 
214  DisjointSet parentSet(tmp, size);
215  // prevLeaf is already initialized
216  eigen_assert(std::all_of(prevLeaf, prevLeaf + size, [](StorageIndex a) { return a == kEmpty; }));
217 
218  for (StorageIndex j_ = 0; j_ < size; j_++) {
219  StorageIndex j = post[j_];
220  nonZerosPerCol[j] += hadjOuter[j + 1] - hadjOuter[j];
221  for (StorageIndex k = hadjOuter[j]; k < hadjOuter[j + 1]; k++) {
222  StorageIndex i = hadjInner[k];
223  eigen_assert(i > j);
224  StorageIndex prev = prevLeaf[i];
225  if (prev != kEmpty) {
226  StorageIndex q = parentSet.find(prev);
227  parentSet.compress(prev, q);
228  nonZerosPerCol[q]--;
229  }
230  prevLeaf[i] = j;
231  }
232  StorageIndex p = parent[j];
233  if (p != kEmpty) parentSet.compress(j, p);
234  }
235 
236  for (StorageIndex j = 0; j < size; j++) {
237  StorageIndex p = parent[j];
238  if (p != kEmpty) nonZerosPerCol[p] += nonZerosPerCol[j] - 1;
239  if (doLDLT) nonZerosPerCol[j]--;
240  }
241  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
#define eigen_assert(x)
Definition: Macros.h:910
float * p
Definition: Tutorial_Map_using.cpp:9
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
const Scalar * a
Definition: level2_cplx_impl.h:32
char char char int int * k
Definition: level2_impl.h:374
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365
EIGEN_DEVICE_FUNC const Scalar & q
Definition: SpecialFunctionsImpl.h:2019
static constexpr StorageIndex kEmpty
Definition: SimplicialCholesky_impl.h:35
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References j, Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::kEmpty, p, and size.

Referenced by Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::run().

◆ calc_etree()

template<typename Scalar , typename StorageIndex >
static void Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::calc_etree ( const StorageIndex  size,
const CholMatrixType ap,
StorageIndex *  parent,
StorageIndex *  tmp 
)
inlinestatic
135  {
136  std::fill_n(parent, size, kEmpty);
137 
138  DisjointSet ancestor(tmp, size);
139 
140  for (StorageIndex j = 1; j < size; j++) {
141  for (InnerIterator it(ap, j); it; ++it) {
142  StorageIndex i = it.index();
143  if (i < j) {
144  StorageIndex r = ancestor.find(i);
145  if (r != j) parent[r] = j;
146  ancestor.compress(i, j);
147  }
148  }
149  }
150  }
Scalar * ap
Definition: level2_cplx_impl.h:161
r
Definition: UniformPSDSelfTest.py:20
typename CholMatrixType::InnerIterator InnerIterator
Definition: SimplicialCholesky_impl.h:33

References ap, Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::DisjointSet::compress(), Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::DisjointSet::find(), i, j, Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::kEmpty, UniformPSDSelfTest::r, size, and tmp.

Referenced by Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::run().

◆ calc_hadj_inner()

template<typename Scalar , typename StorageIndex >
static void Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::calc_hadj_inner ( const StorageIndex  size,
const CholMatrixType ap,
const StorageIndex *  outerIndex,
StorageIndex *  innerIndex,
StorageIndex *  tmp 
)
inlinestatic
112  {
113  std::fill_n(tmp, size, 0);
114 
115  for (StorageIndex j = 1; j < size; j++) {
116  for (InnerIterator it(ap, j); it; ++it) {
117  StorageIndex i = it.index();
118  if (i < j) {
119  StorageIndex b = outerIndex[i] + tmp[i];
120  innerIndex[b] = j;
121  tmp[i]++;
122  }
123  }
124  }
125  }
Scalar * b
Definition: benchVecAdd.cpp:17

References ap, b, i, j, size, and tmp.

Referenced by Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::run().

◆ calc_hadj_outer()

template<typename Scalar , typename StorageIndex >
static void Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::calc_hadj_outer ( const StorageIndex  size,
const CholMatrixType ap,
StorageIndex *  outerIndex 
)
inlinestatic
100  {
101  for (StorageIndex j = 1; j < size; j++) {
102  for (InnerIterator it(ap, j); it; ++it) {
103  StorageIndex i = it.index();
104  if (i < j) outerIndex[i + 1]++;
105  }
106  }
107  std::partial_sum(outerIndex, outerIndex + size + 1, outerIndex);
108  }

References ap, i, j, and size.

Referenced by Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::run().

◆ calc_lineage()

template<typename Scalar , typename StorageIndex >
static void Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::calc_lineage ( const StorageIndex  size,
const StorageIndex *  parent,
StorageIndex *  firstChild,
StorageIndex *  firstSibling 
)
inlinestatic
154  {
155  std::fill_n(firstChild, size, kEmpty);
156  std::fill_n(firstSibling, size, kEmpty);
157 
158  for (StorageIndex j = 0; j < size; j++) {
159  StorageIndex p = parent[j];
160  if (p == kEmpty) continue;
161  StorageIndex c = firstChild[p];
162  if (c == kEmpty)
163  firstChild[p] = j;
164  else {
165  while (firstSibling[c] != kEmpty) c = firstSibling[c];
166  firstSibling[c] = j;
167  }
168  }
169  }
int c
Definition: calibrate.py:100

References calibrate::c, j, Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::kEmpty, p, and size.

Referenced by Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::run().

◆ calc_post()

template<typename Scalar , typename StorageIndex >
static void Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::calc_post ( const StorageIndex  size,
const StorageIndex *  parent,
StorageIndex *  firstChild,
const StorageIndex *  firstSibling,
StorageIndex *  post,
StorageIndex *  dfs 
)
inlinestatic
173  {
174  Stack post_stack(post, 0, size);
175  for (StorageIndex j = 0; j < size; j++) {
176  if (parent[j] != kEmpty) continue;
177  // Begin at a root
178  Stack dfs_stack(dfs, 0, size);
179  dfs_stack.push(j);
180  while (!dfs_stack.empty()) {
181  StorageIndex i = dfs_stack.back();
182  StorageIndex c = firstChild[i];
183  if (c == kEmpty) {
184  post_stack.push(i);
185  dfs_stack.pop();
186  } else {
187  dfs_stack.push(c);
188  // Remove the path from `i` to `c` for future traversals.
189  firstChild[i] = firstSibling[c];
190  }
191  }
192  }
193  eigen_assert(post_stack.size() == size);
194  eigen_assert(std::all_of(firstChild, firstChild + size, [](StorageIndex a) { return a == kEmpty; }));
195  }
void dfs(Node *node_pt, Node *parent_node_pt, std::map< Node *, Vector< std::pair< NodeNodeConstraintElementType *, Node * >>> &tree, std::map< Node *, Colour > &colours, Vector< NodeNodeConstraintElementType * > &pruned_branches)
Definition: mortaring_helpers.h:320

References a, Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::Stack::back(), calibrate::c, MortaringHelpers::dfs(), eigen_assert, Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::Stack::empty(), i, j, Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::kEmpty, Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::Stack::pop(), Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::Stack::push(), size, and Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::Stack::size().

Referenced by Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::run().

◆ init_matrix()

template<typename Scalar , typename StorageIndex >
static void Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::init_matrix ( const StorageIndex  size,
const StorageIndex *  nonZerosPerCol,
CholMatrixType L 
)
inlinestatic
244  {
245  eigen_assert(L.outerIndexPtr()[0] == 0);
246  std::partial_sum(nonZerosPerCol, nonZerosPerCol + size, L.outerIndexPtr() + 1);
247  L.resizeNonZeros(L.outerIndexPtr()[size]);
248  }
MatrixXd L
Definition: LLT_example.cpp:6

References eigen_assert, L, and size.

Referenced by Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::run().

◆ run()

template<typename Scalar , typename StorageIndex >
static void Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::run ( const StorageIndex  size,
const CholMatrixType ap,
CholMatrixType L,
VectorI parent,
VectorI workSpace,
bool  doLDLT 
)
inlinestatic
252  {
253  parent.resize(size);
254  workSpace.resize(4 * size);
255  L.resize(size, size);
256 
257  StorageIndex* tmp1 = workSpace.data();
258  StorageIndex* tmp2 = workSpace.data() + size;
259  StorageIndex* tmp3 = workSpace.data() + 2 * size;
260  StorageIndex* tmp4 = workSpace.data() + 3 * size;
261 
262  // Borrow L's outer index array for the higher adjacency pattern.
263  StorageIndex* hadj_outer = L.outerIndexPtr();
264  calc_hadj_outer(size, ap, hadj_outer);
265  // Request additional temporary storage for the inner indices of the higher adjacency pattern.
266  ei_declare_aligned_stack_constructed_variable(StorageIndex, hadj_inner, hadj_outer[size], nullptr);
267  calc_hadj_inner(size, ap, hadj_outer, hadj_inner, tmp1);
268 
269  calc_etree(size, ap, parent.data(), tmp1);
270  calc_lineage(size, parent.data(), tmp1, tmp2);
271  calc_post(size, parent.data(), tmp1, tmp2, tmp3, tmp4);
272  calc_colcount(size, hadj_outer, hadj_inner, parent.data(), tmp1, tmp2, tmp3, tmp4, doLDLT);
273  init_matrix(size, tmp4, L);
274  }
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
Definition: Memory.h:806
static void calc_hadj_outer(const StorageIndex size, const CholMatrixType &ap, StorageIndex *outerIndex)
Definition: SimplicialCholesky_impl.h:100
static void calc_etree(const StorageIndex size, const CholMatrixType &ap, StorageIndex *parent, StorageIndex *tmp)
Definition: SimplicialCholesky_impl.h:135
static void calc_colcount(const StorageIndex size, const StorageIndex *hadjOuter, const StorageIndex *hadjInner, const StorageIndex *parent, StorageIndex *prevLeaf, StorageIndex *tmp, const StorageIndex *post, StorageIndex *nonZerosPerCol, bool doLDLT)
Definition: SimplicialCholesky_impl.h:203
static void init_matrix(const StorageIndex size, const StorageIndex *nonZerosPerCol, CholMatrixType &L)
Definition: SimplicialCholesky_impl.h:244
static void calc_hadj_inner(const StorageIndex size, const CholMatrixType &ap, const StorageIndex *outerIndex, StorageIndex *innerIndex, StorageIndex *tmp)
Definition: SimplicialCholesky_impl.h:111
static void calc_post(const StorageIndex size, const StorageIndex *parent, StorageIndex *firstChild, const StorageIndex *firstSibling, StorageIndex *post, StorageIndex *dfs)
Definition: SimplicialCholesky_impl.h:172
static void calc_lineage(const StorageIndex size, const StorageIndex *parent, StorageIndex *firstChild, StorageIndex *firstSibling)
Definition: SimplicialCholesky_impl.h:153

References ap, Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::calc_colcount(), Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::calc_etree(), Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::calc_hadj_inner(), Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::calc_hadj_outer(), Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::calc_lineage(), Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::calc_post(), Eigen::PlainObjectBase< Derived >::data(), ei_declare_aligned_stack_constructed_variable, Eigen::internal::simpl_chol_helper< Scalar, StorageIndex >::init_matrix(), L, Eigen::PlainObjectBase< Derived >::resize(), and size.

Member Data Documentation

◆ kEmpty


The documentation for this struct was generated from the following file: