xref: /aosp_15_r20/external/eigen/Eigen/src/SparseLU/SparseLU_Structs.h (revision bf2c37156dfe67e5dfebd6d394bad8b2ab5804d4)
1*bf2c3715SXin Li // This file is part of Eigen, a lightweight C++ template library
2*bf2c3715SXin Li // for linear algebra.
3*bf2c3715SXin Li //
4*bf2c3715SXin Li // Copyright (C) 2012 Désiré Nuentsa-Wakam <[email protected]>
5*bf2c3715SXin Li //
6*bf2c3715SXin Li // This Source Code Form is subject to the terms of the Mozilla
7*bf2c3715SXin Li // Public License v. 2.0. If a copy of the MPL was not distributed
8*bf2c3715SXin Li // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9*bf2c3715SXin Li 
10*bf2c3715SXin Li /*
11*bf2c3715SXin Li  * NOTE: This file comes from a partly modified version of files slu_[s,d,c,z]defs.h
12*bf2c3715SXin Li  * -- SuperLU routine (version 4.1) --
13*bf2c3715SXin Li  * Univ. of California Berkeley, Xerox Palo Alto Research Center,
14*bf2c3715SXin Li  * and Lawrence Berkeley National Lab.
15*bf2c3715SXin Li  * November, 2010
16*bf2c3715SXin Li  *
17*bf2c3715SXin Li  * Global data structures used in LU factorization -
18*bf2c3715SXin Li  *
19*bf2c3715SXin Li  *   nsuper: #supernodes = nsuper + 1, numbered [0, nsuper].
20*bf2c3715SXin Li  *   (xsup,supno): supno[i] is the supernode no to which i belongs;
21*bf2c3715SXin Li  *  xsup(s) points to the beginning of the s-th supernode.
22*bf2c3715SXin Li  *  e.g.   supno 0 1 2 2 3 3 3 4 4 4 4 4   (n=12)
23*bf2c3715SXin Li  *          xsup 0 1 2 4 7 12
24*bf2c3715SXin Li  *  Note: dfs will be performed on supernode rep. relative to the new
25*bf2c3715SXin Li  *        row pivoting ordering
26*bf2c3715SXin Li  *
27*bf2c3715SXin Li  *   (xlsub,lsub): lsub[*] contains the compressed subscript of
28*bf2c3715SXin Li  *  rectangular supernodes; xlsub[j] points to the starting
29*bf2c3715SXin Li  *  location of the j-th column in lsub[*]. Note that xlsub
30*bf2c3715SXin Li  *  is indexed by column.
31*bf2c3715SXin Li  *  Storage: original row subscripts
32*bf2c3715SXin Li  *
33*bf2c3715SXin Li  *      During the course of sparse LU factorization, we also use
34*bf2c3715SXin Li  *  (xlsub,lsub) for the purpose of symmetric pruning. For each
35*bf2c3715SXin Li  *  supernode {s,s+1,...,t=s+r} with first column s and last
36*bf2c3715SXin Li  *  column t, the subscript set
37*bf2c3715SXin Li  *    lsub[j], j=xlsub[s], .., xlsub[s+1]-1
38*bf2c3715SXin Li  *  is the structure of column s (i.e. structure of this supernode).
39*bf2c3715SXin Li  *  It is used for the storage of numerical values.
40*bf2c3715SXin Li  *  Furthermore,
41*bf2c3715SXin Li  *    lsub[j], j=xlsub[t], .., xlsub[t+1]-1
42*bf2c3715SXin Li  *  is the structure of the last column t of this supernode.
43*bf2c3715SXin Li  *  It is for the purpose of symmetric pruning. Therefore, the
44*bf2c3715SXin Li  *  structural subscripts can be rearranged without making physical
45*bf2c3715SXin Li  *  interchanges among the numerical values.
46*bf2c3715SXin Li  *
47*bf2c3715SXin Li  *  However, if the supernode has only one column, then we
48*bf2c3715SXin Li  *  only keep one set of subscripts. For any subscript interchange
49*bf2c3715SXin Li  *  performed, similar interchange must be done on the numerical
50*bf2c3715SXin Li  *  values.
51*bf2c3715SXin Li  *
52*bf2c3715SXin Li  *  The last column structures (for pruning) will be removed
53*bf2c3715SXin Li  *  after the numercial LU factorization phase.
54*bf2c3715SXin Li  *
55*bf2c3715SXin Li  *   (xlusup,lusup): lusup[*] contains the numerical values of the
56*bf2c3715SXin Li  *  rectangular supernodes; xlusup[j] points to the starting
57*bf2c3715SXin Li  *  location of the j-th column in storage vector lusup[*]
58*bf2c3715SXin Li  *  Note: xlusup is indexed by column.
59*bf2c3715SXin Li  *  Each rectangular supernode is stored by column-major
60*bf2c3715SXin Li  *  scheme, consistent with Fortran 2-dim array storage.
61*bf2c3715SXin Li  *
62*bf2c3715SXin Li  *   (xusub,ucol,usub): ucol[*] stores the numerical values of
63*bf2c3715SXin Li  *  U-columns outside the rectangular supernodes. The row
64*bf2c3715SXin Li  *  subscript of nonzero ucol[k] is stored in usub[k].
65*bf2c3715SXin Li  *  xusub[i] points to the starting location of column i in ucol.
66*bf2c3715SXin Li  *  Storage: new row subscripts; that is subscripts of PA.
67*bf2c3715SXin Li  */
68*bf2c3715SXin Li 
69*bf2c3715SXin Li #ifndef EIGEN_LU_STRUCTS
70*bf2c3715SXin Li #define EIGEN_LU_STRUCTS
71*bf2c3715SXin Li namespace Eigen {
72*bf2c3715SXin Li namespace internal {
73*bf2c3715SXin Li 
74*bf2c3715SXin Li typedef enum {LUSUP, UCOL, LSUB, USUB, LLVL, ULVL} MemType;
75*bf2c3715SXin Li 
76*bf2c3715SXin Li template <typename IndexVector, typename ScalarVector>
77*bf2c3715SXin Li struct LU_GlobalLU_t {
78*bf2c3715SXin Li   typedef typename IndexVector::Scalar StorageIndex;
79*bf2c3715SXin Li   IndexVector xsup; //First supernode column ... xsup(s) points to the beginning of the s-th supernode
80*bf2c3715SXin Li   IndexVector supno; // Supernode number corresponding to this column (column to supernode mapping)
81*bf2c3715SXin Li   ScalarVector  lusup; // nonzero values of L ordered by columns
82*bf2c3715SXin Li   IndexVector lsub; // Compressed row indices of L rectangular supernodes.
83*bf2c3715SXin Li   IndexVector xlusup; // pointers to the beginning of each column in lusup
84*bf2c3715SXin Li   IndexVector xlsub; // pointers to the beginning of each column in lsub
85*bf2c3715SXin Li   Index   nzlmax; // Current max size of lsub
86*bf2c3715SXin Li   Index   nzlumax; // Current max size of lusup
87*bf2c3715SXin Li   ScalarVector  ucol; // nonzero values of U ordered by columns
88*bf2c3715SXin Li   IndexVector usub; // row indices of U columns in ucol
89*bf2c3715SXin Li   IndexVector xusub; // Pointers to the beginning of each column of U in ucol
90*bf2c3715SXin Li   Index   nzumax; // Current max size of ucol
91*bf2c3715SXin Li   Index   n; // Number of columns in the matrix
92*bf2c3715SXin Li   Index   num_expansions;
93*bf2c3715SXin Li };
94*bf2c3715SXin Li 
95*bf2c3715SXin Li // Values to set for performance
96*bf2c3715SXin Li struct perfvalues {
97*bf2c3715SXin Li   Index panel_size; // a panel consists of at most <panel_size> consecutive columns
98*bf2c3715SXin Li   Index relax; // To control degree of relaxing supernodes. If the number of nodes (columns)
99*bf2c3715SXin Li                 // in a subtree of the elimination tree is less than relax, this subtree is considered
100*bf2c3715SXin Li                 // as one supernode regardless of the row structures of those columns
101*bf2c3715SXin Li   Index maxsuper; // The maximum size for a supernode in complete LU
102*bf2c3715SXin Li   Index rowblk; // The minimum row dimension for 2-D blocking to be used;
103*bf2c3715SXin Li   Index colblk; // The minimum column dimension for 2-D blocking to be used;
104*bf2c3715SXin Li   Index fillfactor; // The estimated fills factors for L and U, compared with A
105*bf2c3715SXin Li };
106*bf2c3715SXin Li 
107*bf2c3715SXin Li } // end namespace internal
108*bf2c3715SXin Li 
109*bf2c3715SXin Li } // end namespace Eigen
110*bf2c3715SXin Li #endif // EIGEN_LU_STRUCTS
111