commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r673759 - in /commons/proper/math/branches/MATH_2_0/src: java/org/apache/commons/math/ode/nonstiff/ java/org/apache/commons/math/ode/sampling/ site/xdoc/ test/org/apache/commons/math/ode/nonstiff/ test/org/apache/commons/math/ode/sampling/
Date Thu, 03 Jul 2008 18:51:57 GMT
Author: luc
Date: Thu Jul  3 11:51:56 2008
New Revision: 673759

URL: http://svn.apache.org/viewvc?rev=673759&view=rev
Log:
All step interpolators for ODE integrators now provide interpolation for
both the state and its time derivatives. The interpolated derivatives are
the exact derivatives of the interpolated state, thus preserving consistency.
The general step handlers hence do not need to call the derivation function
anymore. The fixed step handlers also get the time derivative of the state
as an additional argument along with the state when they are called.

Modified:
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepInterpolator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepNormalizer.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/package.html
    commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolatorTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolatorTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolatorTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GillStepInterpolatorTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolatorTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolatorTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolatorTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/sampling/StepNormalizerTest.java

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolator.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolator.java Thu Jul  3 11:51:56 2008
@@ -83,17 +83,24 @@
                                             final double oneMinusThetaH)
         throws DerivativeException {
 
-        final double fourTheta = 4 * theta;
-        final double s         = oneMinusThetaH / 6.0;
-        final double coeff1    = s * ((-fourTheta + 5) * theta - 1);
-        final double coeff23   = s * (( fourTheta - 2) * theta - 2);
-        final double coeff4    = s * ((-fourTheta - 1) * theta - 1);
-
+        final double fourTheta      = 4 * theta;
+        final double oneMinusTheta  = 1 - theta;
+        final double oneMinus2Theta = 1 - 2 * theta;
+        final double s             = oneMinusThetaH / 6.0;
+        final double coeff1        = s * ((-fourTheta + 5) * theta - 1);
+        final double coeff23       = s * (( fourTheta - 2) * theta - 2);
+        final double coeff4        = s * ((-fourTheta - 1) * theta - 1);
+        final double coeffDot1     = oneMinusTheta * oneMinus2Theta;
+        final double coeffDot23    = 2 * theta * oneMinusTheta;
+        final double coeffDot4     = -theta * oneMinus2Theta;
         for (int i = 0; i < interpolatedState.length; ++i) {
-            interpolatedState[i] = currentState[i] +
-            coeff1  * yDotK[0][i] +
-            coeff23 * (yDotK[1][i] + yDotK[2][i]) +
-            coeff4  * yDotK[3][i];
+            final double yDot1  = yDotK[0][i];
+            final double yDot23 = yDotK[1][i] + yDotK[2][i];
+            final double yDot4  = yDotK[3][i];
+            interpolatedState[i] =
+                currentState[i] + coeff1  * yDot1 + coeff23 * yDot23 + coeff4  * yDot4;
+            interpolatedDerivatives[i] =
+                coeffDot1 * yDot1 + coeffDot23 * yDot23 + coeffDot4 * yDot4;
         }
 
     }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolator.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolator.java Thu Jul  3 11:51:56 2008
@@ -122,12 +122,16 @@
 
       // we need to compute the interpolation vectors for this time step
       for (int i = 0; i < interpolatedState.length; ++i) {
-        v1[i] = h * (a70 * yDotK[0][i] + a72 * yDotK[2][i] + a73 * yDotK[3][i] +
-                     a74 * yDotK[4][i] + a75 * yDotK[5][i]);
-        v2[i] = h * yDotK[0][i] - v1[i];
-        v3[i] = v1[i] - v2[i] - h * yDotK[6][i];
-        v4[i] = h * (d0 * yDotK[0][i] + d2 * yDotK[2][i] + d3 * yDotK[3][i] +
-                     d4 * yDotK[4][i] + d5 * yDotK[5][i] + d6 * yDotK[6][i]);
+          final double yDot0 = yDotK[0][i];
+          final double yDot2 = yDotK[2][i];
+          final double yDot3 = yDotK[3][i];
+          final double yDot4 = yDotK[4][i];
+          final double yDot5 = yDotK[5][i];
+          final double yDot6 = yDotK[6][i];
+          v1[i] = h * (a70 * yDot0 + a72 * yDot2 + a73 * yDot3 + a74 * yDot4 + a75 * yDot5);
+          v2[i] = h * yDot0 - v1[i];
+          v3[i] = v1[i] - v2[i] - h * yDot6;
+          v4[i] = h * (d0 * yDot0 + d2 * yDot2 + d3 * yDot3 + d4 * yDot4 + d5 * yDot5 + d6 * yDot6);
       }
 
       vectorsInitialized = true;
@@ -136,10 +140,16 @@
 
     // interpolate
     final double eta = oneMinusThetaH / h;
