File indexing completed on 2025-04-19 09:06:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #ifndef SPARSELU_COLUMN_DFS_H
0031 #define SPARSELU_COLUMN_DFS_H
0032
0033 template <typename Scalar, typename StorageIndex> class SparseLUImpl;
0034 namespace RivetEigen {
0035
0036 namespace internal {
0037
0038 template<typename IndexVector, typename ScalarVector>
0039 struct column_dfs_traits : no_assignment_operator
0040 {
0041 typedef typename ScalarVector::Scalar Scalar;
0042 typedef typename IndexVector::Scalar StorageIndex;
0043 column_dfs_traits(Index jcol, Index& jsuper, typename SparseLUImpl<Scalar, StorageIndex>::GlobalLU_t& glu, SparseLUImpl<Scalar, StorageIndex>& luImpl)
0044 : m_jcol(jcol), m_jsuper_ref(jsuper), m_glu(glu), m_luImpl(luImpl)
0045 {}
0046 bool update_segrep(Index , Index )
0047 {
0048 return true;
0049 }
0050 void mem_expand(IndexVector& lsub, Index& nextl, Index chmark)
0051 {
0052 if (nextl >= m_glu.nzlmax)
0053 m_luImpl.memXpand(lsub, m_glu.nzlmax, nextl, LSUB, m_glu.num_expansions);
0054 if (chmark != (m_jcol-1)) m_jsuper_ref = emptyIdxLU;
0055 }
0056 enum { ExpandMem = true };
0057
0058 Index m_jcol;
0059 Index& m_jsuper_ref;
0060 typename SparseLUImpl<Scalar, StorageIndex>::GlobalLU_t& m_glu;
0061 SparseLUImpl<Scalar, StorageIndex>& m_luImpl;
0062 };
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092 template <typename Scalar, typename StorageIndex>
0093 Index SparseLUImpl<Scalar,StorageIndex>::column_dfs(const Index m, const Index jcol, IndexVector& perm_r, Index maxsuper, Index& nseg,
0094 BlockIndexVector lsub_col, IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune,
0095 IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu)
0096 {
0097
0098 Index jsuper = glu.supno(jcol);
0099 Index nextl = glu.xlsub(jcol);
0100 VectorBlock<IndexVector> marker2(marker, 2*m, m);
0101
0102
0103 column_dfs_traits<IndexVector, ScalarVector> traits(jcol, jsuper, glu, *this);
0104
0105
0106 for (Index k = 0; ((k < m) ? lsub_col[k] != emptyIdxLU : false) ; k++)
0107 {
0108 Index krow = lsub_col(k);
0109 lsub_col(k) = emptyIdxLU;
0110 Index kmark = marker2(krow);
0111
0112
0113 if (kmark == jcol) continue;
0114
0115 dfs_kernel(StorageIndex(jcol), perm_r, nseg, glu.lsub, segrep, repfnz, xprune, marker2, parent,
0116 xplore, glu, nextl, krow, traits);
0117 }
0118
0119 Index fsupc;
0120 StorageIndex nsuper = glu.supno(jcol);
0121 StorageIndex jcolp1 = StorageIndex(jcol) + 1;
0122 Index jcolm1 = jcol - 1;
0123
0124
0125 if ( jcol == 0 )
0126 {
0127 nsuper = glu.supno(0) = 0 ;
0128 }
0129 else
0130 {
0131 fsupc = glu.xsup(nsuper);
0132 StorageIndex jptr = glu.xlsub(jcol);
0133 StorageIndex jm1ptr = glu.xlsub(jcolm1);
0134
0135
0136 if ( (nextl-jptr != jptr-jm1ptr-1) ) jsuper = emptyIdxLU;
0137
0138
0139
0140 if ( (jcol - fsupc) >= maxsuper) jsuper = emptyIdxLU;
0141
0142
0143
0144
0145
0146
0147 if (jsuper == emptyIdxLU)
0148 {
0149 if ( (fsupc < jcolm1-1) )
0150 {
0151 StorageIndex ito = glu.xlsub(fsupc+1);
0152 glu.xlsub(jcolm1) = ito;
0153 StorageIndex istop = ito + jptr - jm1ptr;
0154 xprune(jcolm1) = istop;
0155 glu.xlsub(jcol) = istop;
0156
0157 for (StorageIndex ifrom = jm1ptr; ifrom < nextl; ++ifrom, ++ito)
0158 glu.lsub(ito) = glu.lsub(ifrom);
0159 nextl = ito;
0160 }
0161 nsuper++;
0162 glu.supno(jcol) = nsuper;
0163 }
0164 }
0165
0166
0167 glu.xsup(nsuper+1) = jcolp1;
0168 glu.supno(jcolp1) = nsuper;
0169 xprune(jcol) = StorageIndex(nextl);
0170 glu.xlsub(jcolp1) = StorageIndex(nextl);
0171
0172 return 0;
0173 }
0174
0175 }
0176
0177 }
0178
0179 #endif