SparseLU_Utils.h
Go to the documentation of this file.
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 
10 #ifndef EIGEN_SPARSELU_UTILS_H
11 #define EIGEN_SPARSELU_UTILS_H
12 
13 // IWYU pragma: private
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 namespace internal {
18 
22 template <typename Scalar, typename StorageIndex>
24  nnzL = 0;
25  nnzU = (glu.xusub)(n);
26  Index nsuper = (glu.supno)(n);
27  Index jlen;
28  Index i, j, fsupc;
29  if (n <= 0) return;
30  // For each supernode
31  for (i = 0; i <= nsuper; i++) {
32  fsupc = glu.xsup(i);
33  jlen = glu.xlsub(fsupc + 1) - glu.xlsub(fsupc);
34 
35  for (j = fsupc; j < glu.xsup(i + 1); j++) {
36  nnzL += jlen;
37  nnzU += j - fsupc + 1;
38  jlen--;
39  }
40  }
41 }
42 
50 template <typename Scalar, typename StorageIndex>
52  Index fsupc, i, j, k, jstart;
53 
54  StorageIndex nextl = 0;
55  Index nsuper = (glu.supno)(n);
56 
57  // For each supernode
58  for (i = 0; i <= nsuper; i++) {
59  fsupc = glu.xsup(i);
60  jstart = glu.xlsub(fsupc);
61  glu.xlsub(fsupc) = nextl;
62  for (j = jstart; j < glu.xlsub(fsupc + 1); j++) {
63  glu.lsub(nextl) = perm_r(glu.lsub(j)); // Now indexed into P*A
64  nextl++;
65  }
66  for (k = fsupc + 1; k < glu.xsup(i + 1); k++) glu.xlsub(k) = nextl; // other columns in supernode i
67  }
68 
69  glu.xlsub(n) = nextl;
70 }
71 
72 } // end namespace internal
73 
74 } // end namespace Eigen
75 #endif // EIGEN_SPARSELU_UTILS_H
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
void countnz(const Index n, Index &nnzL, Index &nnzU, GlobalLU_t &glu)
Count Nonzero elements in the factors.
Definition: SparseLU_Utils.h:23
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:51
char char char int int * k
Definition: level2_impl.h:374
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
Definition: SparseLU_Structs.h:80
IndexVector xsup
Definition: SparseLU_Structs.h:82
IndexVector supno
Definition: SparseLU_Structs.h:83
IndexVector lsub
Definition: SparseLU_Structs.h:85
IndexVector xusub
Definition: SparseLU_Structs.h:92
IndexVector xlsub
Definition: SparseLU_Structs.h:87
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2