MCPcopy Create free account
hub / github.com/PX4/eigen / QuickSplit

Function QuickSplit

Eigen/src/IterativeLinearSolvers/IncompleteLUT.h:29–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 **/
28template <typename VectorV, typename VectorI>
29Index QuickSplit(VectorV &row, VectorI &ind, Index ncut)
30{
31 typedef typename VectorV::RealScalar RealScalar;
32 using std::swap;
33 using std::abs;
34 Index mid;
35 Index n = row.size(); /* length of the vector */
36 Index first, last ;
37
38 ncut--; /* to fit the zero-based indices */
39 first = 0;
40 last = n-1;
41 if (ncut < first || ncut > last ) return 0;
42
43 do {
44 mid = first;
45 RealScalar abskey = abs(row(mid));
46 for (Index j = first + 1; j <= last; j++) {
47 if ( abs(row(j)) > abskey) {
48 ++mid;
49 swap(row(mid), row(j));
50 swap(ind(mid), ind(j));
51 }
52 }
53 /* Interchange for the pivot element */
54 swap(row(mid), row(first));
55 swap(ind(mid), ind(first));
56
57 if (mid > ncut) last = mid - 1;
58 else if (mid < ncut ) first = mid + 1;
59 } while (mid != ncut );
60
61 return 0; /* mid is equal to ncut */
62}
63
64}// end namespace internal
65

Callers 2

factorizeMethod · 0.85
factorizeMethod · 0.85

Calls 4

absFunction · 0.50
rowFunction · 0.50
swapFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected