65 IndexVector& perm_r, IndexVector& iperm_c, Index& pivrow,
67 Index fsupc = glu.xsup(glu.supno(jcol));
68 Index nsupc = jcol - fsupc;
69 Index lptr = glu.xlsub(fsupc);
70 Index nsupr = glu.xlsub(fsupc + 1) - lptr;
71 Index lda = glu.xlusup(fsupc + 1) - glu.xlusup(fsupc);
72 Scalar* lu_sup_ptr = &(glu.lusup.data()[glu.xlusup(fsupc)]);
73 Scalar* lu_col_ptr = &(glu.lusup.data()[glu.xlusup(jcol)]);
74 StorageIndex* lsub_ptr = &(glu.lsub.data()[lptr]);
77 Index diagind = iperm_c(jcol);
78 RealScalar pivmax(-1.0);
80 Index diag = emptyIdxLU;
82 Index isub, icol, itemp, k;
83 for (isub = nsupc; isub < nsupr; ++isub) {
84 rtemp = numext::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;
108 rtemp = numext::abs(lu_col_ptr[diag]);
109 if (rtemp != RealScalar(0.0) && rtemp >= thresh) pivptr = diag;
111 pivrow = lsub_ptr[pivptr];
115 perm_r(pivrow) = StorageIndex(jcol);
117 if (pivptr != nsupc) {
118 std::swap(lsub_ptr[pivptr], lsub_ptr[nsupc]);
121 for (icol = 0; icol <= nsupc; icol++) {
122 itemp = pivptr + icol * lda;
123 std::swap(lu_sup_ptr[itemp], lu_sup_ptr[nsupc + icol * lda]);
128 const Scalar pivot = lu_col_ptr[nsupc];
129 if (numext::abs(pivot) >= (std::numeric_limits<RealScalar>::min)()) {
130 const Scalar temp = Scalar(1.0) / pivot;
131 for (k = nsupc + 1; k < nsupr; k++) lu_col_ptr[k] *= temp;
133 for (k = nsupc + 1; k < nsupr; k++) lu_col_ptr[k] /= pivot;