Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
// #include <iostream> // debug
// #include <iomanip>
#include <cmath>
#include <cstdio>
#include <ports-of-call/portability.hpp>
#include <ports-of-call/portable_errors.hpp>
#include <tuple>

#include <ports-of-call/portability.hpp>

#define SINGULARITY_ROOT_DEBUG (0)
#define SINGULARITY_ROOT_VERBOSE (0)

Expand Down Expand Up @@ -105,7 +106,7 @@ class RootCounts {
}
PORTABLE_INLINE_FUNCTION void print_counts() const {
for (std::size_t i{0}; i < nbins_; ++i)
printf("%e\n", counts_[i]);
PortsOfCall::printf("%e\n", counts_[i]);
}
PORTABLE_INLINE_FUNCTION std::size_t nBins() const { return nbins_; }
PORTABLE_INLINE_FUNCTION std::size_t more() const { return nbins_ - 1; }
Expand Down Expand Up @@ -144,8 +145,9 @@ PORTABLE_INLINE_FUNCTION bool set_bracket(const T &f, Real &a, const Real guess,
}
// if we get here then we failed to bracket a root
if (verbose) {
printf("set_bracket failed to bound a root! %.14e %.14e %.14e %.14e %.14e %.14e\n", a,
guess, b, ya, yg, yb);
PortsOfCall::printf(
"set_bracket failed to bound a root! %.14e %.14e %.14e %.14e %.14e %.14e\n", a,
guess, b, ya, yg, yb);
}
return false;
}
Expand Down Expand Up @@ -176,7 +178,8 @@ PORTABLE_INLINE_FUNCTION Status regula_falsi(const T &f, const Real ytarget,
// ya, yg, and yb have the same sign
if (!set_bracket(func, a, guess, b, ya, yg, yb, verbose)) {
if (verbose) {
printf("regula_falsi failed! %.14e %.14e %.14e %.14e\n", ytarget, guess, a, b);
PortsOfCall::printf("regula_falsi failed! %.14e %.14e %.14e %.14e\n", ytarget,
guess, a, b);
}
return Status::FAIL;
}
Expand Down Expand Up @@ -223,8 +226,9 @@ PORTABLE_INLINE_FUNCTION Status regula_falsi(const T &f, const Real ytarget,
auto status = Status::SUCCESS;
if (iteration_count == max_iter) {
if (verbose) {
printf("root finding reached the maximum number of iterations. likely not "
"converged\n");
PortsOfCall::printf(
"root finding reached the maximum number of iterations. likely not "
"converged\n");
}
status = Status::FAIL;
}
Expand Down Expand Up @@ -280,8 +284,8 @@ PORTABLE_INLINE_FUNCTION Status newton_raphson(const T &f, const Real ytarget,
// fail_on_bound_root.
if ((_x <= a && _xold <= a) || (_x >= b && _xold >= b)) {
if (verbose) {
printf("newton_raphson out of bounds! %.14e %.14e %.14e %.14e\n", ytarget, guess,
a, b);
PortsOfCall::printf("newton_raphson out of bounds! %.14e %.14e %.14e %.14e\n",
ytarget, guess, a, b);
}
if (fail_on_bound_root) {
status = Status::FAIL;
Expand All @@ -292,8 +296,9 @@ PORTABLE_INLINE_FUNCTION Status newton_raphson(const T &f, const Real ytarget,
}
if (iter >= max_iter) {
if (verbose) {
printf("root finding reached the maximum number of iterations. likely not "
"converged\n");
PortsOfCall::printf(
"root finding reached the maximum number of iterations. likely not "
"converged\n");
}
status = Status::FAIL;
}
Expand Down
Loading