+    final double twoTheta = 2 * theta;
+    final double dot2 = 1 - twoTheta;
+    final double dot3 = theta * (2 - 3 * theta);
+    final double dot4 = twoTheta * (1 + theta * (twoTheta - 3));
     for (int i = 0; i < interpolatedState.length; ++i) {
-      interpolatedState[i] = currentState[i] -
-          eta * (v1[i] - theta * (v2[i] + theta * (v3[i] + eta * v4[i])));
-    }
+      interpolatedState[i] =
+          currentState[i] - eta * (v1[i] - theta * (v2[i] + theta * (v3[i] + eta * v4[i])));
+      interpolatedDerivatives[i] = 
+          (v1[i] + dot2 * v2[i] + dot3 * v3[i] + dot4 * v4[i]) / h;
+      }
 
   }
 

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java Thu Jul  3 11:51:56 2008
@@ -144,32 +144,53 @@
 
       // compute the interpolation vectors for this time step
       for (int i = 0; i < interpolatedState.length; ++i) {
-        v[0][i] = h * (b_01 * yDotK[0][i]  + b_06 * yDotK[5][i] + b_07 * yDotK[6][i] +
-                       b_08 * yDotK[7][i]  + b_09 * yDotK[8][i] + b_10 * yDotK[9][i] +
-                       b_11 * yDotK[10][i] + b_12 * yDotK[11][i]);
-        v[1][i] = h * yDotK[0][i] - v[0][i];
-        v[2][i] = v[0][i] - v[1][i] - h * yDotK[12][i];
-        for (int k = 0; k < d.length; ++k) {
-          v[k+3][i] = h * (d[k][0] * yDotK[0][i]  + d[k][1] * yDotK[5][i]  + d[k][2] * yDotK[6][i] +
-                           d[k][3] * yDotK[7][i]  + d[k][4] * yDotK[8][i]  + d[k][5] * yDotK[9][i] +
-                           d[k][6] * yDotK[10][i] + d[k][7] * yDotK[11][i] + d[k][8] * yDotK[12][i] +
-                           d[k][9]  * yDotKLast[0][i] +
-                           d[k][10] * yDotKLast[1][i] +
-                           d[k][11] * yDotKLast[2][i]);
-        }
+          final double yDot1  = yDotK[0][i];
+          final double yDot6  = yDotK[5][i];
+          final double yDot7  = yDotK[6][i];
+          final double yDot8  = yDotK[7][i];
+          final double yDot9  = yDotK[8][i];
+          final double yDot10 = yDotK[9][i];
+          final double yDot11 = yDotK[10][i];
+          final double yDot12 = yDotK[11][i];
+          final double yDot13 = yDotK[12][i];
+          final double yDot14 = yDotKLast[0][i];
+          final double yDot15 = yDotKLast[1][i];
+          final double yDot16 = yDotKLast[2][i];
+          v[0][i] = h * (b_01 * yDot1  + b_06 * yDot6 + b_07 * yDot7 +
+                         b_08 * yDot8  + b_09 * yDot9 + b_10 * yDot10 +
+                         b_11 * yDot11 + b_12 * yDot12);
+          v[1][i] = h * yDot1 - v[0][i];
+          v[2][i] = v[0][i] - v[1][i] - h * yDotK[12][i];
+          for (int k = 0; k < d.length; ++k) {
+              v[k+3][i] = h * (d[k][0] * yDot1  + d[k][1]  * yDot6  + d[k][2]  * yDot7  +
+                               d[k][3] * yDot8  + d[k][4]  * yDot9  + d[k][5]  * yDot10 +
+                               d[k][6] * yDot11 + d[k][7]  * yDot12 + d[k][8]  * yDot13 +
+                               d[k][9] * yDot14 + d[k][10] * yDot15 + d[k][11] * yDot16);
+          }
       }
 
       vectorsInitialized = true;
 
     }
 
-    final double eta = oneMinusThetaH / h;
+    final double eta      = oneMinusThetaH / h;
+    final double twoTheta = 2 * theta;
+    final double theta2   = theta * theta;
+    final double dot1 = 1 - twoTheta;
+    final double dot2 = theta * (2 - 3 * theta);
+    final double dot3 = twoTheta * (1 + theta * (twoTheta -3));
+    final double dot4 = theta2 * (3 + theta * (5 * theta - 8));
+    final double dot5 = theta2 * (3 + theta * (-12 + theta * (15 - 6 * theta)));
+    final double dot6 = theta2 * theta * (4 + theta * (-15 + theta * (18 - 7 * theta)));
 
     for (int i = 0; i < interpolatedState.length; ++i) {
       interpolatedState[i] =
           currentState[i] - eta * (v[0][i] - theta * (v[1][i] +
                   theta * (v[2][i] + eta * (v[3][i] + theta * (v[4][i] +
                           eta * (v[5][i] + theta * (v[6][i])))))));
+      interpolatedDerivatives[i] = 
+          (v[0][i] + dot1 * v[1][i] + dot2 * v[2][i] + dot3 * v[3][i] +
+                     dot4 * v[4][i] + dot5 * v[5][i] + dot6 * v[6][i]) / h;
     }
 
   }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolator.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolator.java Thu Jul  3 11:51:56 2008
@@ -24,7 +24,7 @@
 /**
  * This class implements a linear interpolator for step.
  *
- * <p>This interpolator allow to compute dense output inside the last
+ * <p>This interpolator computes dense output inside the last
  * step computed. The interpolation equation is consistent with the
  * integration scheme :
  *
@@ -43,6 +43,9 @@
 class EulerStepInterpolator
   extends RungeKuttaStepInterpolator {
 
+  /** Serializable version identifier */
+  private static final long serialVersionUID = -7179861704951334960L;
+
   /** Simple constructor.
    * This constructor builds an instance that is not usable yet, the
    * {@link AbstractStepInterpolator#reinitialize} method should be called
@@ -78,10 +81,8 @@
     for (int i = 0; i < interpolatedState.length; ++i) {
       interpolatedState[i] = currentState[i] - oneMinusThetaH * yDotK[0][i];
     }
+    System.arraycopy(yDotK[0], 0, interpolatedDerivatives, 0, interpolatedDerivatives.length);
 
   }
 
-  /** Serializable version identifier */
-  private static final long serialVersionUID = -7179861704951334960L;
-
 }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolator.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolator.java Thu Jul  3 11:51:56 2008
