30 #ifndef SPARSELU_PIVOTL_H
31 #define SPARSELU_PIVOTL_H
61 template <
typename Scalar,
typename StorageIndex>
65 Index fsupc = (glu.xsup)((glu.supno)(jcol));
66 Index nsupc = jcol - fsupc;
67 Index lptr = glu.xlsub(fsupc);
68 Index nsupr = glu.xlsub(fsupc+1) - lptr;
69 Index lda = glu.xlusup(fsupc+1) - glu.xlusup(fsupc);
70 Scalar* lu_sup_ptr = &(glu.lusup.data()[glu.xlusup(fsupc)]);
71 Scalar* lu_col_ptr = &(glu.lusup.data()[glu.xlusup(jcol)]);
72 StorageIndex* lsub_ptr = &(glu.lsub.data()[lptr]);
75 Index diagind = iperm_c(jcol);
76 RealScalar pivmax(-1.0);
80 Index isub, icol, itemp, k;
81 for (isub = nsupc; isub < nsupr; ++isub) {
83 rtemp =
abs(lu_col_ptr[isub]);
88 if (lsub_ptr[isub] == diagind) diag = isub;
92 if ( pivmax <= RealScalar(0.0) ) {
94 pivrow = pivmax < RealScalar(0.0) ? diagind : lsub_ptr[pivptr];
95 perm_r(pivrow) = StorageIndex(jcol);
99 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 )
120 std::swap( lsub_ptr[pivptr], lsub_ptr[nsupc] );
123 for (icol = 0; icol <= nsupc; icol++)
125 itemp = pivptr + icol * lda;
126 std::swap(lu_sup_ptr[itemp], lu_sup_ptr[nsupc + icol * lda]);
130 Scalar temp = Scalar(1.0) / lu_col_ptr[nsupc];
131 for (k = nsupc+1; k < nsupr; k++)
132 lu_col_ptr[k] *= temp;
const AbsReturnType abs() const
void swap(scoped_array< T > &a, scoped_array< T > &b)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_abs_op< typename Derived::Scalar >, const Derived > abs(const Eigen::ArrayBase< Derived > &x)