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 RcRealDuplication extends RealDuplication {
26
27
28 static final double S0 = 80080;
29
30
31 static final double S2 = 24024;
32
33
34 static final double S3 = 11440;
35
36
37 static final double S4 = 30030;
38
39
40 static final double S5 = 32760;
41
42
43 static final double S6 = 61215;
44
45
46 static final double S7 = 90090;
47
48
49 static final double DENOMINATOR = 80080;
50
51
52
53
54
55 RcRealDuplication(final double x, final double y) {
56 super(x, y);
57 }
58
59
60 @Override
61 protected void initialMeanPoint(final double[] va) {
62 va[2] = (va[0] + va[1] * 2) / 3.0;
63 }
64
65
66 @Override
67 protected double convergenceCriterion(final double r, final double max) {
68 return max / FastMath.sqrt(FastMath.sqrt(FastMath.sqrt(r * 3.0)));
69 }
70
71
72 @Override
73 protected void update(final int m, final double[] vaM, final double[] sqrtM, final double fourM) {
74 final double lambdaA = sqrtM[0] * sqrtM[1] * 2;
75 final double lambdaB = vaM[1];
76 vaM[0] = MathArrays.linearCombination(0.25, vaM[0], 0.25, lambdaA, 0.25, lambdaB);
77 vaM[1] = MathArrays.linearCombination(0.25, vaM[1], 0.25, lambdaA, 0.25, lambdaB);
78 vaM[2] = MathArrays.linearCombination(0.25, vaM[2], 0.25, lambdaA, 0.25, lambdaB);
79 }
80
81
82 @Override
83 protected double evaluate(final double[] va0, final double aM, final double fourM) {
84
85
86 final double s = (va0[1] - va0[2]) / (aM * fourM);
87
88
89 final double poly = ((((((S7 * s + S6) * s + S5) * s + S4) * s + S3) * s + S2) * s * s + S0) / DENOMINATOR;
90 return poly / FastMath.sqrt(aM);
91
92 }
93
94 }