@@ -80,19 +80,31 @@
                                           final double oneMinusThetaH)
     throws DerivativeException {
 
+    final double twoTheta  = 2 * theta;
     final double fourTheta = 4 * theta;
     final double s         = oneMinusThetaH / 6.0;
-    final double soMt      = s * (1 - theta);
-    final double c23       = soMt * (1 + 2 * theta);
+    final double oMt       = 1 - theta;
+    final double soMt      = s * oMt;
+    final double c23       = soMt * (1 + twoTheta);
     final double coeff1    = soMt * (1 - fourTheta);
     final double coeff2    = c23  * tMq;
     final double coeff3    = c23  * tPq;
     final double coeff4    = s * (1 + theta * (1 + fourTheta));
+    final double coeffDot1 = theta * (twoTheta - 3) + 1;
+    final double cDot23    = theta * oMt;
+    final double coeffDot2 = cDot23  * tMq;
+    final double coeffDot3 = cDot23  * tPq;
+    final double coeffDot4 = theta * (twoTheta - 1);
 
     for (int i = 0; i < interpolatedState.length; ++i) {
-      interpolatedState[i] = currentState[i] -
-                             coeff1 * yDotK[0][i] - coeff2 * yDotK[1][i] -
-                             coeff3 * yDotK[2][i] - coeff4 * yDotK[3][i];
+        final double yDot1 = yDotK[0][i];
+        final double yDot2 = yDotK[1][i];
+        final double yDot3 = yDotK[2][i];
+        final double yDot4 = yDotK[3][i];
+        interpolatedState[i] =
+            currentState[i] - coeff1 * yDot1 - coeff2 * yDot2 - coeff3 * yDot3 - coeff4 * yDot4;
+        interpolatedDerivatives[i] =
+            coeffDot1 * yDot1 + coeffDot2 * yDot2 + coeffDot3 * yDot3 + coeffDot4 * yDot4;
      }
 
   }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java Thu Jul  3 11:51:56 2008
@@ -312,22 +312,34 @@
 
     final double oneMinusTheta = 1.0 - theta;
     final double theta05       = theta - 0.5;
-    double t4                  = theta * oneMinusTheta;
-    t4 = t4 * t4;
+    final double tOmT          = theta * oneMinusTheta;
+    final double t4            = tOmT * tOmT;
+    final double t4Dot         = 2 * tOmT * (1 - 2 * theta);
+    final double dot1          = 1.0 / h;
+    final double dot2          = theta * (2 - 3 * theta) / h;
+    final double dot3          = ((3 * theta - 4) * theta + 1) / h;
 
     for (int i = 0; i < dimension; ++i) {
-      interpolatedState[i] = polynoms[0][i] +
-        theta * (polynoms[1][i] +
-                 oneMinusTheta * (polynoms[2][i] * theta +
-                                  polynoms[3][i] * oneMinusTheta));
-
-      if (currentDegree > 3) {
-        double c = polynoms[currentDegree][i];
-        for (int j = currentDegree - 1; j > 3; --j) {
-          c = polynoms[j][i] + c * theta05 / (j - 3);
+
+        final double p0 = polynoms[0][i];
+        final double p1 = polynoms[1][i];
+        final double p2 = polynoms[2][i];
+        final double p3 = polynoms[3][i];
+        interpolatedState[i] = p0 + theta * (p1 + oneMinusTheta * (p2 * theta + p3 * oneMinusTheta));
+        interpolatedDerivatives[i] = dot1 * p1 + dot2 * p2 + dot3 * p3;
+
+        if (currentDegree > 3) {
+            double cDot = 0;
+            double c = polynoms[currentDegree][i];
+            for (int j = currentDegree - 1; j > 3; --j) {
+                final double d = 1.0 / (j - 3);
+                cDot = d * (theta05 * cDot + c);
+                c = polynoms[j][i] + c * d * theta05;
+            }
+            interpolatedState[i]       += t4 * c;
+            interpolatedDerivatives[i] += (t4 * cDot + t4Dot * c) / h;
         }
-        interpolatedState[i] += t4 * c;
-      }
+
     }
 
   }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolator.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolator.java Thu Jul  3 11:51:56 2008
@@ -74,11 +74,22 @@
     final double b3 = h * (4.0/3.0 + theta2 * (-22.0 + theta * (152.0/3.0  + theta * -30.0)));
     final double b4 = h * (-125.0/96.0 + theta2 * (375.0/32.0 + theta * (-625.0/24.0 + theta * 125.0/8.0)));
     final double b5 = h * (-5.0/48.0 + theta2 * (-5.0/16.0 + theta * 5.0/12.0));
+    final double bDot0 = 1 + theta * (-15.0/2.0 + theta * (16.0 - 10.0 * theta));
+    final double bDot2 = theta * (459.0/16.0 + theta * (-729.0/8.0 + 135.0/2.0 * theta));
+    final double bDot3 = theta * (-44.0 + theta * (152.0 - 120.0 * theta));
+    final double bDot4 = theta * (375.0/16.0 + theta * (-625.0/8.0 + 125.0/2.0 * theta));
+    final double bDot5 = theta * 5.0/8.0 * (2 * theta - 1);
 
     for (int i = 0; i < interpolatedState.length; ++i) {
-      interpolatedState[i] = currentState[i] +
-                             b0 * yDotK[0][i] + b2 * yDotK[2][i] + b3 * yDotK[3][i] +
-                             b4 * yDotK[4][i] + b5 * yDotK[5][i];
+        final double yDot0 = yDotK[0][i];
+        final double yDot2 = yDotK[2][i];
+        final double yDot3 = yDotK[3][i];
+        final double yDot4 = yDotK[4][i];
+        final double yDot5 = yDotK[5][i];
+        interpolatedState[i] =
+            currentState[i] + b0 * yDot0 + b2 * yDot2 + b3 * yDot3 + b4 * yDot4 + b5 * yDot5;
+        interpolatedDerivatives[i] =
+            bDot0 * yDot0 + bDot2 * yDot2 + bDot3 * yDot3 + bDot4 * yDot4 + bDot5 * yDot5;
     }
 
   }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolator.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolator.java Thu Jul  3 11:51:56 2008
