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.migration.ode.sampling;
24
25 import java.io.Serializable;
26
27 import org.hipparchus.exception.MathIllegalStateException;
28 import org.hipparchus.ode.ODEStateAndDerivative;
29 import org.hipparchus.ode.sampling.ODEStateInterpolator;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 @Deprecated
47 class MigrationStepInterpolator implements StepInterpolator {
48
49
50 private static final long serialVersionUID = 20160328L;
51
52
53 private final ODEStateInterpolator interpolator;
54
55
56 private ODEStateAndDerivative interpolated;
57
58
59
60
61 MigrationStepInterpolator(final ODEStateInterpolator interpolator) {
62 this.interpolator = interpolator;
63 this.interpolated = interpolator.getCurrentState();
64 }
65
66
67 @Override
68 @Deprecated
69 public double getPreviousTime() {
70 return getPreviousState().getTime();
71 }
72
73
74 @Override
75 @Deprecated
76 public double getCurrentTime() {
77 return getCurrentState().getTime();
78 }
79
80
81 @Override
82 @Deprecated
83 public double getInterpolatedTime() {
84 return interpolated.getTime();
85 }
86
87
88 @Override
89 @Deprecated
90 public void setInterpolatedTime(final double time) {
91 interpolated = getInterpolatedState(time);
92 }
93
94
95 @Override
96 @Deprecated
97 public double[] getInterpolatedState() throws MathIllegalStateException {
98 return interpolated.getPrimaryState();
99 }
100
101
102 @Override
103 @Deprecated
104 public double[] getInterpolatedDerivatives() throws MathIllegalStateException {
105 return interpolated.getPrimaryDerivative();
106 }
107
108
109 @Override
110 @Deprecated
111 public double[] getInterpolatedSecondaryState(final int index) throws MathIllegalStateException {
112 return interpolated.getSecondaryState(index);
113 }
114
115
116 @Override
117 @Deprecated
118 public double[] getInterpolatedSecondaryDerivatives(final int index) throws MathIllegalStateException {
119 return interpolated.getSecondaryDerivative(index);
120 }
121
122
123 @Override
124 public boolean isForward() {
125 return interpolator.isForward();
126 }
127
128
129 @Override
130 public MigrationStepInterpolator copy() throws MathIllegalStateException {
131 return new MigrationStepInterpolator(interpolator);
132 }
133
134
135 @Override
136 public ODEStateAndDerivative getPreviousState() {
137 return interpolator.getPreviousState();
138 }
139
140
141 @Override
142 public boolean isPreviousStateInterpolated() {
143 return interpolator.isPreviousStateInterpolated();
144 }
145
146
147 @Override
148 public ODEStateAndDerivative getCurrentState() {
149 return interpolator.getCurrentState();
150 }
151
152
153 @Override
154 public boolean isCurrentStateInterpolated() {
155 return interpolator.isCurrentStateInterpolated();
156 }
157
158
159 @Override
160 public ODEStateAndDerivative getInterpolatedState(final double time) {
161 return interpolator.getInterpolatedState(time);
162 }
163
164
165
166
167
168 private Object writeReplace() {
169 return new DataTransferObject(interpolator, interpolated.getTime());
170 }
171
172
173 private static class DataTransferObject implements Serializable {
174
175
176 private static final long serialVersionUID = 20160328L;
177
178
179
180
181 private final ODEStateInterpolator interpolator;
182
183
184
185
186 private final double time;
187
188
189
190
191
192 DataTransferObject(final ODEStateInterpolator interpolator, final double time) {
193 this.interpolator = interpolator;
194 this.time = time;
195 }
196
197
198
199
200 private Object readResolve() {
201 final MigrationStepInterpolator msi = new MigrationStepInterpolator(interpolator);
202 msi.setInterpolatedTime(time);
203 return msi;
204 }
205
206 }
207
208 }