| 215 | } |
| 216 | |
| 217 | bool testSolve() { |
| 218 | const bool test_all = true; |
| 219 | bool test_sparse_ftran = test_all; |
| 220 | bool test_sparse_btran = test_all; |
| 221 | bool test_dense_ftran = test_all; |
| 222 | bool test_dense_btran = test_all; |
| 223 | const HighsInt check_basis_change = -66; |
| 224 | const bool debug_report = basis_change == check_basis_change; |
| 225 | if (debug_report) { |
| 226 | printf("basis_change = %d\n", (int)basis_change); |
| 227 | } |
| 228 | factor.setDebugReport(debug_report); |
| 229 | double error_norm; |
| 230 | HighsInt iCol; |
| 231 | HighsRandom random(basis_change); |
| 232 | iCol = random.integer(num_row); |
| 233 | if (test_sparse_ftran) { |
| 234 | // Sparse FTRAN |
| 235 | rhs.clear(); |
| 236 | lp.a_matrix_.collectAj(rhs, basic_set[iCol], 1); |
| 237 | factor.ftranCall(rhs, 1); |
| 238 | error_norm = 0; |
| 239 | for (HighsInt iRow = 0; iRow < num_row; iRow++) { |
| 240 | if (iRow == iCol) { |
| 241 | error_norm = std::max(std::fabs(1 - rhs.array[iRow]), error_norm); |
| 242 | } else { |
| 243 | error_norm = std::max(std::fabs(rhs.array[iRow]), error_norm); |
| 244 | } |
| 245 | } |
| 246 | if (debug_report) |
| 247 | printf("Sparse FTRAN %2d: %g\n", (int)basis_change, error_norm); |
| 248 | if (error_norm > 1e-4) return false; |
| 249 | } |
| 250 | |
| 251 | iCol = random.integer(num_row); |
| 252 | if (test_sparse_btran) { |
| 253 | // Sparse BTRAN |
| 254 | std::vector<double> unit; |
| 255 | unit.assign(num_row, 0); |
| 256 | unit[iCol] = 1.0; |
| 257 | rhs.clear(); |
| 258 | for (HighsInt iCol = 0; iCol < num_row; iCol++) { |
| 259 | rhs.array[iCol] = lp.a_matrix_.computeDot(unit, basic_set[iCol]); |
| 260 | if (rhs.array[iCol]) rhs.index[rhs.count++] = iCol; |
| 261 | } |
| 262 | factor.btranCall(rhs, 1); |
| 263 | error_norm = 0; |
| 264 | for (HighsInt iRow = 0; iRow < num_row; iRow++) { |
| 265 | if (iRow == iCol) { |
| 266 | error_norm = std::max(std::fabs(1 - rhs.array[iRow]), error_norm); |
| 267 | } else { |
| 268 | error_norm = std::max(std::fabs(rhs.array[iRow]), error_norm); |
| 269 | } |
| 270 | } |
| 271 | if (debug_report) |
| 272 | printf("Sparse BTRAN %2d: %g\n", (int)basis_change, error_norm); |
| 273 | if (error_norm > 1e-4) return false; |
| 274 | } |
no test coverage detected