1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.hipparchus.ode.nonstiff;
24
25 import org.hipparchus.CalculusFieldElement;
26 import org.hipparchus.Field;
27 import org.hipparchus.ode.FieldEquationsMapper;
28 import org.hipparchus.ode.FieldODEStateAndDerivative;
29 import org.hipparchus.util.MathArrays;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 public class GillFieldIntegrator<T extends CalculusFieldElement<T>>
57 extends RungeKuttaFieldIntegrator<T> {
58
59
60 public static final String METHOD_NAME = GillIntegrator.METHOD_NAME;
61
62
63
64
65
66
67 public GillFieldIntegrator(final Field<T> field, final T step) {
68 super(field, METHOD_NAME, step);
69 }
70
71
72 @Override
73 public T[] getC() {
74 final T[] c = MathArrays.buildArray(getField(), 3);
75 c[0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 2);
76 c[1] = c[0];
77 c[2] = getField().getOne();
78 return c;
79 }
80
81
82 @Override
83 public T[][] getA() {
84
85 final T two = getField().getZero().add(2);
86 final T sqrtTwo = two.sqrt();
87
88 final T[][] a = MathArrays.buildArray(getField(), 3, -1);
89 for (int i = 0; i < a.length; ++i) {
90 a[i] = MathArrays.buildArray(getField(), i + 1);
91 }
92 a[0][0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 2);
93 a[1][0] = sqrtTwo.subtract(1).multiply(0.5);
94 a[1][1] = sqrtTwo.subtract(2).multiply(-0.5);
95 a[2][0] = getField().getZero();
96 a[2][1] = sqrtTwo.multiply(-0.5);
97 a[2][2] = sqrtTwo.add(2).multiply(0.5);
98 return a;
99 }
100
101
102 @Override
103 public T[] getB() {
104
105 final T two = getField().getZero().add(2);
106 final T sqrtTwo = two.sqrt();
107
108 final T[] b = MathArrays.buildArray(getField(), 4);
109 b[0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 6);
110 b[1] = sqrtTwo.subtract(2).divide(-6);
111 b[2] = sqrtTwo.add(2).divide(6);
112 b[3] = b[0];
113
114 return b;
115
116 }
117
118
119 @Override
120 protected GillFieldStateInterpolator<T>
121 createInterpolator(final boolean forward, T[][] yDotK,
122 final FieldODEStateAndDerivative<T> globalPreviousState,
123 final FieldODEStateAndDerivative<T> globalCurrentState,
124 final FieldEquationsMapper<T> mapper) {
125 return new GillFieldStateInterpolator<T>(getField(), forward, yDotK,
126 globalPreviousState, globalCurrentState,
127 globalPreviousState, globalCurrentState,
128 mapper);
129 }
130
131 }