@@ -25,7 +25,7 @@
  * This class implements a step interpolator for second order
  * Runge-Kutta integrator.
  *
- * <p>This interpolator allow to compute dense output inside the last
+ * <p>This interpolator computes dense output inside the last
  * step computed. The interpolation equation is consistent with the
  * integration scheme :
  *
@@ -77,12 +77,16 @@
                                           final double oneMinusThetaH)
     throws DerivativeException {
 
-    final double coeff1 = oneMinusThetaH * theta;
-    final double coeff2 = oneMinusThetaH * (1.0 + theta);
+    final double coeff1    = oneMinusThetaH * theta;
+    final double coeff2    = oneMinusThetaH * (1.0 + theta);
+    final double coeffDot2 = 2 * theta;
+    final double coeffDot1 = 1 - coeffDot2;
 
     for (int i = 0; i < interpolatedState.length; ++i) {
-      interpolatedState[i] = currentState[i] +
-                             coeff1 * yDotK[0][i] - coeff2 * yDotK[1][i];
+      final double yDot1 = yDotK[0][i];
+      final double yDot2 = yDotK[1][i];
+      interpolatedState[i] = currentState[i] + coeff1 * yDot1 - coeff2 * yDot2;
+      interpolatedDerivatives[i] = coeffDot1 * yDot1 + coeffDot2 * yDot2;
     }
 
   }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java Thu Jul  3 11:51:56 2008
@@ -44,7 +44,7 @@
    * instance in order to initialize the internal arrays. This
    * constructor is used only in order to delay the initialization in
    * some cases. The {@link RungeKuttaIntegrator} and {@link
-   * EmbeddedRungeKuttaIntegrator} classes uses the prototyping design
+   * EmbeddedRungeKuttaIntegrator} classes use the prototyping design
    * pattern to create the step interpolators by cloning an
    * uninitialized model and latter initializing the copy.
    */
@@ -173,7 +173,7 @@
   /** Slopes at the intermediate points */
   protected double[][] yDotK;
 
-  /** Reference to the differential equations beeing integrated. */
+  /** Reference to the differential equations being integrated. */
   protected FirstOrderDifferentialEquations equations;
 
 }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolator.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolator.java Thu Jul  3 11:51:56 2008
@@ -88,11 +88,21 @@
       final double coeff2     = 3 * s * (1 + theta - fourTheta2);
       final double coeff3     = 3 * s * (1 + theta);
       final double coeff4     = s * (1 + theta + fourTheta2);
+      final double coeffDot3  = 0.75 * theta;
+      final double coeffDot1  = coeffDot3 * (4 * theta - 5) + 1;
+      final double coeffDot2  = coeffDot3 * (5 - 6 * theta);
+      final double coeffDot4  = coeffDot3 * (2 * theta - 1);
 
       for (int i = 0; i < interpolatedState.length; ++i) {
-          interpolatedState[i] = currentState[i] -
-          coeff1 * yDotK[0][i] - coeff2 * yDotK[1][i] -
-          coeff3 * yDotK[2][i] - coeff4 * yDotK[3][i];
+          final double yDot1 = yDotK[0][i];
+          final double yDot2 = yDotK[1][i];
+          final double yDot3 = yDotK[2][i];
+          final double yDot4 = yDotK[3][i];
+          interpolatedState[i] =
+              currentState[i] - coeff1 * yDot1 - coeff2 * yDot2 - coeff3 * yDot3 - coeff4 * yDot4;
+          interpolatedDerivatives[i] =
+              coeffDot1 * yDot1 + coeffDot2 * yDot2 + coeffDot3 * yDot3 + coeffDot4 * yDot4;
+
       }
 
   }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java Thu Jul  3 11:51:56 2008
@@ -64,6 +64,9 @@
   /** interpolated state */
   protected double[] interpolatedState;
 
+  /** interpolated derivatives */
+  protected double[] interpolatedDerivatives;
+
   /** indicate if the step has been finalized or not. */
   private boolean finalized;
 
@@ -81,14 +84,15 @@
    * model and latter initializing the copy.
    */
   protected AbstractStepInterpolator() {
-    previousTime      = Double.NaN;
-    currentTime       = Double.NaN;
-    h                 = Double.NaN;
-    interpolatedTime  = Double.NaN;
-    currentState      = null;
-    interpolatedState = null;
-    finalized         = false;
-    this.forward      = true;
+    previousTime            = Double.NaN;
+    currentTime             = Double.NaN;
+    h                       = Double.NaN;
+    interpolatedTime        = Double.NaN;
+    currentState            = null;
+    interpolatedState       = null;
+    interpolatedDerivatives = null;
+    finalized               = false;
+    this.forward            = true;
   }
 
   /** Simple constructor.
@@ -103,8 +107,9 @@
     h                 = Double.NaN;
     interpolatedTime  = Double.NaN;
 
-    currentState      = y;
-    interpolatedState = new double[y.length];
+    currentState            = y;
+    interpolatedState       = new double[y.length];
+    interpolatedDerivatives = new double[y.length];
 
     finalized         = false;
     this.forward      = forward;
@@ -136,11 +141,13 @@
     interpolatedTime  = interpolator.interpolatedTime;
 
     if (interpolator.currentState != null) {
-      currentState      = (double[]) interpolator.currentState.clone();
-      interpolatedState = (double[]) interpolator.interpolatedState.clone();
+      currentState            = (double[]) interpolator.currentState.clone();
+      interpolatedState       = (double[]) interpolator.interpolatedState.clone();
+      interpolatedDerivatives = (double[]) interpolator.interpolatedDerivatives.clone();
     } else {
-      currentState      = null;
-      interpolatedState = null;
+      currentState            = null;
+      interpolatedState       = null;
+      interpolatedDerivatives = null;
     }
 
     finalized = interpolator.finalized;
@@ -160,23 +167,16 @@
     h                 = Double.NaN;
     interpolatedTime  = Double.NaN;
 
-    currentState      = y;
-    interpolatedState = new double[y.length];
+    currentState            = y;
+    interpolatedState       = new double[y.length];
+    interpolatedDerivatives = new double[y.length];
 
     finalized         = false;
     this.forward      = forward;
 
   }
 
-  /** Copy the instance.
-   * <p>The copied instance is guaranteed to be independent from the
-   * original one. Both can be used with different settings for
-   * interpolated time without any side effect.</p>
-   * @return a deep copy of the instance, which can be used independently.
-   * @throws DerivativeException if this call induces an automatic
-   * step finalization that throws one
-   * @see #setInterpolatedTime(double)
-   */
+  /** {@inheritDoc} */
    public StepInterpolator copy() throws DerivativeException {
 
      // finalize the step before performing copy
@@ -220,44 +220,22 @@
 
   }
 
