30 #ifndef SPARSELU_PIVOTL_H 31 #define SPARSELU_PIVOTL_H 34 #include "./InternalHeaderCheck.h" 62 template <
typename Scalar,
typename StorageIndex>
66 Index fsupc = (glu.xsup)((glu.supno)(jcol));
67 Index nsupc = jcol - fsupc;
68 Index lptr = glu.xlsub(fsupc);
69 Index nsupr = glu.xlsub(fsupc + 1) - lptr;
70 Index lda = glu.xlusup(fsupc + 1) - glu.xlusup(fsupc);
71 Scalar* lu_sup_ptr = &(glu.lusup.data()[glu.xlusup(fsupc)]);
72 Scalar* lu_col_ptr = &(glu.lusup.data()[glu.xlusup(jcol)]);
73 StorageIndex* lsub_ptr = &(glu.lsub.data()[lptr]);
76 Index diagind = iperm_c(jcol);
77 RealScalar pivmax(-1.0);
79 Index diag = emptyIdxLU;
81 Index isub, icol, itemp, k;
82 for (isub = nsupc; isub < nsupr; ++isub) {
84 rtemp =
abs(lu_col_ptr[isub]);
89 if (lsub_ptr[isub] == diagind) diag = isub;
93 if (pivmax <= RealScalar(0.0)) {
95 pivrow = pivmax < RealScalar(0.0) ? diagind : lsub_ptr[pivptr];
96 perm_r(pivrow) = StorageIndex(jcol);
100 RealScalar thresh = diagpivotthresh * pivmax;
109 rtemp =
abs(lu_col_ptr[diag]);
110 if (rtemp != RealScalar(0.0) && rtemp >= thresh) pivptr = diag;
112 pivrow = lsub_ptr[pivptr];
116 perm_r(pivrow) = StorageIndex(jcol);
118 if (pivptr != nsupc) {
119 std::swap(lsub_ptr[pivptr], lsub_ptr[nsupc]);
122 for (icol = 0; icol <= nsupc; icol++) {
123 itemp = pivptr + icol * lda;
124 std::swap(lu_sup_ptr[itemp], lu_sup_ptr[nsupc + icol * lda]);
128 Scalar temp = Scalar(1.0) / lu_col_ptr[nsupc];
129 for (k = nsupc + 1; k < nsupr; k++) lu_col_ptr[k] *= temp;
136 #endif // SPARSELU_PIVOTL_H Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_abs_op< typename Derived::Scalar >, const Derived > abs(const Eigen::ArrayBase< Derived > &x)
Index pivotL(const Index jcol, const RealScalar &diagpivotthresh, IndexVector &perm_r, IndexVector &iperm_c, Index &pivrow, GlobalLU_t &glu)
Performs the numerical pivoting on the current column of L, and the CDIV operation.
Definition: SparseLU_pivotL.h:63
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:186