diff --git a/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java b/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java index ea042e52a..3eb9ddd5d 100644 --- a/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java +++ b/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java @@ -332,7 +332,7 @@ public abstract class AdaptiveStepsizeIntegrator return stepStart; } - public double getCurrentStepsize() { + public double getCurrentSignedStepsize() { return stepSize; } diff --git a/src/java/org/apache/commons/math/ode/FirstOrderIntegrator.java b/src/java/org/apache/commons/math/ode/FirstOrderIntegrator.java index 1d0c3520d..91c47d43d 100644 --- a/src/java/org/apache/commons/math/ode/FirstOrderIntegrator.java +++ b/src/java/org/apache/commons/math/ode/FirstOrderIntegrator.java @@ -67,7 +67,7 @@ public interface FirstOrderIntegrator { *

This method solves an Initial Value Problem (IVP).

*

Since this method stores some internal state variables made * available in its public interface during integration ({@link - * #getCurrentStepsize()}), it is not thread-safe.

+ * #getCurrentSignedStepsize()}), it is not thread-safe.

* @param equations differential equations to integrate * @param t0 initial time * @param y0 initial value of the state vector at t0 @@ -95,15 +95,15 @@ public interface FirstOrderIntegrator { */ public double getCurrentStepStart(); - /** Get the current value of the integration stepsize. + /** Get the current signed value of the integration stepsize. *

This method can be called during integration (typically by * the object implementing the {@link FirstOrderDifferentialEquations - * differential equations} problem) if the value of the current stepsize + * differential equations} problem) if the signed value of the current stepsize * that is tried is needed.

*

The result is undefined if the method is called outside of * calls to {@link #integrate}

- * @return current value of the stepsize + * @return current signed value of the stepsize */ - public double getCurrentStepsize(); + public double getCurrentSignedStepsize(); } diff --git a/src/java/org/apache/commons/math/ode/GraggBulirschStoerIntegrator.java b/src/java/org/apache/commons/math/ode/GraggBulirschStoerIntegrator.java index 4dd6e7010..3970202ca 100644 --- a/src/java/org/apache/commons/math/ode/GraggBulirschStoerIntegrator.java +++ b/src/java/org/apache/commons/math/ode/GraggBulirschStoerIntegrator.java @@ -850,17 +850,18 @@ public class GraggBulirschStoerIntegrator if (! reject) { // store end of step state - stepStart += stepSize; + double nextStep = stepStart + stepSize; System.arraycopy(y1, 0, y, 0, y0.length); - switchesHandler.stepAccepted(stepStart, y); + switchesHandler.stepAccepted(nextStep, y); if (switchesHandler.stop()) { lastStep = true; } // provide the step data to the step handler - interpolator.storeTime(stepStart); + interpolator.storeTime(nextStep); handler.handleStep(interpolator, lastStep); + stepStart = nextStep; if (switchesHandler.reset(stepStart, y) && ! lastStep) { // some switching function has triggered changes that diff --git a/src/java/org/apache/commons/math/ode/RungeKuttaFehlbergIntegrator.java b/src/java/org/apache/commons/math/ode/RungeKuttaFehlbergIntegrator.java index c6ba1cfb1..83cedf302 100644 --- a/src/java/org/apache/commons/math/ode/RungeKuttaFehlbergIntegrator.java +++ b/src/java/org/apache/commons/math/ode/RungeKuttaFehlbergIntegrator.java @@ -274,18 +274,19 @@ public abstract class RungeKuttaFehlbergIntegrator } // the step has been accepted - stepStart += stepSize; + double nextStep = stepStart + stepSize; System.arraycopy(yTmp, 0, y, 0, y0.length); - switchesHandler.stepAccepted(stepStart, y); + switchesHandler.stepAccepted(nextStep, y); if (switchesHandler.stop()) { lastStep = true; } else { - lastStep = forward ? (stepStart >= t) : (stepStart <= t); + lastStep = forward ? (nextStep >= t) : (nextStep <= t); } // provide the step data to the step handler - interpolator.storeTime(stepStart); + interpolator.storeTime(nextStep); handler.handleStep(interpolator, lastStep); + stepStart = nextStep; if (fsal) { // save the last evaluation for the next step diff --git a/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java b/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java index b22625662..d6206c8e2 100644 --- a/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java +++ b/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java @@ -219,9 +219,9 @@ public abstract class RungeKuttaIntegrator } // the step has been accepted - stepStart += stepSize; + double nextStep = stepStart + stepSize; System.arraycopy(yTmp, 0, y, 0, y0.length); - switchesHandler.stepAccepted(stepStart, y); + switchesHandler.stepAccepted(nextStep, y); if (switchesHandler.stop()) { lastStep = true; } else { @@ -229,8 +229,9 @@ public abstract class RungeKuttaIntegrator } // provide the step data to the step handler - interpolator.storeTime(stepStart); + interpolator.storeTime(nextStep); handler.handleStep(interpolator, lastStep); + stepStart = nextStep; if (switchesHandler.reset(stepStart, y) && ! lastStep) { // some switching function has triggered changes that @@ -256,7 +257,7 @@ public abstract class RungeKuttaIntegrator return stepStart; } - public double getCurrentStepsize() { + public double getCurrentSignedStepsize() { return stepSize; }