52 static double interp6(
double x,
const double v[6],
const double eps=std::numeric_limits<double>::epsilon() ) {
54 const double &f_m2 = v[0];
const double &f_m1 = v[1];
const double &f_p0 = v[2];
55 const double &f_p1 = v[3];
const double &f_p2 = v[4];
const double &f_p3 = v[5];
57 const double x_m2 = -2.0;
const double x_m1 = -1.0;
const double x_p0 = 0.0;
58 const double x_p1 = 1.0;
const double x_p2 = 2.0;
const double x_p3 = 3.0;
61 C[0] = (x_p2-x) * (x_p3-x) / 20.0;
62 C[1] = (x_p3-x) * (x-x_m2) / 10.0;
63 C[2] = (x-x_m2) * (x-x_m1) / 20.0;
66 S[0] = ((0814.*sqr(f_p1))+(4326.*sqr(f_p0))+(2976.*sqr(f_m1))+(0244.*sqr(f_m2))-(3579.*f_p0*f_p1)-(6927.*f_p0*f_m1)+(1854.*f_p0*f_m2)+(2634.*f_p1*f_m1)-(0683.*f_p1*f_m2)-(1659.*f_m1*f_m2)) / 180.0;
67 S[1] = ((1986.*sqr(f_p1))+(1986.*sqr(f_p0))+(0244.*sqr(f_m1))+(0244.*sqr(f_p2))+(1074.*f_p0*f_p2)-(3777.*f_p0*f_p1)-(1269.*f_p0*f_m1)+(1074.*f_p1*f_m1)-(1269.*f_p2*f_p1)-(0293.*f_p2*f_m1)) / 180.0;
68 S[2] = ((0814.*sqr(f_p0))+(4326.*sqr(f_p1))+(2976.*sqr(f_p2))+(0244.*sqr(f_p3))-(0683.*f_p0*f_p3)+(2634.*f_p0*f_p2)-(3579.*f_p0*f_p1)-(6927.*f_p1*f_p2)+(1854.*f_p1*f_p3)-(1659.*f_p2*f_p3)) / 180.0;
71 P[0] = f_m2 + (f_m1-f_m2) * (x-x_m2) + (f_p0-2.*f_m1+f_m2) * (x-x_m2) * (x-x_m1) / 2.0 + (f_p1-3.*f_p0+3.*f_m1-f_m2) * (x-x_m2) * (x-x_m1) * (x-x_p0) / 6.0;
72 P[1] = f_m1 + (f_p0-f_m1) * (x-x_m1) + (f_p1-2.*f_p0+f_m1) * (x-x_m1) * (x-x_p0) / 2.0 + (f_p2-3.*f_p1+3.*f_p0-f_m1) * (x-x_m1) * (x-x_p0) * (x-x_p1) / 6.0;
73 P[2] = f_p0 + (f_p1-f_p0) * (x-x_p0) + (f_p2-2.*f_p1+f_p0) * (x-x_p0) * (x-x_p1) / 2.0 + (f_p3-3.*f_p2+3.*f_p1-f_p0) * (x-x_p0) * (x-x_p1) * (x-x_p2) / 6.0;
75 double a[3], sum(0.0);
76 for(
int i=0; i<3; ++i ) {
77 a[i] = C[i] / (eps+sqr(S[i]));
81 for(
int i=0; i<3; ++i ) {
85 return w[0]*P[0]+w[1]*P[1]+w[2]*P[2];
97 static double interp4(
double x,
const double v[4],
const double eps=std::numeric_limits<double>::epsilon() ) {
99 const double &f_m1 = v[0];
const double &f_p0 = v[1];
100 const double &f_p1 = v[2];
const double &f_p2 = v[3];
102 const double x_m1 = -1.0;
const double x_p0 = 0.0;
103 const double x_p1 = 1.0;
const double x_p2 = 2.0;
107 C[0] = (x_p2-x) / 3.0;
108 C[1] = (x-x_m1) / 3.0;
111 S[0] = ((26.*f_p1*f_m1)-(52.*f_p0*f_m1)-(76.*f_p1*f_p0)+(25.*sqr(f_p1))+(64.*sqr(f_p0))+(13.*sqr(f_m1))) / 12.0;
112 S[1] = ((26.*f_p2*f_p0)-(52.*f_p2*f_p1)-(76.*f_p1*f_p0)+(25.*sqr(f_p0))+(64.*sqr(f_p1))+(13.*sqr(f_p2))) / 12.0;
115 P[0] = f_p0 + (f_p1-f_m1) * (x-x_p0) / 2.0 + (f_p1-2.*f_p0+f_m1) * sqr(x-x_p0) / 2.0;
116 P[1] = f_p0 + (-f_p2+4.*f_p1-3.*f_p0) * (x-x_p0) / 2.0 + (f_p2-2.*f_p1+f_p0) * sqr(x-x_p0) / 2.0;
118 double a[2], sum(0.0);
119 for(
int i=0; i<2; ++i ) {
120 a[i] = C[i] / (eps+sqr(S[i]));
124 for(
int i=0; i<2; ++i ) {
128 return w[0]*P[0]+w[1]*P[1];
131 static double sqr (
const double &x) {
return x*x; }