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
57
58
59
60
61
62
63
64
65 public class LutherFieldIntegrator<T extends CalculusFieldElement<T>>
66 extends RungeKuttaFieldIntegrator<T> {
67
68
69 public static final String METHOD_NAME = LutherIntegrator.METHOD_NAME;
70
71
72
73
74
75
76 public LutherFieldIntegrator(final Field<T> field, final T step) {
77 super(field, METHOD_NAME, step);
78 }
79
80
81 @Override
82 public T[] getC() {
83 final T q = getField().getZero().add(21).sqrt();
84 final T[] c = MathArrays.buildArray(getField(), 6);
85 c[0] = getField().getOne();
86 c[1] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 2);
87 c[2] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 2, 3);
88 c[3] = q.subtract(7).divide(-14);
89 c[4] = q.add(7).divide(14);
90 c[5] = getField().getOne();
91 return c;
92 }
93
94
95 @Override
96 public T[][] getA() {
97 final T q = getField().getZero().add(21).sqrt();
98 final T[][] a = MathArrays.buildArray(getField(), 6, -1);
99 for (int i = 0; i < a.length; ++i) {
100 a[i] = MathArrays.buildArray(getField(), i + 1);
101 }
102 a[0][0] = getField().getOne();
103 a[1][0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 3, 8);
104 a[1][1] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 8);
105 a[2][0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 8, 27);
106 a[2][1] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 2, 27);
107 a[2][2] = a[2][0];
108 a[3][0] = q.multiply( 9).add( -21).divide( 392);
109 a[3][1] = q.multiply( 8).add( -56).divide( 392);
110 a[3][2] = q.multiply( -48).add( 336).divide( 392);
111 a[3][3] = q.multiply( 3).add( -63).divide( 392);
112 a[4][0] = q.multiply(-255).add(-1155).divide(1960);
113 a[4][1] = q.multiply( -40).add( -280).divide(1960);
114 a[4][2] = q.multiply(-320) .divide(1960);
115 a[4][3] = q.multiply( 363).add( 63).divide(1960);
116 a[4][4] = q.multiply( 392).add( 2352).divide(1960);
117 a[5][0] = q.multiply( 105).add( 330).divide( 180);
118 a[5][1] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 2, 3);
119 a[5][2] = q.multiply( 280).add( -200).divide( 180);
120 a[5][3] = q.multiply(-189).add( 126).divide( 180);
121 a[5][4] = q.multiply(-126).add( -686).divide( 180);
122 a[5][5] = q.multiply( -70).add( 490).divide( 180);
123 return a;
124 }
125
126
127 @Override
128 public T[] getB() {
129
130 final T[] b = MathArrays.buildArray(getField(), 7);
131 b[0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 20);
132 b[1] = getField().getZero();
133 b[2] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 16, 45);
134 b[3] = getField().getZero();
135 b[4] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 49, 180);
136 b[5] = b[4];
137 b[6] = b[0];
138
139 return b;
140
141 }
142
143
144 @Override
145 protected LutherFieldStateInterpolator<T>
146 createInterpolator(final boolean forward, T[][] yDotK,
147 final FieldODEStateAndDerivative<T> globalPreviousState,
148 final FieldODEStateAndDerivative<T> globalCurrentState,
149 final FieldEquationsMapper<T> mapper) {
150 return new LutherFieldStateInterpolator<T>(getField(), forward, yDotK,
151 globalPreviousState, globalCurrentState,
152 globalPreviousState, globalCurrentState,
153 mapper);
154 }
155
156 }