aimstil  5.0.5
cubic_spline_interpolation.tpp
Go to the documentation of this file.
1 #ifndef TIL_CUBIC_SPLINE_INTERPOLATION_TPP_
2 #define TIL_CUBIC_SPLINE_INTERPOLATION_TPP_
3 
4 namespace til
5 {
6 
7  // small helper functions
8  namespace
9  {
10  template < typename T >
11  inline T cubic_1(T x)
12  { return -0.25*cube(x-1); }
13 
14  template < typename T >
15  inline T cubic_2(T x)
16  { return 0.75*(x-3)*square(x-1)+1; }
17 
18  template < typename T >
19  inline T cubic_3(T x)
20  { return 0.75*(x-2)*square(x)+1; }
21 
22  template < typename T >
23  inline T cubic_4(T x)
24  { return 0.25*cube(x); }
25  }
26 
27  template < typename T >
28  inline T CubicSplineInterpolation<T>::compute(T f1, T f2, T f3, T f4, T x)
29  { return f1*cubic_1(x) + f2*cubic_2(x) + f3*cubic_3(x) + f4*cubic_4(x); }
30 
31 } // namespace til
32 
33 #endif /*CUBIC_SPLINE_INTERPOLATION_TPP_*/