-  /**
-   * Get the previous grid point time.
-   * @return previous grid point time
-   */
+  /** {@inheritDoc} */
   public double getPreviousTime() {
     return previousTime;
   }
     
-  /**
-   * Get the current grid point time.
-   * @return current grid point time
-   */
+  /** {@inheritDoc} */
   public double getCurrentTime() {
     return currentTime;
   }
     
-  /**
-   * Get the time of the interpolated point.
-   * If {@link #setInterpolatedTime} has not been called, it returns
-   * the current grid point time.
-   * @return interpolation point time
-   */
+  /** {@inheritDoc} */
   public double getInterpolatedTime() {
     return interpolatedTime;
   }
     
-  /**
-   * Set the time of the interpolated point.
-   * <p>Setting the time outside of the current step is now allowed
-   * (it was not allowed up to version 5.4 of Mantissa), but should be
-   * used with care since the accuracy of the interpolator will
-   * probably be very poor far from this step. This allowance has been
-   * added to simplify implementation of search algorithms near the
-   * step endpoints.</p>
-   * @param time time of the interpolated point
-   * @throws DerivativeException if this call induces an automatic
-   * step finalization that throws one
-   */
+  /** {@inheritDoc} */
   public void setInterpolatedTime(final double time)
       throws DerivativeException {
       interpolatedTime = time;
@@ -265,14 +243,7 @@
       computeInterpolatedState((h - oneMinusThetaH) / h, oneMinusThetaH);
   }
 
-  /** Check if the natural integration direction is forward.
-   * <p>This method provides the integration direction as specified by the
-   * integrator itself, it avoid some nasty problems in degenerated
-   * cases like null steps due to cancellation at step initialization,
-   * step control or discrete events triggering.</p>
-   * @return true if the integration variable (time) increases during
-   * integration
-   */
+  /** {@inheritDoc} */
   public boolean isForward() {
     return forward;
   }
@@ -291,14 +262,15 @@
                                                    double oneMinusThetaH)
     throws DerivativeException;
     
-  /**
-   * Get the state vector of the interpolated point.
-   * @return state vector at time {@link #getInterpolatedTime}
-   */
+  /** {@inheritDoc} */
   public double[] getInterpolatedState() {
-    return (double[]) interpolatedState.clone();
+    return interpolatedState;
   }
 
+  /** {@inheritDoc} */
+  public double[] getInterpolatedDerivatives() {
+    return interpolatedDerivatives;
+  }
 
   /**
    * Finalize the step.
@@ -360,17 +332,11 @@
     throws DerivativeException {
   }
 
-  /** Write the instance to an output channel.
-   * @param out output channel
-   * @exception IOException if the instance cannot be written
-   */
+  /** {@inheritDoc} */
   public abstract void writeExternal(ObjectOutput out)
     throws IOException;
 
-  /** Read the instance from an input channel.
-   * @param in input channel
-   * @exception IOException if the instance cannot be read
-   */
+  /** {@inheritDoc} */
   public abstract void readExternal(ObjectInput in)
     throws IOException;
 
@@ -431,8 +397,9 @@
     }
 
     // we do NOT handle the interpolated time and state here
-    interpolatedTime  = Double.NaN;
-    interpolatedState = new double[dimension];
+    interpolatedTime        = Double.NaN;
+    interpolatedState       = new double[dimension];
+    interpolatedDerivatives = new double[dimension];
 
     finalized = true;
 

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java Thu Jul  3 11:51:56 2008
@@ -17,6 +17,8 @@
 
 package org.apache.commons.math.ode.sampling;
 
+import org.apache.commons.math.ode.DerivativeException;
+
 /**
  * This interface represents a handler that should be called after
  * each successful fixed step.
@@ -41,15 +43,21 @@
   /**
    * Handle the last accepted step
    * @param t time of the current step
-
    * @param y state vector at t. For efficiency purposes, the {@link
-   * StepNormalizer} class reuse the same array on each call, so if
+   * StepNormalizer} class reuses the same array on each call, so if
+   * the instance wants to keep it across all calls (for example to
+   * provide at the end of the integration a complete array of all
+   * steps), it should build a local copy store this copy.
+   * @param yDot derivatives of the state vector state vector at t.
+   * For efficiency purposes, the {@link StepNormalizer} class reuses
+   * the same array on each call, so if
    * the instance wants to keep it across all calls (for example to
    * provide at the end of the integration a complete array of all
    * steps), it should build a local copy store this copy.
-
    * @param isLast true if the step is the last one
+   * @throws DerivativeException if some error condition is encountered
    */
