8#ifndef BILINEARSPLINEFUNCTION_H
9#define BILINEARSPLINEFUNCTION_H
58 void setData(
const std::vector<double> &x,
const std::vector<double> &y,
const std::vector<double> &vals) {
63 for (
unsigned int i = 0; i < x.size(); ++i) {
64 if (fabs(x[i] - cx) > 1e-6) {
67 m_xspls[m_xspls.size() - 1].add_val(y[i], vals[i]);
71 m_xspls[m_xspls.size() - 1].add_val(y[i], vals[i]);
78 double Eval(
double x,
double y)
const {
79 if (m_xs.size() < 2)
throw std::runtime_error(
"Insufficient data points for interpolation.");
80 std::vector< double >::const_iterator it = std::lower_bound(m_xs.begin(), m_xs.end(), x);
81 unsigned int indx = std::distance(m_xs.begin(), it);
82 int ind1 = 0, ind2 = 0;
87 else if (indx == m_xs.size()) {
95 double f1v = m_xspls[ind1].f(y);
96 double f2v = m_xspls[ind2].f(y);
97 return f1v + (x - m_xs[ind1]) * (f2v - f1v) / (m_xs[ind2] - m_xs[ind1]);
104 std::vector<double> m_xs;
105 std::vector<SplineFunction> m_xspls;
void setData(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &vals)
BilinearSplineFunction(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &vals)
~BilinearSplineFunction(void)=default
Destructor.
BilinearSplineFunction(void)
double Eval(double x, double y) const
Evaluates interpolated f(x,y)
Class implementing a simple linear spline.
The main namespace where all classes and functions of the Thermal-FIST library reside.