10 #include <initializer_list>
17 const std::vector<double>& y,
18 const std::vector<double>& z) {
19 const size_t M = x.size();
20 const size_t N = y.size();
22 if (z.size() != N * M) {
23 throw std::runtime_error(
24 "Dimensions not suitable for 2D interpolation. DIM(z) != DIM(x) * "
29 throw std::runtime_error(
30 "Need at least 4 data points in each dimension for bicubic spline "
41 const double* xa = &x[0];
42 const double* ya = &y[0];
43 const double* za = &z[0];
46 xacc_ = gsl_interp_accel_alloc();
47 yacc_ = gsl_interp_accel_alloc();
50 spline_ = gsl_spline2d_alloc(gsl_interp2d_bicubic, M, N);
51 gsl_spline2d_init(
spline_, xa, ya, za, M, N);
56 gsl_interp_accel_free(
xacc_);
57 gsl_interp_accel_free(
yacc_);
double first_y_
First y value.
double last_y_
Last y value.
double last_x_
Last x value.
InterpolateData2DSpline(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z)
Interpolate function f given discrete samples f(x_i, y_i) = z_i.
double operator()(double xi, double yi) const
Calculate bicubic interpolation for given x and y.
gsl_interp_accel * xacc_
GSL iterator for interpolation lookups in x direction.
~InterpolateData2DSpline()
Destructor.
gsl_spline2d * spline_
GSL spline in 2D.
double first_x_
First x value.
gsl_interp_accel * yacc_
GSL iterator for interpolation lookupin y direction.