remove return statement from omp-for loop and use "break"

This commit is contained in:
Krishna Vedala
2020-06-04 13:57:57 -04:00
parent 3b37d06d2a
commit 5e34779d95

View File

@@ -122,10 +122,13 @@ std::pair<uint32_t, double> durand_kerner_algo(
log_file << complex_str((*roots)[n]) << ",";
}
while (!check_termination(tol_condition) && iter < INT16_MAX) {
bool break_loop = false;
while (!check_termination(tol_condition) && iter < INT16_MAX &&
!break_loop) {
std::complex<double> delta = 0;
tol_condition = 0;
iter++;
break_loop = false;
if (log_file.is_open())
log_file << "\n" << iter << ",";
@@ -146,9 +149,13 @@ std::pair<uint32_t, double> durand_kerner_algo(
if (std::isnan(std::abs(delta)) || std::isinf(std::abs(delta))) {
std::cerr << "\n\nOverflow/underrun error - got value = "
<< std::abs(delta);
return std::pair<uint32_t, double>(iter, tol_condition);
// return std::pair<uint32_t, double>(iter, tol_condition);
break_loop = true;
}
if (break_loop)
break;
(*roots)[n] -= delta;
tol_condition = std::max(tol_condition, std::abs(std::abs(delta)));
@@ -158,6 +165,9 @@ std::pair<uint32_t, double> durand_kerner_algo(
}
// tol_condition /= (degree - 1);
if (break_loop)
break;
#if defined(DEBUG) || !defined(NDEBUG)
if (iter % 500 == 0) {
std::cout << "Iter: " << iter << "\t";