45 <<
"size: X=" << x.
size() <<
", Y=" << y.
size();
51 return make_unique<FunctionAdapter>([c](
double) {
return c; });
54 return make_unique<FunctionAdapter>([c, sx](
double v) {
return c * (v == sx); });
68 if (x[i] == x[i - 1]) {
69 if (y[i] == y[i - 1]) {
73 if (x[i] < x[i - 1]) {
75 <<
"but found " << x[i] <<
" after " << x[i - 1];
96 for (
auto& pair : dataset) {
110 if (xp.
size() == 1) {
111 return (extrapolate || xp.
front() == x) ? yp.
front() : 0.;
116 if (!extrapolate && x < xp.
front())
120 if (i == xp.
size()) {
121 if (!extrapolate && x > xp.
back())
125 double x1 = xp[i], x0 = xp[i - 1];
126 double y1 = yp[i], y0 = yp[i - 1];
129 return (x1 + y1) / 2.;
132 double coef1 = (y1 - y0) / (x1 - x0);
133 double coef0 = y0 - coef1 * x0;
134 return coef0 + coef1 * x;
static Elements::Logging logger
Logger.
static Logging getLogger(const std::string &name="")
This module provides an interface for accessing two dimensional datasets (pairs of (X,...
size_t size() const
Get the size of the vector container.
T emplace_back(T... args)
ELEMENTS_API std::unique_ptr< Function > interpolate(const std::vector< double > &x, const std::vector< double > &y, InterpolationType type, bool extrapolate=false)
ELEMENTS_API double simple_interpolation(double x, const std::vector< double > &xp, const std::vector< double > &yp, bool extrapolate=false)
std::unique_ptr< Function > splineInterpolation(const std::vector< double > &x, const std::vector< double > &y, bool extrapolate)
Performs cubic spline interpolation for the given set of data points.
InterpolationType
Enumeration of the different supported interpolation types.
std::unique_ptr< Function > linearInterpolation(const std::vector< double > &x, const std::vector< double > &y, bool extrapolate)
Performs linear interpolation for the given set of data points.