OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
lambda_kernel.hpp
1 //
2 // Created by Abhinav Singh on 13.01.21.
3 //
4 
5 #ifndef OPENFPM_PDATA_LAMBDAKERNEL_HPP
6 #define OPENFPM_PDATA_LAMBDAKERNEL_HPP
7 
8 #include <iostream>
9 
10 template<typename st>
11 double horner(const std::array<double,10> &v, st x)
12 {
13  st s = 0;
14  for(int i=9; i>=0; i--)
15  s = v[i] + (s * x);
16  return s;
17 }
18 
19 constexpr std::array<double,10> c1={(1.0 * 12.0) , (0.0 * 12.0) , -(5.0 * 3.0) , (0.0 * 12.0) , (1.0 * 3.0) , -(100.0 * 4.0) , (455.0 * 3.0) , -(295.0 * 6.0) , (345.0 * 3.0) , -(115.0 * 2.0) };
20 constexpr std::array<double,10> c2={-(199.0 * 24.0) , (5485.0 * 6.0) , -(32975.0 * 3.0) , (28425.0 * 6.0) , -(61953.0 * 3.0) , (33175.0 * 4.0) , -(20685.0 * 3.0) , (3055.0 * 6.0) , -(1035.0 * 3.0) , (115.0 * 2.0) };
21 constexpr std::array<double,10> c3={(5913.0 * 24.0) , -(89235.0 * 6.0) , (297585.0 * 3.0) , -(143895.0 * 6.0) , (177871.0 * 3.0) , -(54641.0 * 4.0) , (19775.0 * 3.0) , -(1715.0 * 6.0) , (345.0 * 3.0) , -(23.0 * 2.0)};
22 
23 
24 template<typename st>
26 {
27 public:
28  static const int np = 6;
29  static inline st value(st x, size_t i)
30  {
31  if (i == 0)
32  return horner(c3, -x) / 24.0;
33  else if (i == 1)
34  return horner(c2, -x) / 24.0;
35  else if (i == 2)
36  return horner(c1, -x) / 12.0;
37  else if (i == 3)
38  return horner(c1, x) / 12.0;
39  else if (i == 4)
40  return horner(c2, x) / 24.0;
41  else if (i == 5)
42  return horner(c3, x) / 24.0;
43  return 0.0;
44  }
45 };
46 
47 #endif //OPENFPM_PDATA_LAMBDAKERNEL_HPP