Eigen  5.0.1
 
Loading...
Searching...
No Matches
SparseLU_Utils.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 <desire.nuentsa_wakam@inria.fr>
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// SPDX-License-Identifier: MPL-2.0
10
11#ifndef EIGEN_SPARSELU_UTILS_H
12#define EIGEN_SPARSELU_UTILS_H
13
14// IWYU pragma: private
15#include "./InternalHeaderCheck.h"
16
17namespace Eigen {
18namespace internal {
19
23template <typename Scalar, typename StorageIndex>
24void SparseLUImpl<Scalar, StorageIndex>::countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu) {
25 nnzL = 0;
26 nnzU = glu.xusub(n);
27 Index nsuper = glu.supno(n);
28 Index jlen;
29 Index i, j, fsupc;
30 if (n <= 0) return;
31 // For each supernode
32 for (i = 0; i <= nsuper; i++) {
33 fsupc = glu.xsup(i);
34 jlen = glu.xlsub(fsupc + 1) - glu.xlsub(fsupc);
35
36 for (j = fsupc; j < glu.xsup(i + 1); j++) {
37 nnzL += jlen;
38 nnzU += j - fsupc + 1;
39 jlen--;
40 }
41 }
42}
43
51template <typename Scalar, typename StorageIndex>
52void SparseLUImpl<Scalar, StorageIndex>::fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu) {
53 Index fsupc, i, j, k, jstart;
54
55 StorageIndex nextl = 0;
56 Index nsuper = glu.supno(n);
57
58 // For each supernode
59 for (i = 0; i <= nsuper; i++) {
60 fsupc = glu.xsup(i);
61 jstart = glu.xlsub(fsupc);
62 glu.xlsub(fsupc) = nextl;
63 for (j = jstart; j < glu.xlsub(fsupc + 1); j++) {
64 glu.lsub(nextl) = perm_r(glu.lsub(j)); // Now indexed into P*A
65 nextl++;
66 }
67 for (k = fsupc + 1; k < glu.xsup(i + 1); k++) glu.xlsub(k) = nextl; // other columns in supernode i
68 }
69
70 glu.xlsub(n) = nextl;
72
73} // end namespace internal
74
75} // end namespace Eigen
76#endif // EIGEN_SPARSELU_UTILS_H
void fixupL(const Index n, const IndexVector &perm_r, GlobalLU_t &glu)
Fix up the data storage lsub for L-subscripts.
Definition SparseLU_Utils.h:52
void countnz(const Index n, Index &nnzL, Index &nnzU, GlobalLU_t &glu)
Count Nonzero elements in the factors.
Definition SparseLU_Utils.h:24