1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.hipparchus.ode.nonstiff;
19
20 import org.hipparchus.ode.EquationsMapper;
21 import org.hipparchus.ode.ODEStateAndDerivative;
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 class EulerStateInterpolator
45 extends RungeKuttaStateInterpolator {
46
47
48 private static final long serialVersionUID = 20160328L;
49
50
51
52
53
54
55
56
57
58
59 EulerStateInterpolator(final boolean forward,
60 final double[][] yDotK,
61 final ODEStateAndDerivative globalPreviousState,
62 final ODEStateAndDerivative globalCurrentState,
63 final ODEStateAndDerivative softPreviousState,
64 final ODEStateAndDerivative softCurrentState,
65 final EquationsMapper mapper) {
66 super(forward, yDotK,
67 globalPreviousState, globalCurrentState, softPreviousState, softCurrentState,
68 mapper);
69 }
70
71
72 @Override
73 protected EulerStateInterpolator create(final boolean newForward, final double[][] newYDotK,
74 final ODEStateAndDerivative newGlobalPreviousState,
75 final ODEStateAndDerivative newGlobalCurrentState,
76 final ODEStateAndDerivative newSoftPreviousState,
77 final ODEStateAndDerivative newSoftCurrentState,
78 final EquationsMapper newMapper) {
79 return new EulerStateInterpolator(newForward, newYDotK,
80 newGlobalPreviousState, newGlobalCurrentState,
81 newSoftPreviousState, newSoftCurrentState,
82 newMapper);
83 }
84
85
86 @Override
87 protected ODEStateAndDerivative computeInterpolatedStateAndDerivatives(final EquationsMapper mapper,
88 final double time, final double theta,
89 final double thetaH, final double oneMinusThetaH) {
90 final double[] interpolatedState;
91 final double[] interpolatedDerivatives;
92 if (getGlobalPreviousState() != null && theta <= 0.5) {
93 interpolatedState = previousStateLinearCombination(thetaH);
94 interpolatedDerivatives = derivativeLinearCombination(1.0);
95 } else {
96 interpolatedState = currentStateLinearCombination(-oneMinusThetaH);
97 interpolatedDerivatives = derivativeLinearCombination(1.0);
98 }
99
100 return mapper.mapStateAndDerivative(time, interpolatedState, interpolatedDerivatives);
101
102 }
103
104 }