13 inline double h00(
double t )
15 return (1.0+2.0*t)*(1.0-t)*(1.0-t);
17 inline double h10(
double t )
19 return t*(1.0-t)*(1.0-t);
22 inline long bisect (
const std::vector<double> &x,
double xval )
25 long ilo = 0, ihi = n-1;
32 long imid = (ilo+ihi)/2;
44 : m_x(x,x+n), m_y(y,y+n), m_g(n)
47 std::vector<double> d(n-1),h(n-1);
48 for (
long k=0;k<n-1;++k)
51 d[k] = (y[k+1]-y[k])/h[k];
54 for (
long k=1;k<n-1;++k)
59 double a = (h[k-1]+2.0*h[k])/(3.0*(h[k-1]+h[k]));
60 m_g[k] /= (a*d[k]+(1-a)*d[k-1]);
83 else if( xval >=
m_x[
m_x.size()-1] )
89 long k = bisect(
m_x, xval );
90 double h =
m_x[k+1]-
m_x[k], t = (xval-m_x[k])/h;
91 yval =
m_y[k]*h00(t) + h*
m_g[k]*h10(t)
92 +
m_y[k+1]*h00(1.0-t) - h*
m_g[k+1]*h10(1.0-t);
Monointerp(const double x[], const double y[], long n)
std::vector< double > m_g
double operator()(double xval) const
const std::vector< double > m_x
const std::vector< double > m_y