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 
11 #ifndef EIGEN_SPARSELU_UTILS_H
12 #define EIGEN_SPARSELU_UTILS_H
13 
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 namespace internal {
18 
22 template <typename Scalar, typename StorageIndex>
23 void SparseLUImpl<Scalar,StorageIndex>::countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu)
24 {
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  {
34  fsupc = glu.xsup(i);
35  jlen = glu.xlsub(fsupc+1) - glu.xlsub(fsupc);
36 
37  for (j = fsupc; j < glu.xsup(i+1); j++)
38  {
39  nnzL += jlen;
40  nnzU += j - fsupc + 1;
41  jlen--;
42  }
43  }
44 }
45 
53 template <typename Scalar, typename StorageIndex>
54 void SparseLUImpl<Scalar,StorageIndex>::fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu)
55 {
56  Index fsupc, i, j, k, jstart;
57 
58  StorageIndex nextl = 0;
59  Index nsuper = (glu.supno)(n);
60 
61  // For each supernode
62  for (i = 0; i <= nsuper; i++)
63  {
64  fsupc = glu.xsup(i);
65  jstart = glu.xlsub(fsupc);
66  glu.xlsub(fsupc) = nextl;
67  for (j = jstart; j < glu.xlsub(fsupc + 1); j++)
68  {
69  glu.lsub(nextl) = perm_r(glu.lsub(j)); // Now indexed into P*A
70  nextl++;
71  }
72  for (k = fsupc+1; k < glu.xsup(i+1); k++)
73  glu.xlsub(k) = nextl; // other columns in supernode i
74  }
75 
76  glu.xlsub(n) = nextl;
77 }
78 
79 } // end namespace internal
80 
81 } // end namespace Eigen
82 #endif // EIGEN_SPARSELU_UTILS_H
int n
: InteropHeaders
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
std::ptrdiff_t j