28 #include <gsl/gsl_errno.h>
29 #include <gsl/gsl_spline.h>
37 std::vector<double> times,
38 std::vector<double> values)
39 : spline_m(NULL), acc_m(NULL) {
44 : spline_m(NULL), acc_m(NULL) {
56 gsl_interp_accel_free(
acc_m);
68 os <<
"Uninitiaised SplineTimeDependence" <<
endl;
72 <<
" with " <<
times_m.size() <<
" entries" <<
endl;
77 std::vector<double> times,
78 std::vector<double> values) {
79 if (times.size() != values.size()) {
81 "SplineTimeDependence::SplineTimeDependence",
82 "Times and values should be of equal length");
84 if (times.size() < splineOrder+1) {
86 "SplineTimeDependence::SplineTimeDependence",
87 "Times and values should be of length > splineOrder+1");
89 if (splineOrder != 1 and splineOrder != 3) {
91 "SplineTimeDependence::SplineTimeDependence",
92 "Only linear or cubic interpolation is supported");
94 for (
int i = 0; i < int(times.size())-1; ++i) {
95 if (times[i] >= times[i+1]) {
97 "SplineTimeDependence::SplineTimeDependence",
98 "Times should increase monotonically");
105 if (splineOrder == 1) {
106 spline_m = gsl_spline_alloc (gsl_interp_linear, times.size());
107 }
else if (splineOrder == 3) {
108 spline_m = gsl_spline_alloc (gsl_interp_cspline, times.size());
112 gsl_spline_init(
spline_m, ×[0], &values[0], times.size());
114 acc_m = gsl_interp_accel_alloc();
116 gsl_interp_accel_reset(
acc_m);
Inform & endl(Inform &inf)
SplineTimeDependence * clone()
std::vector< double > values_m
void setSpline(size_t splineOrder, std::vector< double > times, std::vector< double > values)
Inform & print(Inform &os)
std::vector< double > times_m