1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.hipparchus.special.elliptic.carlson;
18
19 import org.hipparchus.util.FastMath;
20 import org.hipparchus.util.MathArrays;
21
22
23
24
25 class RdRealDuplication extends RealDuplication {
26
27
28 static final double CONSTANT = 4084080;
29
30
31 static final double E2 = -875160;
32
33
34 static final double E3 = 680680;
35
36
37 static final double E2_E2 = 417690;
38
39
40 static final double E4 = -556920;
41
42
43 static final double E2_E3 = -706860;
44
45
46 static final double E5 = 471240;
47
48
49 static final double E2_E2_E2 = -255255;
50
51
52 static final double E3_E3 = 306306;
53
54
55 static final double E2_E4 = 612612;
56
57
58 static final double E2_E2_E3 = 675675;
59
60
61 static final double E3_E4_P_E2_E5 = -540540;
62
63
64 static final double DENOMINATOR = 4084080;
65
66
67 private double sum;
68
69
70
71
72
73
74 RdRealDuplication(final double x, final double y, final double z) {
75 super(x, y, z);
76 sum = 0;
77 }
78
79
80 @Override
81 protected void initialMeanPoint(final double[] va) {
82 va[3] = (va[0] + va[1] + va[2] * 3.0) / 5.0;
83 }
84
85
86 @Override
87 protected double convergenceCriterion(final double r, final double max) {
88 return max / (FastMath.sqrt(FastMath.sqrt(FastMath.sqrt(r * 0.25))));
89 }
90
91
92 @Override
93 protected void update(final int m, final double[] vaM, final double[] sqrtM, final double fourM) {
94
95
96 final double lambdaA = sqrtM[0] * sqrtM[1];
97 final double lambdaB = sqrtM[0] * sqrtM[2];
98 final double lambdaC = sqrtM[1] * sqrtM[2];
99
100
101 final double lambda = lambdaA + lambdaB + lambdaC;
102 sum += 1.0 / ((vaM[2] + lambda) * sqrtM[2] * fourM);
103
104
105 vaM[0] = MathArrays.linearCombination(0.25, vaM[0], 0.25, lambdaA, 0.25, lambdaB, 0.25, lambdaC);
106 vaM[1] = MathArrays.linearCombination(0.25, vaM[1], 0.25, lambdaA, 0.25, lambdaB, 0.25, lambdaC);
107 vaM[2] = MathArrays.linearCombination(0.25, vaM[2], 0.25, lambdaA, 0.25, lambdaB, 0.25, lambdaC);
108 vaM[3] = MathArrays.linearCombination(0.25, vaM[3], 0.25, lambdaA, 0.25, lambdaB, 0.25, lambdaC);
109
110 }
111
112
113 @Override
114 protected double evaluate(final double[] va0, final double aM, final double fourM) {
115
116
117 final double inv = 1.0 / (aM * fourM);
118 final double bigX = (va0[3] - va0[0]) * inv;
119 final double bigY = (va0[3] - va0[1]) * inv;
120 final double bigZ = (bigX + bigY) / -3;
121 final double bigXY = bigX * bigY;
122 final double bigZ2 = bigZ * bigZ;
123
124
125 final double e2 = bigXY - bigZ2 * 6;
126 final double e3 = (bigXY * 3 - bigZ2 * 8) * bigZ;
127 final double e4 = (bigXY - bigZ2) * 3 * bigZ2;
128 final double e5 = bigXY * bigZ2 * bigZ;
129
130 final double e2e2 = e2 * e2;
131 final double e2e3 = e2 * e3;
132 final double e2e4 = e2 * e4;
133 final double e2e5 = e2 * e5;
134 final double e3e3 = e3 * e3;
135 final double e3e4 = e3 * e4;
136 final double e2e2e2 = e2e2 * e2;
137 final double e2e2e3 = e2e2 * e3;
138
139
140
141 final double poly = ((e3e4 + e2e5) * E3_E4_P_E2_E5 +
142 e2e2e3 * E2_E2_E3 +
143 e2e4 * E2_E4 +
144 e3e3 * E3_E3 +
145 e2e2e2 * E2_E2_E2 +
146 e5 * E5 +
147 e2e3 * E2_E3 +
148 e4 * E4 +
149 e2e2 * E2_E2 +
150 e3 * E3 +
151 e2 * E2 +
152 CONSTANT) /
153 DENOMINATOR;
154 final double polyTerm = poly / (aM * FastMath.sqrt(aM) * fourM);
155
156 return polyTerm + sum * 3;
157
158 }
159
160 }