-  public void handleStep(double t, double[] y, boolean isLast);
-    
+  public void handleStep(double t, double[] y, double[] yDot, boolean isLast)
+      throws DerivativeException;
+
 }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepInterpolator.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepInterpolator.java Thu Jul  3 11:51:56 2008
@@ -82,10 +82,24 @@
 
   /**
    * Get the state vector of the interpolated point.
+   * <p>The returned vector is a reference to a reused array, so
+   * it should not be modified and it should be copied if it needs
+   * to be preserved across several calls.</p>
    * @return state vector at time {@link #getInterpolatedTime}
+   * @see #getInterpolatedDerivatives()
    */
   public double[] getInterpolatedState();
 
+  /**
+   * Get the derivatives of the state vector of the interpolated point.
+   * <p>The returned vector is a reference to a reused array, so
+   * it should not be modified and it should be copied if it needs
+   * to be preserved across several calls.</p>
+   * @return derivatives of the state vector at time {@link #getInterpolatedTime}
+   * @see #getInterpolatedState()
+   */
+  public double[] getInterpolatedDerivatives();
+
   /** Check if the natural integration direction is forward.
    * <p>This method provides the integration direction as specified by
    * the integrator itself, it avoid some nasty problems in

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepNormalizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepNormalizer.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepNormalizer.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepNormalizer.java Thu Jul  3 11:51:56 2008
@@ -50,7 +50,7 @@
 public class StepNormalizer implements StepHandler {
 
     /** Serializable version identifier. */
-    private static final long serialVersionUID = -973517244031912577L;
+    private static final long serialVersionUID = -789699939659144654L;
 
     /** Fixed time step. */
     private double h;
@@ -64,6 +64,9 @@
     /** Last State vector. */
     private double[] lastState;
 
+    /** Last Derivatives vector. */
+    private double[] lastDerivatives;
+
     /** Integration direction indicator. */
     private boolean forward;
 
