54 double *
a,
const double *z,
const double *z1)
56 if (!isfinite(z1[1] + z1[2]))
64 }
else if (!isfinite(z1[0] + z1[3])) {
74 a[0] = 1.5 * (z[1] - z[2]) + 0.5 * (z[3] - z[0]);
75 a[1] = z[0] - 2.5 * z[1] + 2 * z[2] - 0.5 * z[3];
76 a[2] = 0.5 * (z[2] - z[0]);
84 return ((
a[0] * t +
a[1]) * t +
a[2]) * t +
a[3];
89 double f,
double t0,
double length,
double *t,
double *
i)
96 const double *data,
int n,
double tmin,
double dt)
99 const int length =
n + 6;
100 interp = malloc(
sizeof(*interp) + length *
sizeof(*interp->
a));
104 interp->
t0 = 3 - interp->
f * tmin;
106 for (
int i = 0;
i < length;
i ++)
109 for (
int j = 0;
j < 4;
j ++)
137 const double *data,
int ns,
int nt,
138 double smin,
double tmin,
double ds,
double dt)
141 const int slength =
ns + 6;
142 const int tlength = nt + 6;
143 interp = malloc(
sizeof(*interp) + slength * tlength *
sizeof(*interp->
a));
148 interp->
s0 = 3 - interp->
fs * smin;
149 interp->
t0 = 3 - interp->
ft * tmin;
152 for (
int is = 0; is < slength; is ++)
154 for (
int it = 0; it < tlength; it ++)
156 double a[4][4], a1[4][4];
157 for (
int js = 0; js < 4; js ++)
161 for (
int jt = 0; jt < 4; jt ++)
163 int kt =
clip_int(it + jt - 4, 0, nt - 1);
164 z[jt] =
data[ks *
ns + kt];
168 for (
int js = 0; js < 4; js ++)
170 for (
int jt = 0; jt < 4; jt ++)
172 a1[js][jt] =
a[jt][js];
175 for (
int js = 0; js < 4; js ++)
179 memcpy(interp->
a[is * slength + it],
a,
sizeof(
a));
195 const double (*
a)[4];
199 if (isnan(
s) || isnan(t))
204 for (
int i = 0;
i < 4;
i ++)
static double clip_double(double t, double min, double max)
bicubic_interp * bicubic_interp_init(const double *data, int ns, int nt, double smin, double tmin, double ds, double dt)
void cubic_interp_free(cubic_interp *interp)
void bicubic_interp_free(bicubic_interp *interp)
static int clip_int(int t, int min, int max)
double bicubic_interp_eval(const bicubic_interp *interp, double s, double t)
static double cubic_eval(const double *a, double t)
static void cubic_interp_index(double f, double t0, double length, double *t, double *i)
static void cubic_interp_init_coefficients(double *a, const double *z, const double *z1)
cubic_interp * cubic_interp_init(const double *data, int n, double tmin, double dt)
double cubic_interp_eval(const cubic_interp *interp, double t)