40 for(
int i=0; i<n; i++)
46 for (
int i=1; i<n; ++i) {
47 g = 2.*(x[i+1]-x[i-1]) - h[i-1]*mu[i-1];
49 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;
61 for (
int j=n-1; j>=0; j--) {
63 c[j] = z[j] - mu[j] * c[j+1];
64 b[j] = (y[j+1] - y[j]) / h[j] - h[j] * (c[j+1] + 2. * c[j]) / 3.;
65 d[j] = (c[j+1] - c[j]) / (3. * h[j]);
70 for (
int i=0; i<n; i++) {
72 double x_2 = x_1 * x_1;
73 double x_3 = x_1 * x_2;
74 a[i] = a[i] + b[i]*x_1 + c[i]*x_2 + d[i]*x_3;
75 b[i] = b[i] + 2.*c[i]*x_1 + 3.*d[i]*x_2;
76 c[i] = c[i] + 3.*d[i]*x_1;
81 for (
int i=0; i<n; i++) {
std::unique_ptr< Function > splineInterpolation(const std::vector< double > &x, const std::vector< double > &y)
Performs cubic spline interpolation for the given set of data points.
Represents a polynomial function.
Represents a piecewise function.