| 309 | } |
| 310 | |
| 311 | bool testSolveDense() { |
| 312 | const bool test_all = true; |
| 313 | bool test_sparse_ftran = test_all; |
| 314 | bool test_sparse_btran = test_all; |
| 315 | bool test_dense_ftran = test_all; |
| 316 | bool test_dense_btran = test_all; |
| 317 | std::vector<double> rhs_dense; |
| 318 | double error_norm = 0; |
| 319 | HighsInt iCol; |
| 320 | if (test_sparse_ftran) { |
| 321 | HighsRandom random; |
| 322 | iCol = random.integer(num_row); |
| 323 | rhs.clear(); |
| 324 | lp.a_matrix_.collectAj(rhs, basic_set[iCol], 1); |
| 325 | rhs_dense = rhs.array; |
| 326 | factor.ftranCall(rhs_dense); |
| 327 | error_norm = 0; |
| 328 | for (HighsInt iRow = 0; iRow < num_row; iRow++) { |
| 329 | if (iRow == iCol) { |
| 330 | error_norm = std::max(std::fabs(1 - rhs_dense[iRow]), error_norm); |
| 331 | } else { |
| 332 | error_norm = std::max(std::fabs(rhs_dense[iRow]), error_norm); |
| 333 | } |
| 334 | } |
| 335 | if (dev_run) printf("Sparse FTRAN: %g\n", error_norm); |
| 336 | if (error_norm > 1e-4) return false; |
| 337 | } |
| 338 | |
| 339 | if (test_dense_ftran) { |
| 340 | rhs.clear(); |
| 341 | for (HighsInt iCol = 0; iCol < num_row; iCol++) |
| 342 | lp.a_matrix_.collectAj(rhs, basic_set[iCol], solution[iCol]); |
| 343 | rhs_dense = rhs.array; |
| 344 | factor.ftranCall(rhs_dense); |
| 345 | error_norm = 0; |
| 346 | for (HighsInt iRow = 0; iRow < num_row; iRow++) |
| 347 | error_norm = |
| 348 | std::max(std::fabs(solution[iRow] - rhs_dense[iRow]), error_norm); |
| 349 | if (dev_run) printf("Dense FTRAN: %g\n", error_norm); |
| 350 | if (error_norm > 1e-4) return false; |
| 351 | } |
| 352 | |
| 353 | if (test_sparse_btran) { |
| 354 | // Sparse BTRAN |
| 355 | std::vector<double> unit; |
| 356 | unit.assign(num_row, 0); |
| 357 | unit[iCol] = 1.0; |
| 358 | rhs_dense.clear(); |
| 359 | for (HighsInt iCol = 0; iCol < num_row; iCol++) |
| 360 | rhs_dense.push_back(lp.a_matrix_.computeDot(unit, basic_set[iCol])); |
| 361 | factor.btranCall(rhs_dense); |
| 362 | error_norm = 0; |
| 363 | for (HighsInt iRow = 0; iRow < num_row; iRow++) { |
| 364 | if (iRow == iCol) { |
| 365 | error_norm = std::max(std::fabs(1 - rhs_dense[iRow]), error_norm); |
| 366 | } else { |
| 367 | error_norm = std::max(std::fabs(rhs_dense[iRow]), error_norm); |
| 368 | } |
no test coverage detected