aimstil  5.0.5
LagrangeInterpolation.h
Go to the documentation of this file.
1 #ifndef TIL_LAGRANGE_INTERPOLATION_H
2 #define TIL_LAGRANGE_INTERPOLATION_H
3 
4 // includes from TIL library
5 #include "til/til_common.h"
6 #include "til/labels.h"
7 
8 namespace til
9 {
10 
18  // NOTE: The templating has been done on the function members rather than on
19  // the class itself, to make use of the automatic template deduction of functions.
20  // It may be changed.
21  template < typename T >
23  : public Interpolator_label
24  {
25  public: // static members ---------------------------------------------------
26 
28  // NB: There is a priori no reason for f to be the same type as x.
29  // However, forcing x and f to have the same type forces the
30  // (necessary anyway) casting to be done once, before function
31  // call.
32  inline static T compute(
33  T f1,
34  T f2,
35  T f3,
36  T f4,
37  T x
38  )
39  {
40  return (((3*(f2-f3)+f4-f1)/6.0*x+((f1+f3)/2.0-f2))*x+(6*f3-2*f1-3*f2-f4)/6.0)*x+f2;
41  }
42  };
43 
44 }
45 
46 #endif
47 
Interpolation using Lagrange polynomials of order 4.
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
static T compute(T f1, T f2, T f3, T f4, T x)
Returns the interpolated value of four numbers using Lagrange4 method.
General macros, definitions and functions.
Defines empty classes that serves as labels.