42 for(
int i=0; i<n; i++)
48 for (
int i=1; i<n; ++i) {
49 g = 2.*(x[i+1]-x[i-1]) - h[i-1]*mu[i-1];
51 z[i] = (3.*(y[i+1]*h[i-1] - y[i]*(x[i+1]-x[i-1])+ y[i-1]*h[i]) / (h[i-1]*h[i]) - h[i-1] * z[i-1]) /
g;
63 for (
int j=n-1; j>=0; j--) {
65 c[j] = z[j] - mu[j] * c[j+1];
66 b[j] = (y[j+1] - y[j]) / h[j] - h[j] * (c[j+1] + 2. * c[j]) / 3.;
67 d[j] = (c[j+1] - c[j]) / (3. * h[j]);
72 for (
int i=0; i<n; i++) {
74 double x_2 = x_1 * x_1;
75 double x_3 = x_1 * x_2;
76 a[i] = a[i] + b[i]*x_1 + c[i]*x_2 + d[i]*x_3;
77 b[i] = b[i] + 2.*c[i]*x_1 + 3.*d[i]*x_2;
78 c[i] = c[i] + 3.*d[i]*x_1;
84 for (
int i=0; i<n; i++) {
Represents a polynomial function.
std::unique_ptr< Function > splineInterpolation(const std::vector< double > &x, const std::vector< double > &y, bool extrapolate)
Performs cubic spline interpolation for the given set of data points.
Represents a piecewise function.