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.CalculusFieldElement;
20 import org.hipparchus.complex.Complex;
21 import org.hipparchus.complex.FieldComplex;
22 import org.hipparchus.util.FastMath;
23
24
25
26
27
28 class RcFieldDuplication<T extends CalculusFieldElement<T>> extends FieldDuplication<T> {
29
30
31
32
33
34 RcFieldDuplication(final T x, final T y) {
35 super(x, y);
36 }
37
38
39 @Override
40 protected void initialMeanPoint(final T[] va) {
41 va[2] = va[0].add(va[1].multiply(2)).divide(3.0);
42 }
43
44
45 @Override
46 protected T convergenceCriterion(final T r, final T max) {
47 return max.divide(FastMath.sqrt(FastMath.sqrt(FastMath.sqrt(r.multiply(3.0)))));
48 }
49
50
51 @Override
52 protected void update(final int m, final T[] vaM, final T[] sqrtM, final double fourM) {
53 final T lambdaA = sqrtM[0].multiply(sqrtM[1]).multiply(2);
54 final T lambdaB = vaM[1];
55 vaM[0] = vaM[0].linearCombination(0.25, vaM[0], 0.25, lambdaA, 0.25, lambdaB);
56 vaM[1] = vaM[1].linearCombination(0.25, vaM[1], 0.25, lambdaA, 0.25, lambdaB);
57 vaM[2] = vaM[2].linearCombination(0.25, vaM[2], 0.25, lambdaA, 0.25, lambdaB);
58 }
59
60
61 @Override
62 protected T evaluate(final T[] va0, final T aM, final double fourM) {
63
64
65 final T s = va0[1].subtract(va0[2]).divide(aM.multiply(fourM));
66
67
68 final T poly = s.multiply(RcRealDuplication.S7).
69 add(RcRealDuplication.S6).multiply(s).
70 add(RcRealDuplication.S5).multiply(s).
71 add(RcRealDuplication.S4).multiply(s).
72 add(RcRealDuplication.S3).multiply(s).
73 add(RcRealDuplication.S2).multiply(s).
74 multiply(s).
75 add(RcRealDuplication.S0).
76 divide(RcRealDuplication.DENOMINATOR);
77 return poly.divide(FastMath.sqrt(aM));
78
79 }
80
81 }