13#include "../settings/settings.hpp"
25template <
typename Tx,
typename Ty>
26auto linInt_noexcept(
bool bound, Tx &xdat, Ty &ydat,
int nin,
double x,
bool is_fixed =
false)
53 return std::make_pair(yy, status);
54 }
else if (x > xdat[nin - 1]) {
56 return std::make_pair(yy, status);
62 else if (x >= xdat[nin - 1])
70 double dt = xdat[1] - xdat[0];
71 i_low =
static_cast<int>((x - xdat[0]) / dt) + 1;
76 const auto it = std::lower_bound(xdat.begin(), xdat.begin() + nin, x);
77 i_low =
static_cast<int>(it - xdat.begin());
80 const double xr = xdat[i_low];
81 const double yr = ydat[i_low];
82 const double xl = xdat[i_low - 1];
83 const double yl = ydat[i_low - 1];
84 yy = yl + (yr - yl) * (x - xl) / (xr - xl);
87 return std::make_pair(yy, status);
90template <
typename Tx,
typename Ty>
91double linInt(
bool verbose,
bool bound, Tx &xdat, Ty &ydat,
int nin,
double x,
bool is_fixed =
false)
116 auto [yy, status] =
linInt_noexcept(bound, xdat, ydat, nin, x, is_fixed);
120 std::cerr <<
"ERROR in Interpolation::linInt: x is out of bounds. x = " << x <<
" while xmin = " << xdat[0] <<
" and xmax is " << xdat[nin - 1] <<
".\n";
Slide namespace contains all the types, classes, and functions for the simulation framework.
Definition: Cell.hpp:27
double linInt(bool verbose, bool bound, Tx &xdat, Ty &ydat, int nin, double x, bool is_fixed=false)
Definition: interpolation.hpp:91
auto linInt_noexcept(bool bound, Tx &xdat, Ty &ydat, int nin, double x, bool is_fixed=false)
Definition: interpolation.hpp:26