| 83 | } |
| 84 | |
| 85 | void checkDecreasingSort(const HighsInt num_sorted, |
| 86 | const vector<double>& values, |
| 87 | const vector<HighsInt>& indices, |
| 88 | const vector<double>& original_values) { |
| 89 | // Check that the random numbers are ascending and that the indices |
| 90 | // point from the original values to their new positions |
| 91 | bool error0 = false; |
| 92 | bool error1 = false; |
| 93 | double previous = kHighsInf; |
| 94 | for (HighsInt ix = 0; ix < num_sorted; ix++) { |
| 95 | if (values[1 + ix] > previous) { |
| 96 | printf("Values[%2" HIGHSINT_FORMAT "] = %f5.4 < %f5.4 = previous\n", |
| 97 | 1 + ix, values[1 + ix], previous); |
| 98 | error0 = true; |
| 99 | } |
| 100 | previous = values[1 + ix]; |
| 101 | if (values[1 + ix] != original_values[1 + indices[1 + ix]]) { |
| 102 | printf("Values[%2" HIGHSINT_FORMAT |
| 103 | "] = %f5.4 != %f5.4 = original_values[indices[%2" HIGHSINT_FORMAT |
| 104 | "]]\n", |
| 105 | 1 + ix, values[1 + ix], original_values[indices[1 + ix]], 1 + ix); |
| 106 | error1 = true; |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | REQUIRE(error0 == false); |
| 111 | REQUIRE(error1 == false); |
| 112 | } |
| 113 | |
| 114 | TEST_CASE("HiGHS_sort", "[highs_data]") { |
| 115 | HighsInt num_values = 10; |