| 51 | */ |
| 52 | template <typename Scalar, typename StorageIndex> |
| 53 | void SparseLUImpl<Scalar,StorageIndex>::pruneL(const Index jcol, const IndexVector& perm_r, const Index pivrow, const Index nseg, |
| 54 | const IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune, GlobalLU_t& glu) |
| 55 | { |
| 56 | // For each supernode-rep irep in U(*,j] |
| 57 | Index jsupno = glu.supno(jcol); |
| 58 | Index i,irep,irep1; |
| 59 | bool movnum, do_prune = false; |
| 60 | Index kmin = 0, kmax = 0, minloc, maxloc,krow; |
| 61 | for (i = 0; i < nseg; i++) |
| 62 | { |
| 63 | irep = segrep(i); |
| 64 | irep1 = irep + 1; |
| 65 | do_prune = false; |
| 66 | |
| 67 | // Don't prune with a zero U-segment |
| 68 | if (repfnz(irep) == emptyIdxLU) continue; |
| 69 | |
| 70 | // If a snode overlaps with the next panel, then the U-segment |
| 71 | // is fragmented into two parts -- irep and irep1. We should let |
| 72 | // pruning occur at the rep-column in irep1s snode. |
| 73 | if (glu.supno(irep) == glu.supno(irep1) ) continue; // don't prune |
| 74 | |
| 75 | // If it has not been pruned & it has a nonz in row L(pivrow,i) |
| 76 | if (glu.supno(irep) != jsupno ) |
| 77 | { |
| 78 | if ( xprune (irep) >= glu.xlsub(irep1) ) |
| 79 | { |
| 80 | kmin = glu.xlsub(irep); |
| 81 | kmax = glu.xlsub(irep1) - 1; |
| 82 | for (krow = kmin; krow <= kmax; krow++) |
| 83 | { |
| 84 | if (glu.lsub(krow) == pivrow) |
| 85 | { |
| 86 | do_prune = true; |
| 87 | break; |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | if (do_prune) |
| 93 | { |
| 94 | // do a quicksort-type partition |
| 95 | // movnum=true means that the num values have to be exchanged |
| 96 | movnum = false; |
| 97 | if (irep == glu.xsup(glu.supno(irep)) ) // Snode of size 1 |
| 98 | movnum = true; |
| 99 | |
| 100 | while (kmin <= kmax) |
| 101 | { |
| 102 | if (perm_r(glu.lsub(kmax)) == emptyIdxLU) |
| 103 | kmax--; |
| 104 | else if ( perm_r(glu.lsub(kmin)) != emptyIdxLU) |
| 105 | kmin++; |
| 106 | else |
| 107 | { |
| 108 | // kmin below pivrow (not yet pivoted), and kmax |
| 109 | // above pivrow: interchange the two suscripts |
| 110 | std::swap(glu.lsub(kmin), glu.lsub(kmax)); |