27 const std::vector<double> &y_)
28 : interpolation_points(x_)
29 , interpolation_values(y_)
30 , acc(gsl_interp_accel_alloc(),
31 [](gsl_interp_accel *p) { gsl_interp_accel_free(p); })
32 , cspline(gsl_spline_alloc(gsl_interp_cspline, interpolation_points.size()),
33 [](gsl_spline *p) { gsl_spline_free(p); })
35 Assert(interpolation_points.size() > 0,
38 Assert(interpolation_points.size() == interpolation_values.size(),
40 interpolation_values.size()));
43 for (
unsigned int i = 0; i < interpolation_points.size() - 1; ++i)
44 AssertThrow(interpolation_points[i] < interpolation_points[i + 1],
46 interpolation_points[i],
47 interpolation_points[i + 1]));
49 const unsigned int n = interpolation_points.size();
51 gsl_spline_init(cspline.get(),
52 interpolation_points.data(),
53 interpolation_values.data(),
66 std::lock_guard<std::mutex> lock(acc_mutex);
68 const double x = p[0];
69 Assert(x >= interpolation_points.front() &&
70 x <= interpolation_points.back(),
72 interpolation_points.front(),
73 interpolation_points.back()));
75 return gsl_spline_eval(cspline.get(), x, acc.get());
87 std::lock_guard<std::mutex> lock(acc_mutex);
89 const double x = p[0];
90 Assert(x >= interpolation_points.front() &&
91 x <= interpolation_points.back(),
93 interpolation_points.front(),
94 interpolation_points.back()));
96 const double deriv = gsl_spline_eval_deriv(cspline.get(), x, acc.get());
111 std::lock_guard<std::mutex> lock(acc_mutex);
113 const double x = p[0];
114 Assert(x >= interpolation_points.front() &&
115 x <= interpolation_points.back(),
117 interpolation_points.front(),
118 interpolation_points.back()));
120 return gsl_spline_eval_deriv2(cspline.get(), x, acc.get());