}
@Test
public void checkClone()
{
TestProblem3 pb = new TestProblem3(0.9);
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
double scalAbsoluteTolerance = 1.0e-8;
double scalRelativeTolerance = scalAbsoluteTolerance;
HighamHall54Integrator integ = new HighamHall54Integrator(minStep, maxStep,
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.addStepHandler(new StepHandler() {
public void handleStep(StepInterpolator interpolator, boolean isLast) {
StepInterpolator cloned = interpolator.copy();
double tA = cloned.getPreviousTime();
double tB = cloned.getCurrentTime();
double halfStep = FastMath.abs(tB - tA) / 2;
Assert.assertEquals(interpolator.getPreviousTime(), tA, 1.0e-12);
Assert.assertEquals(interpolator.getCurrentTime(), tB, 1.0e-12);
for (int i = 0; i < 10; ++i) {
double t = (i * tB + (9 - i) * tA) / 9;
interpolator.setInterpolatedTime(t);
Assert.assertTrue(FastMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
cloned.setInterpolatedTime(t);
Assert.assertEquals(t, cloned.getInterpolatedTime(), 1.0e-12);
double[] referenceState = interpolator.getInterpolatedState();
double[] cloneState = cloned.getInterpolatedState();
for (int j = 0; j < referenceState.length; ++j) {
Assert.assertEquals(referenceState[j], cloneState[j], 1.0e-12);
}
}
}
public void init(double t0, double[] y0, double t) {
}
});
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
}