Go to the documentation of this file.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 #ifndef SPARSELU_PIVOTL_H
00031 #define SPARSELU_PIVOTL_H
00032
00033 namespace Eigen {
00034 namespace internal {
00035
00059 template <typename Scalar, typename Index>
00060 Index SparseLUImpl<Scalar,Index>::pivotL(const Index jcol, const RealScalar& diagpivotthresh, IndexVector& perm_r, IndexVector& iperm_c, Index& pivrow, GlobalLU_t& glu)
00061 {
00062
00063 Index fsupc = (glu.xsup)((glu.supno)(jcol));
00064 Index nsupc = jcol - fsupc;
00065 Index lptr = glu.xlsub(fsupc);
00066 Index nsupr = glu.xlsub(fsupc+1) - lptr;
00067 Index lda = glu.xlusup(fsupc+1) - glu.xlusup(fsupc);
00068 Scalar* lu_sup_ptr = &(glu.lusup.data()[glu.xlusup(fsupc)]);
00069 Scalar* lu_col_ptr = &(glu.lusup.data()[glu.xlusup(jcol)]);
00070 Index* lsub_ptr = &(glu.lsub.data()[lptr]);
00071
00072
00073 Index diagind = iperm_c(jcol);
00074 RealScalar pivmax = 0.0;
00075 Index pivptr = nsupc;
00076 Index diag = emptyIdxLU;
00077 RealScalar rtemp;
00078 Index isub, icol, itemp, k;
00079 for (isub = nsupc; isub < nsupr; ++isub) {
00080 rtemp = std::abs(lu_col_ptr[isub]);
00081 if (rtemp > pivmax) {
00082 pivmax = rtemp;
00083 pivptr = isub;
00084 }
00085 if (lsub_ptr[isub] == diagind) diag = isub;
00086 }
00087
00088
00089 if ( pivmax == 0.0 ) {
00090 pivrow = lsub_ptr[pivptr];
00091 perm_r(pivrow) = jcol;
00092 return (jcol+1);
00093 }
00094
00095 RealScalar thresh = diagpivotthresh * pivmax;
00096
00097
00098
00099 {
00100
00101 if (diag >= 0 )
00102 {
00103
00104 rtemp = std::abs(lu_col_ptr[diag]);
00105 if (rtemp != 0.0 && rtemp >= thresh) pivptr = diag;
00106 }
00107 pivrow = lsub_ptr[pivptr];
00108 }
00109
00110
00111 perm_r(pivrow) = jcol;
00112
00113 if (pivptr != nsupc )
00114 {
00115 std::swap( lsub_ptr[pivptr], lsub_ptr[nsupc] );
00116
00117
00118 for (icol = 0; icol <= nsupc; icol++)
00119 {
00120 itemp = pivptr + icol * lda;
00121 std::swap(lu_sup_ptr[itemp], lu_sup_ptr[nsupc + icol * lda]);
00122 }
00123 }
00124
00125 Scalar temp = Scalar(1.0) / lu_col_ptr[nsupc];
00126 for (k = nsupc+1; k < nsupr; k++)
00127 lu_col_ptr[k] *= temp;
00128 return 0;
00129 }
00130
00131 }
00132 }
00133
00134 #endif // SPARSELU_PIVOTL_H