From 89f33a49ba2bf70e4189c484a60eea59a2d5b286 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Thu, 4 Jun 2020 14:14:46 -0400 Subject: [PATCH] (1) break while loop (2) skip runs on break_loop instead of hard-break --- numerical_methods/durand_kerner_roots.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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) {