MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / checkDecreasingSort

Function checkDecreasingSort

check/TestSort.cpp:85–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85void 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
114TEST_CASE("HiGHS_sort", "[highs_data]") {
115 HighsInt num_values = 10;

Callers 1

TestSort.cppFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected