Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:06:43

0001 // This file is part of Eigen, a lightweight C++ template library
0002 // for linear algebra.
0003 //
0004 // Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>
0005 //
0006 // This Source Code Form is subject to the terms of the Mozilla
0007 // Public License v. 2.0. If a copy of the MPL was not distributed
0008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
0009 
0010 
0011 #ifndef EIGEN_SPARSELU_UTILS_H
0012 #define EIGEN_SPARSELU_UTILS_H
0013 
0014 namespace RivetEigen {
0015 namespace internal {
0016 
0017 /**
0018  * \brief Count Nonzero elements in the factors
0019  */
0020 template <typename Scalar, typename StorageIndex>
0021 void SparseLUImpl<Scalar,StorageIndex>::countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu)
0022 {
0023  nnzL = 0; 
0024  nnzU = (glu.xusub)(n); 
0025  Index nsuper = (glu.supno)(n); 
0026  Index jlen; 
0027  Index i, j, fsupc;
0028  if (n <= 0 ) return; 
0029  // For each supernode
0030  for (i = 0; i <= nsuper; i++)
0031  {
0032    fsupc = glu.xsup(i); 
0033    jlen = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); 
0034    
0035    for (j = fsupc; j < glu.xsup(i+1); j++)
0036    {
0037      nnzL += jlen; 
0038      nnzU += j - fsupc + 1; 
0039      jlen--; 
0040    }
0041  }
0042 }
0043 
0044 /**
0045  * \brief Fix up the data storage lsub for L-subscripts. 
0046  * 
0047  * It removes the subscripts sets for structural pruning, 
0048  * and applies permutation to the remaining subscripts
0049  * 
0050  */
0051 template <typename Scalar, typename StorageIndex>
0052 void SparseLUImpl<Scalar,StorageIndex>::fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu)
0053 {
0054   Index fsupc, i, j, k, jstart; 
0055   
0056   StorageIndex nextl = 0; 
0057   Index nsuper = (glu.supno)(n); 
0058   
0059   // For each supernode 
0060   for (i = 0; i <= nsuper; i++)
0061   {
0062     fsupc = glu.xsup(i); 
0063     jstart = glu.xlsub(fsupc); 
0064     glu.xlsub(fsupc) = nextl; 
0065     for (j = jstart; j < glu.xlsub(fsupc + 1); j++)
0066     {
0067       glu.lsub(nextl) = perm_r(glu.lsub(j)); // Now indexed into P*A
0068       nextl++;
0069     }
0070     for (k = fsupc+1; k < glu.xsup(i+1); k++)
0071       glu.xlsub(k) = nextl; // other columns in supernode i
0072   }
0073   
0074   glu.xlsub(n) = nextl; 
0075 }
0076 
0077 } // end namespace internal
0078 
0079 } // end namespace RivetEigen
0080 #endif // EIGEN_SPARSELU_UTILS_H