00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef SPARSELU_COLUMN_BMOD_H
00032 #define SPARSELU_COLUMN_BMOD_H
00033
00034 namespace Eigen {
00035
00036 namespace internal {
00052 template <typename Scalar, typename Index>
00053 Index SparseLUImpl<Scalar,Index>::column_bmod(const Index jcol, const Index nseg, BlockScalarVector dense, ScalarVector& tempv, BlockIndexVector segrep, BlockIndexVector repfnz, Index fpanelc, GlobalLU_t& glu)
00054 {
00055 Index jsupno, k, ksub, krep, ksupno;
00056 Index lptr, nrow, isub, irow, nextlu, new_next, ufirst;
00057 Index fsupc, nsupc, nsupr, luptr, kfnz, no_zeros;
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 jsupno = glu.supno(jcol);
00068
00069 k = nseg - 1;
00070 Index d_fsupc;
00071
00072 Index fst_col;
00073 Index segsize;
00074 for (ksub = 0; ksub < nseg; ksub++)
00075 {
00076 krep = segrep(k); k--;
00077 ksupno = glu.supno(krep);
00078 if (jsupno != ksupno )
00079 {
00080
00081 fsupc = glu.xsup(ksupno);
00082 fst_col = (std::max)(fsupc, fpanelc);
00083
00084
00085
00086 d_fsupc = fst_col - fsupc;
00087
00088 luptr = glu.xlusup(fst_col) + d_fsupc;
00089 lptr = glu.xlsub(fsupc) + d_fsupc;
00090
00091 kfnz = repfnz(krep);
00092 kfnz = (std::max)(kfnz, fpanelc);
00093
00094 segsize = krep - kfnz + 1;
00095 nsupc = krep - fst_col + 1;
00096 nsupr = glu.xlsub(fsupc+1) - glu.xlsub(fsupc);
00097 nrow = nsupr - d_fsupc - nsupc;
00098 Index lda = glu.xlusup(fst_col+1) - glu.xlusup(fst_col);
00099
00100
00101
00102
00103 no_zeros = kfnz - fst_col;
00104 if(segsize==1)
00105 LU_kernel_bmod<1>::run(segsize, dense, tempv, glu.lusup, luptr, lda, nrow, glu.lsub, lptr, no_zeros);
00106 else
00107 LU_kernel_bmod<Dynamic>::run(segsize, dense, tempv, glu.lusup, luptr, lda, nrow, glu.lsub, lptr, no_zeros);
00108 }
00109 }
00110
00111
00112 nextlu = glu.xlusup(jcol);
00113 fsupc = glu.xsup(jsupno);
00114
00115
00116 Index mem;
00117 new_next = nextlu + glu.xlsub(fsupc + 1) - glu.xlsub(fsupc);
00118 Index offset = internal::first_multiple<Index>(new_next, internal::packet_traits<Scalar>::size) - new_next;
00119 if(offset)
00120 new_next += offset;
00121 while (new_next > glu.nzlumax )
00122 {
00123 mem = memXpand<ScalarVector>(glu.lusup, glu.nzlumax, nextlu, LUSUP, glu.num_expansions);
00124 if (mem) return mem;
00125 }
00126
00127 for (isub = glu.xlsub(fsupc); isub < glu.xlsub(fsupc+1); isub++)
00128 {
00129 irow = glu.lsub(isub);
00130 glu.lusup(nextlu) = dense(irow);
00131 dense(irow) = Scalar(0.0);
00132 ++nextlu;
00133 }
00134
00135 if(offset)
00136 {
00137 glu.lusup.segment(nextlu,offset).setZero();
00138 nextlu += offset;
00139 }
00140 glu.xlusup(jcol + 1) = nextlu;
00141
00142
00143
00144
00145
00146
00147
00148 fst_col = (std::max)(fsupc, fpanelc);
00149
00150 if (fst_col < jcol)
00151 {
00152
00153
00154 d_fsupc = fst_col - fsupc;
00155
00156 lptr = glu.xlsub(fsupc) + d_fsupc;
00157 luptr = glu.xlusup(fst_col) + d_fsupc;
00158 nsupr = glu.xlsub(fsupc+1) - glu.xlsub(fsupc);
00159 nsupc = jcol - fst_col;
00160 nrow = nsupr - d_fsupc - nsupc;
00161
00162
00163 ufirst = glu.xlusup(jcol) + d_fsupc;
00164 Index lda = glu.xlusup(jcol+1) - glu.xlusup(jcol);
00165 Map<Matrix<Scalar,Dynamic,Dynamic>, 0, OuterStride<> > A( &(glu.lusup.data()[luptr]), nsupc, nsupc, OuterStride<>(lda) );
00166 VectorBlock<ScalarVector> u(glu.lusup, ufirst, nsupc);
00167 u = A.template triangularView<UnitLower>().solve(u);
00168
00169 new (&A) Map<Matrix<Scalar,Dynamic,Dynamic>, 0, OuterStride<> > ( &(glu.lusup.data()[luptr+nsupc]), nrow, nsupc, OuterStride<>(lda) );
00170 VectorBlock<ScalarVector> l(glu.lusup, ufirst+nsupc, nrow);
00171 l.noalias() -= A * u;
00172
00173 }
00174 return 0;
00175 }
00176
00177 }
00178 }
00179
00180 #endif // SPARSELU_COLUMN_BMOD_H