41 for (
int i = 0; i < n; i++)
42 h[i] = x[i + 1] - x[i];
46 for (
int i = 1; i < n; ++i) {
47 double g = 2. * (x[i + 1] - x[i - 1]) - h[i - 1] * mu[i - 1];
50 (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;
62 for (
int j = n - 1; j >= 0; j--) {
64 c[j] = z[j] - mu[j] * c[j + 1];
65 b[j] = (y[j + 1] - y[j]) / h[j] - h[j] * (c[j + 1] + 2. * c[j]) / 3.;
66 d[j] = (c[j + 1] - c[j]) / (3. * h[j]);
71 for (
int i = 0; i < n; i++) {
73 double x_2 = x_1 * x_1;
74 double x_3 = x_1 * x_2;
75 a[i] = a[i] + b[i] * x_1 + c[i] * x_2 + d[i] * x_3;
76 b[i] = b[i] + 2. * c[i] * x_1 + 3. * d[i] * x_2;
77 c[i] = c[i] + 3. * d[i] * x_1;
83 for (
int i = 0; i < n; i++) {
Represents a piecewise function.
Represents a polynomial function.
T emplace_back(T... args)
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.