1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.hipparchus.analysis.integration.gauss;
23
24 import java.util.ArrayList;
25 import java.util.Collection;
26
27 import org.hipparchus.util.Binary64;
28 import org.hipparchus.util.Binary64Field;
29 import org.hipparchus.util.FastMath;
30 import org.junit.runner.RunWith;
31 import org.junit.runners.Parameterized;
32 import org.junit.runners.Parameterized.Parameters;
33
34
35
36
37
38
39
40
41
42 @RunWith(value=Parameterized.class)
43 public class FieldHermiteParametricTest extends FieldGaussianQuadratureAbstractTest {
44 private static final double SQRT_PI = FastMath.sqrt(Math.PI);
45 private static final FieldGaussIntegratorFactory<Binary64> factory = new FieldGaussIntegratorFactory<>(Binary64Field.getInstance());
46
47
48
49
50 public static final int MAX_NUM_POINTS = 30;
51
52
53
54
55
56
57
58
59
60
61 public FieldHermiteParametricTest(int numberOfPoints,
62 int maxDegree,
63 double eps,
64 double numUlps) {
65 super(factory.hermite(numberOfPoints),
66 maxDegree, eps, numUlps);
67 }
68
69
70
71
72
73
74
75
76
77 @Parameters
78 public static Collection<Object[]> getParameters() {
79 final ArrayList<Object[]> parameters = new ArrayList<Object[]>();
80 final int [] numUlps = {
81 10, 10, 10, 10, 20,
82 20, 30, 30, 30, 40,
83 40, 60, 150, 150, 150,
84 150, 150, 150, 150, 200,
85 250, 250, 300, 300, 300,
86 300, 300, 300, 350, 350
87 };
88 for (int k = 1; k <= MAX_NUM_POINTS; k++) {
89 parameters.add(new Object[] { k, 2 * k - 1, Math.ulp(1d), numUlps[k - 1] });
90 }
91 return parameters;
92 }
93
94 @Override
95 public double getExpectedValue(final int n) {
96 if (n % 2 == 1) {
97 return 0;
98 }
99
100 final int iMax = n / 2;
101 double p = 1;
102 double q = 1;
103 for (int i = 0; i < iMax; i++) {
104 p *= 2 * i + 1;
105 q *= 2;
106 }
107
108 return p / q * SQRT_PI;
109 }
110 }