29 real* p = malloc((n-1)*
sizeof(
real));
38 for(
int i=1; i<n-1; i++) {
39 Y[i] = 6 * (f[i+1] - 2 * f[i] + f[i-1]);
48 for(
int i=1; i<n-1; i++) {
49 p[i] = 1 / (4 - p[i-1]);
50 Y[i] = (Y[i] - Y[i-1]) / (4 - p[i-1]);
56 for(
int i=n-2; i>-1; i--) {
57 D[i] = Y[i] - p[i] * D[i+1];
70 real* r = malloc((n-2)*
sizeof(
real));
75 Y[0] = 6 * (f[1] - 2 * f[0] + f[n-1]);
76 for(
int i=1; i<n-1; i++) {
77 Y[i] = 6 * (f[i+1] - 2 * f[i] + f[i-1]);
79 Y[n-1] = 6 * (f[0] - 2 * f[n-1] + f[n-2]);
87 for(
int i=1; i<n-2; i++) {
88 dlast = dlast - l * r[i-1];
89 Y[n-1] = Y[n-1] - l * Y[i-1];
91 p[i] = 1 / (4 - p[i-1]);
92 r[i] = -r[i-1] / (4 - p[i-1]);
93 Y[i] = (Y[i] - Y[i-1]) / (4 - p[i-1]);
95 blast = 1.0 - l * p[n-3];
96 dlast = dlast - l * r[n-3];
97 Y[n-1] = Y[n-1] - l * Y[n-3];
99 p[n-2] = (1 - r[n-3]) / (4 - p[n-3]);
100 Y[n-2] = (Y[n-2] - Y[n-3]) / (4 - p[n-3]);
101 Y[n-1] = (Y[n-1] - blast * Y[n-2]) / (dlast - blast * p[n-2]);
105 D[n-2] = Y[n-2] - p[n-2] * D[n-1];
106 for(
int i=n-3; i>-1; i--) {
107 D[i] = Y[i] - p[i] * D[i+1] - r[i] * D[n-1];
121 for(
int i=0; i<n; i++) {
void splinecomp(real *f, int n, int bc, real *c)
Calculate compact cubic spline interpolation coefficients in 1D.