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 public class ClassicalRungeKuttaFieldIntegrator<T extends CalculusFieldElement<T>>
56 extends RungeKuttaFieldIntegrator<T> {
57
58
59 public static final String METHOD_NAME = ClassicalRungeKuttaIntegrator.METHOD_NAME;
60
61
62
63
64
65
66 public ClassicalRungeKuttaFieldIntegrator(final Field<T> field, final T step) {
67 super(field, METHOD_NAME, step);
68 }
69
70
71 @Override
72 public T[] getC() {
73 final T[] c = MathArrays.buildArray(getField(), 3);
74 c[0] = getField().getOne().newInstance(0.5);
75 c[1] = c[0];
76 c[2] = getField().getOne();
77 return c;
78 }
79
80
81 @Override
82 public T[][] getA() {
83 final T[][] a = MathArrays.buildArray(getField(), 3, -1);
84 for (int i = 0; i < a.length; ++i) {
85 a[i] = MathArrays.buildArray(getField(), i + 1);
86 }
87 a[0][0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 2);
88 a[1][0] = getField().getZero();
89 a[1][1] = a[0][0];
90 a[2][0] = getField().getZero();
91 a[2][1] = getField().getZero();
92 a[2][2] = getField().getOne();
93 return a;
94 }
95
96
97 @Override
98 public T[] getB() {
99 final T[] b = MathArrays.buildArray(getField(), 4);
100 b[0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 6);
101 b[1] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 3);
102 b[2] = b[1];
103 b[3] = b[0];
104 return b;
105 }
106
107
108 @Override
109 protected ClassicalRungeKuttaFieldStateInterpolator<T>
110 createInterpolator(final boolean forward, T[][] yDotK,
111 final FieldODEStateAndDerivative<T> globalPreviousState,
112 final FieldODEStateAndDerivative<T> globalCurrentState,
113 final FieldEquationsMapper<T> mapper) {
114 return new ClassicalRungeKuttaFieldStateInterpolator<T>(getField(), forward, yDotK,
115 globalPreviousState, globalCurrentState,
116 globalPreviousState, globalCurrentState,
117 mapper);
118 }
119
120 }