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) {
85 rtemp = abs(lu_col_ptr[isub]);
90 if (lsub_ptr[isub] == diagind) diag = isub;
94 if (pivmax <= RealScalar(0.0)) {
96 pivrow = pivmax < RealScalar(0.0) ? diagind : lsub_ptr[pivptr];
97 perm_r(pivrow) = StorageIndex(jcol);
101 RealScalar thresh = diagpivotthresh * pivmax;
110 rtemp = abs(lu_col_ptr[diag]);
111 if (rtemp != RealScalar(0.0) && rtemp >= thresh) pivptr = diag;
113 pivrow = lsub_ptr[pivptr];
117 perm_r(pivrow) = StorageIndex(jcol);
119 if (pivptr != nsupc) {
120 std::swap(lsub_ptr[pivptr], lsub_ptr[nsupc]);
123 for (icol = 0; icol <= nsupc; icol++) {
124 itemp = pivptr + icol * lda;
125 std::swap(lu_sup_ptr[itemp], lu_sup_ptr[nsupc + icol * lda]);
130 const Scalar pivot = lu_col_ptr[nsupc];
131 if (numext::abs(pivot) >= (std::numeric_limits<RealScalar>::min)()) {
132 const Scalar temp = Scalar(1.0) / pivot;
133 for (k = nsupc + 1; k < nsupr; k++) lu_col_ptr[k] *= temp;
135 for (k = nsupc + 1; k < nsupr; k++) lu_col_ptr[k] /= pivot;