xref: /aosp_15_r20/external/eigen/Eigen/src/SparseLU/SparseLUImpl.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 #ifndef SPARSELU_IMPL_H
10*bf2c3715SXin Li #define SPARSELU_IMPL_H
11*bf2c3715SXin Li 
12*bf2c3715SXin Li namespace Eigen {
13*bf2c3715SXin Li namespace internal {
14*bf2c3715SXin Li 
15*bf2c3715SXin Li /** \ingroup SparseLU_Module
16*bf2c3715SXin Li   * \class SparseLUImpl
17*bf2c3715SXin Li   * Base class for sparseLU
18*bf2c3715SXin Li   */
19*bf2c3715SXin Li template <typename Scalar, typename StorageIndex>
20*bf2c3715SXin Li class SparseLUImpl
21*bf2c3715SXin Li {
22*bf2c3715SXin Li   public:
23*bf2c3715SXin Li     typedef Matrix<Scalar,Dynamic,1> ScalarVector;
24*bf2c3715SXin Li     typedef Matrix<StorageIndex,Dynamic,1> IndexVector;
25*bf2c3715SXin Li     typedef Matrix<Scalar,Dynamic,Dynamic,ColMajor> ScalarMatrix;
26*bf2c3715SXin Li     typedef Map<ScalarMatrix, 0,  OuterStride<> > MappedMatrixBlock;
27*bf2c3715SXin Li     typedef typename ScalarVector::RealScalar RealScalar;
28*bf2c3715SXin Li     typedef Ref<Matrix<Scalar,Dynamic,1> > BlockScalarVector;
29*bf2c3715SXin Li     typedef Ref<Matrix<StorageIndex,Dynamic,1> > BlockIndexVector;
30*bf2c3715SXin Li     typedef LU_GlobalLU_t<IndexVector, ScalarVector> GlobalLU_t;
31*bf2c3715SXin Li     typedef SparseMatrix<Scalar,ColMajor,StorageIndex> MatrixType;
32*bf2c3715SXin Li 
33*bf2c3715SXin Li   protected:
34*bf2c3715SXin Li      template <typename VectorType>
35*bf2c3715SXin Li      Index expand(VectorType& vec, Index& length, Index nbElts, Index keep_prev, Index& num_expansions);
36*bf2c3715SXin Li      Index memInit(Index m, Index n, Index annz, Index lwork, Index fillratio, Index panel_size,  GlobalLU_t& glu);
37*bf2c3715SXin Li      template <typename VectorType>
38*bf2c3715SXin Li      Index memXpand(VectorType& vec, Index& maxlen, Index nbElts, MemType memtype, Index& num_expansions);
39*bf2c3715SXin Li      void heap_relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end);
40*bf2c3715SXin Li      void relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end);
41*bf2c3715SXin Li      Index snode_dfs(const Index jcol, const Index kcol,const MatrixType& mat,  IndexVector& xprune, IndexVector& marker, GlobalLU_t& glu);
42*bf2c3715SXin Li      Index snode_bmod (const Index jcol, const Index fsupc, ScalarVector& dense, GlobalLU_t& glu);
43*bf2c3715SXin Li      Index pivotL(const Index jcol, const RealScalar& diagpivotthresh, IndexVector& perm_r, IndexVector& iperm_c, Index& pivrow, GlobalLU_t& glu);
44*bf2c3715SXin Li      template <typename Traits>
45*bf2c3715SXin Li      void dfs_kernel(const StorageIndex jj, IndexVector& perm_r,
46*bf2c3715SXin Li                     Index& nseg, IndexVector& panel_lsub, IndexVector& segrep,
47*bf2c3715SXin Li                     Ref<IndexVector> repfnz_col, IndexVector& xprune, Ref<IndexVector> marker, IndexVector& parent,
48*bf2c3715SXin Li                     IndexVector& xplore, GlobalLU_t& glu, Index& nextl_col, Index krow, Traits& traits);
49*bf2c3715SXin Li      void panel_dfs(const Index m, const Index w, const Index jcol, MatrixType& A, IndexVector& perm_r, Index& nseg, ScalarVector& dense, IndexVector& panel_lsub, IndexVector& segrep, IndexVector& repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu);
50*bf2c3715SXin Li 
51*bf2c3715SXin Li      void panel_bmod(const Index m, const Index w, const Index jcol, const Index nseg, ScalarVector& dense, ScalarVector& tempv, IndexVector& segrep, IndexVector& repfnz, GlobalLU_t& glu);
52*bf2c3715SXin Li      Index column_dfs(const Index m, const Index jcol, IndexVector& perm_r, Index maxsuper, Index& nseg,  BlockIndexVector lsub_col, IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu);
53*bf2c3715SXin Li      Index column_bmod(const Index jcol, const Index nseg, BlockScalarVector dense, ScalarVector& tempv, BlockIndexVector segrep, BlockIndexVector repfnz, Index fpanelc, GlobalLU_t& glu);
54*bf2c3715SXin Li      Index copy_to_ucol(const Index jcol, const Index nseg, IndexVector& segrep, BlockIndexVector repfnz ,IndexVector& perm_r, BlockScalarVector dense, GlobalLU_t& glu);
55*bf2c3715SXin Li      void pruneL(const Index jcol, const IndexVector& perm_r, const Index pivrow, const Index nseg, const IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune, GlobalLU_t& glu);
56*bf2c3715SXin Li      void countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu);
57*bf2c3715SXin Li      void fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu);
58*bf2c3715SXin Li 
59*bf2c3715SXin Li      template<typename , typename >
60*bf2c3715SXin Li      friend struct column_dfs_traits;
61*bf2c3715SXin Li };
62*bf2c3715SXin Li 
63*bf2c3715SXin Li } // end namespace internal
64*bf2c3715SXin Li } // namespace Eigen
65*bf2c3715SXin Li 
66*bf2c3715SXin Li #endif
67