| 94 | } |
| 95 | |
| 96 | static void MyQuickSortDescending(Real* first, Real* last, int depth) |
| 97 | { |
| 98 | REPORT |
| 99 | for (;;) |
| 100 | { |
| 101 | const int length = last - first + 1; |
| 102 | if (length < DoSimpleSort) { REPORT return; } |
| 103 | if (depth++ > MaxDepth) |
| 104 | Throw(ConvergenceException("QuickSortDescending fails: ")); |
| 105 | Real* centre = first + length/2; |
| 106 | const Real test = SortThreeDescending(first, centre, last); |
| 107 | Real* f = first; Real* l = last; |
| 108 | for (;;) |
| 109 | { |
| 110 | while (*(++f) > test) {} |
| 111 | while (*(--l) < test) {} |
| 112 | if (l <= f) break; |
| 113 | const Real temp = *f; *f = *l; *l = temp; |
| 114 | } |
| 115 | if (f > centre) |
| 116 | { REPORT MyQuickSortDescending(l+1, last, depth); last = f-1; } |
| 117 | else { REPORT MyQuickSortDescending(first, f-1, depth); first = l+1; } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | void SortAscending(GeneralMatrix& GM) |
| 122 | { |
no test coverage detected