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