You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2007/11/03 19:46:11 UTC

svn commit: r591661 - in /commons/proper/math/trunk/src/java/org/apache/commons/math/ode: AdaptiveStepsizeIntegrator.java FirstOrderIntegrator.java GraggBulirschStoerIntegrator.java RungeKuttaFehlbergIntegrator.java RungeKuttaIntegrator.java

Author: luc
Date: Sat Nov  3 11:46:11 2007
New Revision: 591661

URL: http://svn.apache.org/viewvc?rev=591661&view=rev
Log:
delayed integrator internal state update after the call to step handler
to ensure integrator.getStepStart() and interpolator.getPreviousTime()
are consistent.
renamed getStepsize() into getSignedStepsize()

Modified:
    commons/proper/math/trunk/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/ode/FirstOrderIntegrator.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/ode/GraggBulirschStoerIntegrator.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/ode/RungeKuttaFehlbergIntegrator.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java?rev=591661&r1=591660&r2=591661&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java Sat Nov  3 11:46:11 2007
@@ -332,7 +332,7 @@
     return stepStart;
   }
 
-  public double getCurrentStepsize() {
+  public double getCurrentSignedStepsize() {
     return stepSize;
   }
 

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/ode/FirstOrderIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/ode/FirstOrderIntegrator.java?rev=591661&r1=591660&r2=591661&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/ode/FirstOrderIntegrator.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/ode/FirstOrderIntegrator.java Sat Nov  3 11:46:11 2007
@@ -67,7 +67,7 @@
    * <p>This method solves an Initial Value Problem (IVP).</p>
    * <p>Since this method stores some internal state variables made
    * available in its public interface during integration ({@link
-   * #getCurrentStepsize()}), it is <em>not</em> thread-safe.</p>
+   * #getCurrentSignedStepsize()}), it is <em>not</em> thread-safe.</p>
    * @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 double getCurrentStepStart();
 
-  /** Get the current value of the integration stepsize.
+  /** Get the current signed value of the integration stepsize.
    * <p>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.</p>
    * <p>The result is undefined if the method is called outside of
    * calls to {@link #integrate}</p>
-   * @return current value of the stepsize
+   * @return current signed value of the stepsize
    */
-  public double getCurrentStepsize();
+  public double getCurrentSignedStepsize();
 
 }

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/ode/GraggBulirschStoerIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/ode/GraggBulirschStoerIntegrator.java?rev=591661&r1=591660&r2=591661&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/ode/GraggBulirschStoerIntegrator.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/ode/GraggBulirschStoerIntegrator.java Sat Nov  3 11:46:11 2007
@@ -850,17 +850,18 @@
       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

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/ode/RungeKuttaFehlbergIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/ode/RungeKuttaFehlbergIntegrator.java?rev=591661&r1=591660&r2=591661&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/ode/RungeKuttaFehlbergIntegrator.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/ode/RungeKuttaFehlbergIntegrator.java Sat Nov  3 11:46:11 2007
@@ -274,18 +274,19 @@
       }
 
       // 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

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java?rev=591661&r1=591660&r2=591661&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java Sat Nov  3 11:46:11 2007
@@ -219,9 +219,9 @@
       }
 
       // 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 @@
       }
 
       // 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 @@
     return stepStart;
   }
 
-  public double getCurrentStepsize() {
+  public double getCurrentSignedStepsize() {
     return stepSize;
   }