OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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
10template<typename st>
11double horner(const double *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//These needs to be Checked
19double c1[10]={(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) };
20double c2[10]={-(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) };
21double c3[10]={(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
24template<typename st>
26{
27public:
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
48template<typename st>
49double horner22(const double *v, st x)
50{
51 st s = 0;
52 for(int i=5; i>=0; i--)
53 s = v[i] + (s * x);
54 return s;
55}
56
57double c221[6]={1.0,0.0,-1.0,-4.5,7.5,-3.0};
58double c222[6]={-4.0,18.0,-29.0,21.5,-7.5,1.0};
59
60
61template<typename st>
63{
64public:
65 static const int np = 6;
66 static inline st value(st x, size_t i)
67 {
68 if (i == 0)
69 return horner22(c221, -x);
70 else if (i == 1)
71 return horner22(c222, -x);
72 return 0.0;
73 }
74};
75
76#endif //OPENFPM_PDATA_LAMBDAKERNEL_HPP