@@ -92,9 +95,10 @@
      * handled.
      */
     public void reset() {
-        lastTime  = Double.NaN;
-        lastState = null;
-        forward   = true;
+        lastTime        = Double.NaN;
+        lastState       = null;
+        lastDerivatives = null;
+        forward         = true;
     }
 
     /**
@@ -117,9 +121,8 @@
 
             lastTime = interpolator.getPreviousTime();
             interpolator.setInterpolatedTime(lastTime);
-
-            final double[] state = interpolator.getInterpolatedState();
-            lastState = (double[]) state.clone();
+            lastState = interpolator.getInterpolatedState().clone();
+            lastDerivatives = interpolator.getInterpolatedDerivatives().clone();
 
             // take the integration direction into account
             forward = (interpolator.getCurrentTime() >= lastTime);
@@ -134,13 +137,15 @@
         while (nextInStep) {
 
             // output the stored previous step
-            handler.handleStep(lastTime, lastState, false);
+            handler.handleStep(lastTime, lastState, lastDerivatives, false);
 
             // store the next step
             lastTime = nextTime;
             interpolator.setInterpolatedTime(lastTime);
             System.arraycopy(interpolator.getInterpolatedState(), 0,
                              lastState, 0, lastState.length);
+            System.arraycopy(interpolator.getInterpolatedDerivatives(), 0,
+                             lastDerivatives, 0, lastDerivatives.length);
 
             nextTime  += h;
             nextInStep = forward ^ (nextTime > interpolator.getCurrentTime());
@@ -150,7 +155,7 @@
         if (isLast) {
             // there will be no more steps,
             // the stored one should be flagged as being the last
-            handler.handleStep(lastTime, lastState, true);
+            handler.handleStep(lastTime, lastState, lastDerivatives, true);
         }
 
     }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/package.html
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/package.html?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/package.html (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/package.html Thu Jul  3 11:51:56 2008
@@ -23,14 +23,16 @@
 </p>
 
 <p>
-All ODE integrators accept a {@link org.apache.commons.math.ode.sampling.StepHandler
-StepHandler} instance thanks to their {@link
-org.apache.commons.math.ode.FirstOrderIntegrator#setStepHandler setStepHandler} method.
-They compute the evolution of the state vector at some grid points that depend on their
-own internal algorithm. Once they have found a new grid point (possibly after having
-computed several evaluation of the derivative at intermediate points), they provide it
-to the registered step handler which can do whatever it needs with the state. A typical
-use of step handler is to provide some output to monitor the integration process.
+In addition to computing the evolution of the state vector at some grid points, all
+ODE integrators also build up interpolation models of this evolution <em>inside</em> the
+last computed step. If users are interested in these interpolators, they can register a
+{@link org.apache.commons.math.ode.sampling.StepHandler StepHandler} instance using the
+{@link org.apache.commons.math.ode.FirstOrderIntegrator#setStepHandler setStepHandler}
+method which is supported by all integrators. The integrator will call this instance
+at the end of each accepted step and provide it the interpolator. The user can do
+whatever he wants with this interpolator, which computes both the state and its
+time-derivative. A typical use of step handler is to provide some output to monitor
+the integration process.
 </p>
 
 <p>
@@ -44,7 +46,7 @@
 <p>
 Since some integrators may use variable step size, the generic {@link
 org.apache.commons.math.ode.sampling.StepHandler StepHandler} interface can be called
-either at regular or irregular rate. This interface allow to navigate to any location
+either at regular or irregular rate. This interface allows to navigate to any location
 within the last computed step, thanks to the provided {@link
 org.apache.commons.math.ode.sampling.StepInterpolator StepInterpolator} object.
 If regular output is desired (for example in order to write an ephemeris file), then

Modified: commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml Thu Jul  3 11:51:56 2008
@@ -39,6 +39,14 @@
   </properties>
   <body>
     <release version="2.0" date="TBD" description="TBD">
+      <action dev="luc" type="add">
+        All step interpolators for ODE integrators now provide interpolation for
+        both the state and its time derivatives. The interpolated derivatives are
+        the exact derivatives of the interpolated state, thus preserving consistency.
+        The general step handlers hence do not need to call the derivation function
+        anymore. The fixed step handlers also get the time derivative of the state
+        as an additional argument along with the state when they are called.
+      </action>
       <action dev="luc" type="fix" issue="MATH-213" >
         Changed return type for FirstOrderIntegrator.integrate() to double
         in order to retrieve exact stop time. This allows to handle properly

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolatorTest.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolatorTest.java Thu Jul  3 11:51:56 2008
@@ -17,26 +17,35 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
-import junit.framework.*;
-import java.util.Random;
-import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Random;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 import org.apache.commons.math.ode.ContinuousOutputModel;
 import org.apache.commons.math.ode.DerivativeException;
 import org.apache.commons.math.ode.IntegratorException;
-import org.apache.commons.math.ode.nonstiff.ClassicalRungeKuttaIntegrator;
 
 public class ClassicalRungeKuttaStepInterpolatorTest
-  extends TestCase {
+  extends AbstractStepInterpolatorTest {
 
   public ClassicalRungeKuttaStepInterpolatorTest(String name) {
     super(name);
   }
 
+  public void testDerivativesConsistency()
+  throws DerivativeException, IntegratorException {
+    TestProblem3 pb = new TestProblem3();
+    double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+    ClassicalRungeKuttaIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
+    checkDerivativesConsistency(integ, pb, 1.0e-10);
+  }
+
   public void testSerialization()
     throws DerivativeException, IntegratorException,
            IOException, ClassNotFoundException {

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolatorTest.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolatorTest.java Thu Jul  3 11:51:56 2008
@@ -33,12 +33,25 @@
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 
 public class DormandPrince54StepInterpolatorTest
-  extends TestCase {
+  extends AbstractStepInterpolatorTest {
 
   public DormandPrince54StepInterpolatorTest(String name) {
     super(name);
   }
 
+  public void testDerivativesConsistency()
+  throws DerivativeException, IntegratorException {
+    TestProblem3 pb = new TestProblem3(0.1);
+    double minStep = 0;
+    double maxStep = pb.getFinalTime() - pb.getInitialTime();
+    double scalAbsoluteTolerance = 1.0e-8;
+    double scalRelativeTolerance = scalAbsoluteTolerance;
+    DormandPrince54Integrator integ = new DormandPrince54Integrator(minStep, maxStep,
+                                                                    scalAbsoluteTolerance,
+                                                                    scalRelativeTolerance);
+    checkDerivativesConsistency(integ, pb, 1.0e-10);
+  }
+
   public void testSerialization()
     throws DerivativeException, IntegratorException,
            IOException, ClassNotFoundException {

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolatorTest.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolatorTest.java Thu Jul  3 11:51:56 2008
@@ -33,12 +33,25 @@
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 
 public class DormandPrince853StepInterpolatorTest
-  extends TestCase {
+  extends AbstractStepInterpolatorTest {
 
   public DormandPrince853StepInterpolatorTest(String name) {
     super(name);
   }
 
+  public void testDerivativesConsistency()
+  throws DerivativeException, IntegratorException {
+    TestProblem3 pb = new TestProblem3(0.1);
+    double minStep = 0;
+    double maxStep = pb.getFinalTime() - pb.getInitialTime();
+    double scalAbsoluteTolerance = 1.0e-8;
+    double scalRelativeTolerance = scalAbsoluteTolerance;
+    DormandPrince853Integrator integ = new DormandPrince853Integrator(minStep, maxStep,
+                                                                      scalAbsoluteTolerance,
+                                                                      scalRelativeTolerance);
+    checkDerivativesConsistency(integ, pb, 1.0e-10);
+  }
+
   public void testSerialization()
     throws DerivativeException, IntegratorException,
            IOException, ClassNotFoundException {

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java Thu Jul  3 11:51:56 2008
@@ -17,23 +17,23 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
-import junit.framework.*;
-import java.util.Random;
-import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Random;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 import org.apache.commons.math.ode.ContinuousOutputModel;
 import org.apache.commons.math.ode.DerivativeException;
 import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
 import org.apache.commons.math.ode.IntegratorException;
-import org.apache.commons.math.ode.nonstiff.EulerIntegrator;
-import org.apache.commons.math.ode.nonstiff.EulerStepInterpolator;
 
 public class EulerStepInterpolatorTest
-  extends TestCase {
+  extends AbstractStepInterpolatorTest {
 
   public EulerStepInterpolatorTest(String name) {
     super(name);
@@ -93,7 +93,7 @@
   }
 
   public void testInterpolationInside()
-    throws DerivativeException {
+  throws DerivativeException {
 
     double[]   y    =   { 1.0, 3.0, -4.0 };
     double[][] yDot = { { 1.0, 2.0, -2.0 } };
@@ -117,6 +117,14 @@
 
   }
 
+  public void testDerivativesConsistency()
+  throws DerivativeException, IntegratorException {
+    TestProblem3 pb = new TestProblem3();
+    double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+    EulerIntegrator integ = new EulerIntegrator(step);
+    checkDerivativesConsistency(integ, pb, 1.0e-10);
+  }
+
   public void testSerialization()
     throws DerivativeException, IntegratorException,
            IOException, ClassNotFoundException {

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GillStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GillStepInterpolatorTest.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GillStepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GillStepInterpolatorTest.java Thu Jul  3 11:51:56 2008
@@ -31,12 +31,20 @@
 import org.apache.commons.math.ode.nonstiff.GillIntegrator;
 
 public class GillStepInterpolatorTest
-  extends TestCase {
+  extends AbstractStepInterpolatorTest {
 
   public GillStepInterpolatorTest(String name) {
     super(name);
   }
 
+  public void testDerivativesConsistency()
+  throws DerivativeException, IntegratorException {
+    TestProblem3 pb = new TestProblem3();
+    double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+    GillIntegrator integ = new GillIntegrator(step);
+    checkDerivativesConsistency(integ, pb, 1.0e-10);
+  }
+
   public void testSerialization()
     throws DerivativeException, IntegratorException,
            IOException, ClassNotFoundException {

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java Thu Jul  3 11:51:56 2008
@@ -33,12 +33,26 @@
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 
 public class GraggBulirschStoerStepInterpolatorTest
-  extends TestCase {
+  extends AbstractStepInterpolatorTest {
 
   public GraggBulirschStoerStepInterpolatorTest(String name) {
     super(name);
   }
 
+  public void testDerivativesConsistency()
+  throws DerivativeException, IntegratorException {
+    TestProblem3 pb = new TestProblem3(0.9);
+    double minStep   = 0;
+    double maxStep   = pb.getFinalTime() - pb.getInitialTime();
+    double absTolerance = 1.0e-8;
+    double relTolerance = 1.0e-8;
+
+    GraggBulirschStoerIntegrator integ =
+      new GraggBulirschStoerIntegrator(minStep, maxStep,
+                                       absTolerance, relTolerance);
+    checkDerivativesConsistency(integ, pb, 1.0e-8);
+  }
+
   public void testSerialization()
     throws DerivativeException, IntegratorException,
            IOException, ClassNotFoundException {

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolatorTest.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolatorTest.java Thu Jul  3 11:51:56 2008
@@ -33,12 +33,25 @@
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 
 public class HighamHall54StepInterpolatorTest
-  extends TestCase {
+  extends AbstractStepInterpolatorTest {
 
   public HighamHall54StepInterpolatorTest(String name) {
     super(name);
   }
 
+  public void testDerivativesConsistency()
+  throws DerivativeException, IntegratorException {
+    TestProblem3 pb = new TestProblem3(0.1);
+    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);
+    checkDerivativesConsistency(integ, pb, 1.0e-10);
+  }
+
   public void testSerialization()
     throws DerivativeException, IntegratorException,
            IOException, ClassNotFoundException {

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolatorTest.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolatorTest.java Thu Jul  3 11:51:56 2008
@@ -17,26 +17,35 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
-import junit.framework.*;
-import java.util.Random;
-import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Random;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 import org.apache.commons.math.ode.ContinuousOutputModel;
 import org.apache.commons.math.ode.DerivativeException;
 import org.apache.commons.math.ode.IntegratorException;
-import org.apache.commons.math.ode.nonstiff.MidpointIntegrator;
 
 public class MidpointStepInterpolatorTest
-  extends TestCase {
+  extends AbstractStepInterpolatorTest {
 
   public MidpointStepInterpolatorTest(String name) {
     super(name);
   }
 
+  public void testDerivativesConsistency()
+  throws DerivativeException, IntegratorException {
+    TestProblem3 pb = new TestProblem3();
+    double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+    MidpointIntegrator integ = new MidpointIntegrator(step);
+    checkDerivativesConsistency(integ, pb, 1.0e-10);
+  }
+
   public void testSerialization()
     throws DerivativeException, IntegratorException,
            IOException, ClassNotFoundException {

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolatorTest.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolatorTest.java Thu Jul  3 11:51:56 2008
@@ -17,26 +17,35 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
-import junit.framework.*;
-import java.util.Random;
-import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Random;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 import org.apache.commons.math.ode.ContinuousOutputModel;
 import org.apache.commons.math.ode.DerivativeException;
 import org.apache.commons.math.ode.IntegratorException;
-import org.apache.commons.math.ode.nonstiff.ThreeEighthesIntegrator;
 
 public class ThreeEighthesStepInterpolatorTest
-  extends TestCase {
+  extends AbstractStepInterpolatorTest {
 
   public ThreeEighthesStepInterpolatorTest(String name) {
     super(name);
   }
 
+  public void testDerivativesConsistency()
+  throws DerivativeException, IntegratorException {
+    TestProblem3 pb = new TestProblem3();
+    double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+    ThreeEighthesIntegrator integ = new ThreeEighthesIntegrator(step);
+    checkDerivativesConsistency(integ, pb, 1.0e-10);
+  }
+
   public void testSerialization()
     throws DerivativeException, IntegratorException,
            IOException, ClassNotFoundException {

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/sampling/StepNormalizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/sampling/StepNormalizerTest.java?rev=673759&r1=673758&r2=673759&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/sampling/StepNormalizerTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/sampling/StepNormalizerTest.java Thu Jul  3 11:51:56 2008
@@ -45,6 +45,7 @@
                                          private boolean firstCall = true;
                                          public void handleStep(double t,
                                                                 double[] y,
+                                                                double[] yDot,
                                                                 boolean isLast) {
                                            if (firstCall) {
                                              checkValue(t, pb.getInitialTime());
@@ -70,6 +71,7 @@
                                        new FixedStepHandler() {
                                          public void handleStep(double t,
                                                                 double[] y,
+                                                                double[] yDot,
                                                                 boolean isLast) {
                                            if (isLast) {
                                              setLastSeen(true);



Mime
View raw message