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
0031 #ifndef SPARSELU_COLUMN_BMOD_H
0032 #define SPARSELU_COLUMN_BMOD_H
0033
0034 namespace RivetEigen {
0035
0036 namespace internal {
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 template <typename Scalar, typename StorageIndex>
0053 Index SparseLUImpl<Scalar,StorageIndex>::column_bmod(const Index jcol, const Index nseg, BlockScalarVector dense, ScalarVector& tempv,
0054 BlockIndexVector segrep, BlockIndexVector repfnz, Index fpanelc, GlobalLU_t& glu)
0055 {
0056 Index jsupno, k, ksub, krep, ksupno;
0057 Index lptr, nrow, isub, irow, nextlu, new_next, ufirst;
0058 Index fsupc, nsupc, nsupr, luptr, kfnz, no_zeros;
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 jsupno = glu.supno(jcol);
0069
0070 k = nseg - 1;
0071 Index d_fsupc;
0072
0073 Index fst_col;
0074 Index segsize;
0075 for (ksub = 0; ksub < nseg; ksub++)
0076 {
0077 krep = segrep(k); k--;
0078 ksupno = glu.supno(krep);
0079 if (jsupno != ksupno )
0080 {
0081
0082 fsupc = glu.xsup(ksupno);
0083 fst_col = (std::max)(fsupc, fpanelc);
0084
0085
0086
0087 d_fsupc = fst_col - fsupc;
0088
0089 luptr = glu.xlusup(fst_col) + d_fsupc;
0090 lptr = glu.xlsub(fsupc) + d_fsupc;
0091
0092 kfnz = repfnz(krep);
0093 kfnz = (std::max)(kfnz, fpanelc);
0094
0095 segsize = krep - kfnz + 1;
0096 nsupc = krep - fst_col + 1;
0097 nsupr = glu.xlsub(fsupc+1) - glu.xlsub(fsupc);
0098 nrow = nsupr - d_fsupc - nsupc;
0099 Index lda = glu.xlusup(fst_col+1) - glu.xlusup(fst_col);
0100
0101
0102
0103
0104 no_zeros = kfnz - fst_col;
0105 if(segsize==1)
0106 LU_kernel_bmod<1>::run(segsize, dense, tempv, glu.lusup, luptr, lda, nrow, glu.lsub, lptr, no_zeros);
0107 else
0108 LU_kernel_bmod<Dynamic>::run(segsize, dense, tempv, glu.lusup, luptr, lda, nrow, glu.lsub, lptr, no_zeros);
0109 }
0110 }
0111
0112
0113 nextlu = glu.xlusup(jcol);
0114 fsupc = glu.xsup(jsupno);
0115
0116
0117 Index mem;
0118 new_next = nextlu + glu.xlsub(fsupc + 1) - glu.xlsub(fsupc);
0119 Index offset = internal::first_multiple<Index>(new_next, internal::packet_traits<Scalar>::size) - new_next;
0120 if(offset)
0121 new_next += offset;
0122 while (new_next > glu.nzlumax )
0123 {
0124 mem = memXpand<ScalarVector>(glu.lusup, glu.nzlumax, nextlu, LUSUP, glu.num_expansions);
0125 if (mem) return mem;
0126 }
0127
0128 for (isub = glu.xlsub(fsupc); isub < glu.xlsub(fsupc+1); isub++)
0129 {
0130 irow = glu.lsub(isub);
0131 glu.lusup(nextlu) = dense(irow);
0132 dense(irow) = Scalar(0.0);
0133 ++nextlu;
0134 }
0135
0136 if(offset)
0137 {
0138 glu.lusup.segment(nextlu,offset).setZero();
0139 nextlu += offset;
0140 }
0141 glu.xlusup(jcol + 1) = StorageIndex(nextlu);
0142
0143
0144
0145
0146
0147
0148
0149 fst_col = (std::max)(fsupc, fpanelc);
0150
0151 if (fst_col < jcol)
0152 {
0153
0154
0155 d_fsupc = fst_col - fsupc;
0156
0157 lptr = glu.xlsub(fsupc) + d_fsupc;
0158 luptr = glu.xlusup(fst_col) + d_fsupc;
0159 nsupr = glu.xlsub(fsupc+1) - glu.xlsub(fsupc);
0160 nsupc = jcol - fst_col;
0161 nrow = nsupr - d_fsupc - nsupc;
0162
0163
0164 ufirst = glu.xlusup(jcol) + d_fsupc;
0165 Index lda = glu.xlusup(jcol+1) - glu.xlusup(jcol);
0166 MappedMatrixBlock A( &(glu.lusup.data()[luptr]), nsupc, nsupc, OuterStride<>(lda) );
0167 VectorBlock<ScalarVector> u(glu.lusup, ufirst, nsupc);
0168 u = A.template triangularView<UnitLower>().solve(u);
0169
0170 new (&A) MappedMatrixBlock ( &(glu.lusup.data()[luptr+nsupc]), nrow, nsupc, OuterStride<>(lda) );
0171 VectorBlock<ScalarVector> l(glu.lusup, ufirst+nsupc, nrow);
0172 l.noalias() -= A * u;
0173
0174 }
0175 return 0;
0176 }
0177
0178 }
0179 }
0180
0181 #endif