18 #include "../../include/ecl/geometry/smooth_linear_spline.hpp" 32 if ( x_data.
size() != y_data.
size() ) {
41 unsigned int n = x_data.
size()-1;
53 for (
unsigned int i = 0; i < n; ++i ) {
54 segments[i] = LinearFunction::Interpolation(x_data[i],y_data[i],x_data[i+1],y_data[i+1]);
62 for (
unsigned int i = 1; i < n; ++i ) {
65 corners[i-1].coefficients() <<
segments[i-1].coefficients()[0],
segments[i-1].coefficients()[1], 0.0, 0.0, 0.0, 0.0;
69 for (
unsigned int j = 1; j <= 5; ++j ) {
72 x_l = x_data[i] - j*(x_data[i]-x_data[i-1])/5;
74 x_l = x_data[i] - j*(x_data[i]-x_data[i-1])/10;
77 x_r = x_data[i] + j*(x_data[i+1]-x_data[i])/5;
79 x_r = x_data[i] + j*(x_data[i+1]-x_data[i])/10;
83 double ydot_l =
segments[i-1].derivative(x_l);
84 double ydot_r =
segments[i].derivative(x_r);
85 corners[i-1] = QuinticPolynomial::Interpolation(x_l,y_l,ydot_l,0.0,
118 if ( index % 2 == 0 ) {
121 return corners[(index-1)/2](x);
131 if ( index % 2 == 0 ) {
132 return segments[index/2].derivative(x);
144 if ( index % 2 == 0 ) {
145 return segments[index/2].dderivative(x);
Embedded control libraries.
Mathematical minimum on a compact interval for cubic polynomials.
double operator()(const double &x) const
Spline function.
#define ecl_assert_throw(expression, exception)
double derivative(const double &x) const
Spline derivative.
double dderivative(const double &x) const
Spline second derivative.
Array< double > discretised_domain
Mathematical maximum on a compact interval for cubic polynomials.
Array< QuinticPolynomial > corners
SmoothLinearSpline()
Default constructor.
Array< LinearFunction > segments