diff --git a/numerical_methods/durand_kerner_roots.cpp b/numerical_methods/durand_kerner_roots.cpp index dd6a10f22..01fd4ebaf 100644 --- a/numerical_methods/durand_kerner_roots.cpp +++ b/numerical_methods/durand_kerner_roots.cpp @@ -134,9 +134,12 @@ std::pair durand_kerner_algo( log_file << "\n" << iter << ","; #ifdef _OPENMP -#pragma omp for +#pragma omp parallel for shared(break_loop) #endif for (n = 0; n < roots->size(); n++) { + if (break_loop) + continue; + std::complex numerator, denominator; numerator = poly_function(coeffs, (*roots)[n]); denominator = 1.0; @@ -153,9 +156,6 @@ std::pair durand_kerner_algo( break_loop = true; } - if (break_loop) - break; - (*roots)[n] -= delta; tol_condition = std::max(tol_condition, std::abs(std::abs(delta))); @@ -166,7 +166,7 @@ std::pair durand_kerner_algo( // tol_condition /= (degree - 1); if (break_loop) - continue; + break; #if defined(DEBUG) || !defined(NDEBUG) if (iter % 500 == 0) {