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 public class MidpointFieldIntegrator<T extends CalculusFieldElement<T>> extends RungeKuttaFieldIntegrator<T> {
54
55
56 public static final String METHOD_NAME = MidpointIntegrator.METHOD_NAME;
57
58
59
60
61
62
63 public MidpointFieldIntegrator(final Field<T> field, final T step) {
64 super(field, METHOD_NAME, step);
65 }
66
67
68 @Override
69 public T[] getC() {
70 final T[] c = MathArrays.buildArray(getField(), 1);
71 c[0] = getField().getOne().newInstance(0.5);
72 return c;
73 }
74
75
76 @Override
77 public T[][] getA() {
78 final T[][] a = MathArrays.buildArray(getField(), 1, 1);
79 a[0][0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 2);
80 return a;
81 }
82
83
84 @Override
85 public T[] getB() {
86 final T[] b = MathArrays.buildArray(getField(), 2);
87 b[0] = getField().getZero();
88 b[1] = getField().getOne();
89 return b;
90 }
91
92
93 @Override
94 protected MidpointFieldStateInterpolator<T>
95 createInterpolator(final boolean forward, T[][] yDotK,
96 final FieldODEStateAndDerivative<T> globalPreviousState,
97 final FieldODEStateAndDerivative<T> globalCurrentState,
98 final FieldEquationsMapper<T> mapper) {
99 return new MidpointFieldStateInterpolator<T>(getField(), forward, yDotK,
100 globalPreviousState, globalCurrentState,
101 globalPreviousState, globalCurrentState,
102 mapper);
103 }
104
105 }