15 const std::vector<double>& y) {
16 const auto N = x.size();
18 throw std::runtime_error(
19 "Need two vectors of equal length for interpolation.");
22 throw std::runtime_error(
23 "Need at least 3 data points for cubic spline interpolation.");
26 x, [&](
double const& a,
double const& b) {
return a < b; });
35 acc_ = gsl_interp_accel_alloc();
36 spline_ = gsl_spline_alloc(gsl_interp_cspline, N);
37 gsl_spline_init(
spline_, &(*sorted_x.begin()), &(*sorted_y.begin()), N);
42 gsl_interp_accel_free(
acc_);
double first_x_
First x value.
gsl_spline * spline_
GSL spline.
InterpolateDataSpline(const std::vector< double > &x, const std::vector< double > &y)
Interpolate function f given discrete samples f(x_i) = y_i.
~InterpolateDataSpline()
Destructor.
double last_y_
Last y value.
double operator()(double x) const
Calculate spline interpolation at x.
double first_y_
First y value.
gsl_interp_accel * acc_
GSL iterator for interpolation lookups.
double last_x_
Last x value.
std::vector< T > apply_permutation(const std::vector< T > &v, const Permutation &p)
Apply a permutation to a vector.
void check_duplicates(const std::vector< T > &x, const std::string &error_position)
Check whether two components have the same value in a sorted vector x.
Permutation generate_sort_permutation(std::vector< T > const &v, Cmp compare)
Calculate the permutations necessary for sorting a vector.