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
21 import org.hipparchus.linear.Array2DRowRealMatrix;
22 import org.hipparchus.ode.ExpandableODE;
23 import org.hipparchus.ode.ODEStateAndDerivative;
24 import org.hipparchus.ode.sampling.AbstractODEStateInterpolator;
25
26 public class AdamsStateInterpolatorTest extends ODEStateInterpolatorAbstractTest {
27
28 @Override
29 protected AbstractODEStateInterpolator
30 setUpInterpolator(ReferenceODE eqn, double t0, double[] y0, double t1) {
31 final int nSteps = 12;
32 final double h = (t1 - t0) / (nSteps - 1);
33 final int nbPoints = (nSteps + 3) / 2;
34 final double[] t = new double[nbPoints];
35 final double[][] y = new double[nbPoints][];
36 final double[][] yDot = new double[nbPoints][];
37 for (int i = 0; i < nbPoints; ++i) {
38 t[i] = t0 + i * h;
39 y[i] = eqn.theoreticalState(t[i]);
40 yDot[i] = eqn.computeDerivatives(t[i], y[i]);
41 }
42 AdamsNordsieckTransformer transformer = AdamsNordsieckTransformer.getInstance(nSteps);
43 Array2DRowRealMatrix nordsieck = transformer.initializeHighOrderDerivatives(h, t, y, yDot);
44
45 double[] scaled = new double[eqn.getDimension()];
46 for (int i = 0; i < scaled.length; ++i) {
47 scaled[i] = h * yDot[0][i];
48 }
49 double tCurrent = t1;
50 double[] yCurrent = eqn.theoreticalState(tCurrent);
51 double[] yDotCurrent = eqn.computeDerivatives(tCurrent, yCurrent);
52
53 ODEStateAndDerivative previous = new ODEStateAndDerivative(t[0], y[0], yDot[0]);
54 ODEStateAndDerivative current = new ODEStateAndDerivative(tCurrent, yCurrent, yDotCurrent);
55 return new AdamsStateInterpolator(h, previous, scaled, nordsieck, t1 >= t0,
56 previous, current, new ExpandableODE(eqn).getMapper());
57
58 }
59
60 @Override
61 public void interpolationAtBounds() {
62
63
64
65 doInterpolationAtBounds(1.4e-6);
66 }
67
68 @Override
69 public void interpolationInside() {
70 doInterpolationInside(3.3e-10, 1.4e-6);
71 }
72
73 @Override
74 public void restrictPrevious() {
75 doRestrictPrevious(1.0e-15, 1.0e-15);
76 }
77
78 @Override
79 public void restrictCurrent() {
80 doRestrictCurrent(1.0e-15, 1.0e-15);
81 }
82
83 @Override
84 public void restrictBothEnds() {
85 doRestrictBothEnds(1.0e-15, 1.0e-15);
86 }
87
88 @Override
89 public void degenerateInterpolation() {
90 doDegenerateInterpolation();
91 }
92
93 }