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(nullptr), acc_m(nullptr) {
44 : spline_m(nullptr), acc_m(nullptr) {
55 if (
acc_m !=
nullptr) {
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());
113 if (
acc_m ==
nullptr) {
114 acc_m = gsl_interp_accel_alloc();
116 gsl_interp_accel_reset(
acc_m);
void setSpline(size_t splineOrder, std::vector< double > times, std::vector< double > values)
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Inform & endl(Inform &inf)
std::vector< double > values_m
std::vector< double > times_m
Inform & print(Inform &os)
SplineTimeDependence * clone()