@@ -44,24 +44,6 @@ Int Numeric::solve(double* x) const {
4444 return kRetOk ;
4545}
4646
47- Int Numeric::solve (double * x, Int k) const {
48- if (k == 1 )
49- return solve (x);
50- else {
51- highs::parallel::TaskGroup tg;
52- const Int n = S_ ->size ();
53- std::atomic<bool > fail{false };
54- for (Int i = 0 ; i < k; ++i) {
55- tg.spawn ([=, &fail]() {
56- Int status = solve (&x[i * n]);
57- if (status) fail.store (true , std::memory_order_relaxed);
58- });
59- }
60- tg.taskWait ();
61- return fail;
62- }
63- }
64-
6547Int Numeric::forwardSolve (double * x) const {
6648 if (!sn_columns_ || !S_ || !data_ || !options_) return kRetInvalidPointer ;
6749 HybridSolveHandler SH (*S_ , *sn_columns_, swaps_, pivot_2x2_, *data_,
@@ -86,6 +68,32 @@ Int Numeric::backwardSolve(double* x) const {
8668 return kRetOk ;
8769}
8870
71+ #define SOLVE_MULTIPLE (f ) \
72+ if (k == 1 ) \
73+ return f(x); \
74+ else { \
75+ highs::parallel::TaskGroup tg; \
76+ const Int n = S_ ->size (); \
77+ std::atomic<bool > fail{false }; \
78+ for (Int i = 0 ; i < k; ++i) { \
79+ tg.spawn ([=, &fail]() { \
80+ Int status = f (&x[i * n]); \
81+ if (status) fail.store (true , std::memory_order_relaxed); \
82+ }); \
83+ } \
84+ tg.taskWait (); \
85+ return fail; \
86+ }
87+
88+ Int Numeric::solve (double * x, Int k) const { SOLVE_MULTIPLE (solve); }
89+ Int Numeric::forwardSolve (double * x, Int k) const {
90+ SOLVE_MULTIPLE (forwardSolve);
91+ }
92+ Int Numeric::diagSolve (double * x, Int k) const { SOLVE_MULTIPLE (diagSolve); }
93+ Int Numeric::backwardSolve (double * x, Int k) const {
94+ SOLVE_MULTIPLE (backwardSolve);
95+ }
96+
8997void Numeric::getReg (double * reg) {
9098 std::memcpy (reg, total_reg_.data (), total_reg_.size () * sizeof (double ));
9199}
0 commit comments