Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
SparseLU_relax_snode.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2012 Désiré Nuentsa-Wakam <[email protected]>
5//
6// This Source Code Form is subject to the terms of the Mozilla
7// Public License v. 2.0. If a copy of the MPL was not distributed
8// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10/* This file is a modified version of heap_relax_snode.c file in SuperLU
11 * -- SuperLU routine (version 3.0) --
12 * Univ. of California Berkeley, Xerox Palo Alto Research Center,
13 * and Lawrence Berkeley National Lab.
14 * October 15, 2003
15 *
16 * Copyright (c) 1994 by Xerox Corporation. All rights reserved.
17 *
18 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
19 * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
20 *
21 * Permission is hereby granted to use or copy this program for any
22 * purpose, provided the above notices are retained on all copies.
23 * Permission to modify the code and to distribute modified code is
24 * granted, provided the above notices are retained, and a notice that
25 * the code was modified is included with the above copyright notice.
26 */
27
28#ifndef SPARSELU_RELAX_SNODE_H
29#define SPARSELU_RELAX_SNODE_H
30
31// IWYU pragma: private
32#include "./InternalHeaderCheck.h"
33
34namespace Eigen {
35
36namespace internal {
37
49template <typename Scalar, typename StorageIndex>
50void SparseLUImpl<Scalar, StorageIndex>::relax_snode(const Index n, IndexVector& et, const Index relax_columns,
51 IndexVector& descendants, IndexVector& relax_end) {
52 // compute the number of descendants of each node in the etree
53 Index parent;
54 relax_end.setConstant(emptyIdxLU);
55 descendants.setZero();
56 for (Index j = 0; j < n; j++) {
57 parent = et(j);
58 if (parent != n) // not the dummy root
59 descendants(parent) += descendants(j) + 1;
60 }
61 // Identify the relaxed supernodes by postorder traversal of the etree
62 Index snode_start; // beginning of a snode
63 for (Index j = 0; j < n;) {
64 parent = et(j);
65 snode_start = j;
66 while (parent != n && descendants(parent) < relax_columns) {
67 j = parent;
68 parent = et(j);
69 }
70 // Found a supernode in postordered etree, j is the last column
71 relax_end(snode_start) = StorageIndex(j); // Record last column
72 j++;
73 // Search for a new leaf
74 while (descendants(j) != 0 && j < n) j++;
75 } // End postorder traversal of the etree
76}
77
78} // end namespace internal
79
80} // end namespace Eigen
81#endif
Namespace containing all symbols from the Eigen library.
Definition Core:137