commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1176734 [2/2] - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/exception/util/ main/java/org/apache/commons/math/ode/ main/java/org/apache/commons/math/ode/nonstiff/ main/java/org/apache/commons/math/ode/sampling/ mai...
Date Wed, 28 Sep 2011 05:56:43 GMT
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java?rev=1176734&r1=1176733&r2=1176734&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java Wed Sep 28 05:56:42 2011
@@ -22,6 +22,7 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 
 import org.apache.commons.math.ode.AbstractIntegrator;
+import org.apache.commons.math.ode.EquationsMapper;
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 
 /**
@@ -280,9 +281,11 @@ class DormandPrince853StepInterpolator
   /** {@inheritDoc} */
   @Override
   public void reinitialize(final AbstractIntegrator integrator,
-                           final double[] y, final double[][] yDotK, final boolean forward) {
+                           final double[] y, final double[][] yDotK, final boolean forward,
+                           final EquationsMapper primaryMapper,
+                           final EquationsMapper[] secondaryMappers) {
 
-    super.reinitialize(integrator, y, yDotK, forward);
+    super.reinitialize(integrator, y, yDotK, forward, primaryMapper, secondaryMappers);
 
     final int dimension = currentState.length;
 
@@ -454,7 +457,7 @@ class DormandPrince853StepInterpolator
   /** {@inheritDoc} */
   @Override
   public void readExternal(final ObjectInput in)
-    throws IOException {
+    throws IOException, ClassNotFoundException {
 
     // read the local attributes
     yDotKLast = new double[3][];

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java?rev=1176734&r1=1176733&r2=1176734&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java Wed Sep 28 05:56:42 2011
@@ -19,7 +19,7 @@ package org.apache.commons.math.ode.nons
 
 import org.apache.commons.math.exception.MathIllegalArgumentException;
 import org.apache.commons.math.exception.MathIllegalStateException;
-import org.apache.commons.math.ode.ExpandableFirstOrderDifferentialEquations;
+import org.apache.commons.math.ode.ExpandableStatefulODE;
 import org.apache.commons.math.ode.sampling.StepHandler;
 import org.apache.commons.math.util.FastMath;
 
@@ -189,38 +189,30 @@ public abstract class EmbeddedRungeKutta
 
   /** {@inheritDoc} */
   @Override
-  public double integrate(final ExpandableFirstOrderDifferentialEquations equations,
-                          final double t0, final double[] z0,
-                          final double t, final double[] z)
+  public void integrate(final ExpandableStatefulODE equations, final double t)
       throws MathIllegalStateException, MathIllegalArgumentException {
 
-    sanityChecks(equations, t0, z0, t, z);
+    sanityChecks(equations, t);
     setEquations(equations);
     resetEvaluations();
-    final boolean forward = t > t0;
+    final boolean forward = t > equations.getTime();
 
     // create some internal working arrays
-    final int totalDim = equations.getDimension();
-    final int mainDim  = equations.getMainSetDimension();
-    final double[] y0  = new double[totalDim];
-    final double[] y   = new double[totalDim];
-    System.arraycopy(z0, 0, y0, 0, mainDim);
-    System.arraycopy(equations.getCurrentAdditionalStates(), 0, y0, mainDim, totalDim - mainDim);
+    final double[] y0  = equations.getCompleteState();
+    final double[] y = y0.clone();
     final int stages = c.length + 1;
-    if (y != y0) {
-      System.arraycopy(y0, 0, y, 0, totalDim);
-    }
-    final double[][] yDotK = new double[stages][totalDim];
-    final double[] yTmp    = new double[totalDim];
-    final double[] yDotTmp = new double[totalDim];
+    final double[][] yDotK = new double[stages][y.length];
+    final double[] yTmp    = new double[y.length];
+    final double[] yDotTmp = new double[y.length];
 
     // set up an interpolator sharing the integrator arrays
     final RungeKuttaStepInterpolator interpolator = (RungeKuttaStepInterpolator) prototype.copy();
-    interpolator.reinitialize(this, yTmp, yDotK, forward);
-    interpolator.storeTime(t0);
+    interpolator.reinitialize(this, yTmp, yDotK, forward,
+                              equations.getPrimaryMapper(), equations.getSecondaryMappers());
+    interpolator.storeTime(equations.getTime());
 
     // set up integration control objects
-    stepStart         = t0;
+    stepStart         = equations.getTime();
     double  hNew      = 0;
     boolean firstTime = true;
     for (StepHandler handler : stepHandlers) {
@@ -331,13 +323,11 @@ public abstract class EmbeddedRungeKutta
 
     } while (!isLastStep);
 
-    // dispatch result between main and additional states
-    System.arraycopy(y, 0, z, 0, z.length);
-    equations.setCurrentAdditionalState(y);
+    // dispatch results
+    equations.setTime(stepStart);
+    equations.setCompleteState(y);
 
-    final double stopTime = stepStart;
     resetInternalState();
-    return stopTime;
 
   }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java?rev=1176734&r1=1176733&r2=1176734&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java Wed Sep 28 05:56:42 2011
@@ -20,7 +20,7 @@ package org.apache.commons.math.ode.nons
 import org.apache.commons.math.analysis.solvers.UnivariateRealSolver;
 import org.apache.commons.math.exception.MathIllegalArgumentException;
 import org.apache.commons.math.exception.MathIllegalStateException;
-import org.apache.commons.math.ode.ExpandableFirstOrderDifferentialEquations;
+import org.apache.commons.math.ode.ExpandableStatefulODE;
 import org.apache.commons.math.ode.events.EventHandler;
 import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
 import org.apache.commons.math.ode.sampling.StepHandler;
@@ -541,32 +541,27 @@ public class GraggBulirschStoerIntegrato
 
   /** {@inheritDoc} */
   @Override
-  public double integrate(final ExpandableFirstOrderDifferentialEquations equations,
-                          final double t0, final double[] z0, final double t, final double[] z)
+  public void integrate(final ExpandableStatefulODE equations, final double t)
       throws MathIllegalStateException, MathIllegalArgumentException {
 
-    sanityChecks(equations, t0, z0, t, z);
+    sanityChecks(equations, t);
     setEquations(equations);
     resetEvaluations();
-    final boolean forward = t > t0;
+    final boolean forward = t > equations.getTime();
 
     // create some internal working arrays
-    final int totalDim = equations.getDimension();
-    final int mainDim  = equations.getMainSetDimension();
-    final double[] y0 = new double[totalDim];
-    final double[] y  = new double[totalDim];
-    System.arraycopy(z0, 0, y0, 0, mainDim);
-    System.arraycopy(equations.getCurrentAdditionalStates(), 0, y0, mainDim, totalDim - mainDim);
-    final double[] yDot0   = new double[totalDim];
-    final double[] y1      = new double[totalDim];
-    final double[] yTmp    = new double[totalDim];
-    final double[] yTmpDot = new double[totalDim];
+    final double[] y0      = equations.getCompleteState();
+    final double[] y       = y0.clone();
+    final double[] yDot0   = new double[y.length];
+    final double[] y1      = new double[y.length];
+    final double[] yTmp    = new double[y.length];
+    final double[] yTmpDot = new double[y.length];
 
     final double[][] diagonal = new double[sequence.length-1][];
     final double[][] y1Diag = new double[sequence.length-1][];
     for (int k = 0; k < sequence.length-1; ++k) {
-      diagonal[k] = new double[totalDim];
-      y1Diag[k] = new double[totalDim];
+      diagonal[k] = new double[y.length];
+      y1Diag[k] = new double[y.length];
     }
 
     final double[][][] fk  = new double[sequence.length][][];
@@ -606,10 +601,12 @@ public class GraggBulirschStoerIntegrato
     final AbstractStepInterpolator interpolator =
             new GraggBulirschStoerStepInterpolator(y, yDot0,
                                                    y1, yDot1,
-                                                   yMidDots, forward);
-    interpolator.storeTime(t0);
+                                                   yMidDots, forward,
+                                                   equations.getPrimaryMapper(),
+                                                   equations.getSecondaryMappers());
+    interpolator.storeTime(equations.getTime());
 
-    stepStart = t0;
+    stepStart = equations.getTime();
     double  hNew             = 0;
     double  maxError         = Double.MAX_VALUE;
     boolean previousRejected = false;
@@ -940,13 +937,11 @@ public class GraggBulirschStoerIntegrato
 
     } while (!isLastStep);
 
-    // dispatch result between main and additional states
-    System.arraycopy(y, 0, z, 0, z.length);
-    equations.setCurrentAdditionalState(y);
+    // dispatch results
+    equations.setTime(stepStart);
+    equations.setCompleteState(y);
 
-    final double stopTime = stepStart;
     resetInternalState();
-    return stopTime;
 
   }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java?rev=1176734&r1=1176733&r2=1176734&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java Wed Sep 28 05:56:42 2011
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 
+import org.apache.commons.math.ode.EquationsMapper;
 import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
 import org.apache.commons.math.ode.sampling.StepInterpolator;
 import org.apache.commons.math.util.FastMath;
@@ -94,13 +95,13 @@ class GraggBulirschStoerStepInterpolator
      */
     private double[][] yMidDots;
 
-    /** Interpolation polynoms. */
-    private double[][] polynoms;
+    /** Interpolation polynomials. */
+    private double[][] polynomials;
 
     /** Error coefficients for the interpolation. */
     private double[] errfac;
 
-    /** Degree of the interpolation polynoms. */
+    /** Degree of the interpolation polynomials. */
     private int currentDegree;
 
   /** Simple constructor.
@@ -126,13 +127,17 @@ class GraggBulirschStoerStepInterpolator
    * @param yMidDots reference to the integrator array holding the
    * derivatives at the middle point of the step
    * @param forward integration direction indicator
+   * @param primaryMapper equations mapper for the primary equations set
+   * @param secondaryMappers equations mappers for the secondary equations sets
    */
   public GraggBulirschStoerStepInterpolator(final double[] y, final double[] y0Dot,
                                             final double[] y1, final double[] y1Dot,
                                             final double[][] yMidDots,
-                                            final boolean forward) {
+                                            final boolean forward,
+                                            final EquationsMapper primaryMapper,
+                                            final EquationsMapper[] secondaryMappers) {
 
-    super(y, forward);
+    super(y, forward, primaryMapper, secondaryMappers);
     this.y0Dot    = y0Dot;
     this.y1       = y1;
     this.y1Dot    = y1Dot;
@@ -161,16 +166,16 @@ class GraggBulirschStoerStepInterpolator
     y1Dot    = null;
     yMidDots = null;
 
-    // copy the interpolation polynoms (up to the current degree only)
-    if (interpolator.polynoms == null) {
-      polynoms = null;
+    // copy the interpolation polynomials (up to the current degree only)
+    if (interpolator.polynomials == null) {
+      polynomials = null;
       currentDegree = -1;
     } else {
       resetTables(interpolator.currentDegree);
-      for (int i = 0; i < polynoms.length; ++i) {
-        polynoms[i] = new double[dimension];
-        System.arraycopy(interpolator.polynoms[i], 0,
-                         polynoms[i], 0, dimension);
+      for (int i = 0; i < polynomials.length; ++i) {
+        polynomials[i] = new double[dimension];
+        System.arraycopy(interpolator.polynomials[i], 0,
+                         polynomials[i], 0, dimension);
       }
       currentDegree = interpolator.currentDegree;
     }
@@ -179,21 +184,21 @@ class GraggBulirschStoerStepInterpolator
 
   /** Reallocate the internal tables.
    * Reallocate the internal tables in order to be able to handle
-   * interpolation polynoms up to the given degree
+   * interpolation polynomials up to the given degree
    * @param maxDegree maximal degree to handle
    */
   private void resetTables(final int maxDegree) {
 
     if (maxDegree < 0) {
-      polynoms      = null;
+      polynomials   = null;
       errfac        = null;
       currentDegree = -1;
     } else {
 
       final double[][] newPols = new double[maxDegree + 1][];
-      if (polynoms != null) {
-        System.arraycopy(polynoms, 0, newPols, 0, polynoms.length);
-        for (int i = polynoms.length; i < newPols.length; ++i) {
+      if (polynomials != null) {
+        System.arraycopy(polynomials, 0, newPols, 0, polynomials.length);
+        for (int i = polynomials.length; i < newPols.length; ++i) {
           newPols[i] = new double[currentState.length];
         }
       } else {
@@ -201,7 +206,7 @@ class GraggBulirschStoerStepInterpolator
           newPols[i] = new double[currentState.length];
         }
       }
-      polynoms = newPols;
+      polynomials = newPols;
 
       // initialize the error factors array for interpolation
       if (maxDegree <= 4) {
@@ -237,7 +242,7 @@ class GraggBulirschStoerStepInterpolator
    */
   public void computeCoefficients(final int mu, final double h) {
 
-    if ((polynoms == null) || (polynoms.length <= (mu + 4))) {
+    if ((polynomials == null) || (polynomials.length <= (mu + 4))) {
       resetTables(mu + 4);
     }
 
@@ -251,10 +256,10 @@ class GraggBulirschStoerStepInterpolator
       final double aspl  = ydiff - yp1;
       final double bspl  = yp0 - ydiff;
 
-      polynoms[0][i] = currentState[i];
-      polynoms[1][i] = ydiff;
-      polynoms[2][i] = aspl;
-      polynoms[3][i] = bspl;
+      polynomials[0][i] = currentState[i];
+      polynomials[1][i] = ydiff;
+      polynomials[2][i] = aspl;
+      polynomials[3][i] = bspl;
 
       if (mu < 0) {
         return;
@@ -262,25 +267,25 @@ class GraggBulirschStoerStepInterpolator
 
       // compute the remaining coefficients
       final double ph0 = 0.5 * (currentState[i] + y1[i]) + 0.125 * (aspl + bspl);
-      polynoms[4][i] = 16 * (yMidDots[0][i] - ph0);
+      polynomials[4][i] = 16 * (yMidDots[0][i] - ph0);
 
       if (mu > 0) {
         final double ph1 = ydiff + 0.25 * (aspl - bspl);
-        polynoms[5][i] = 16 * (yMidDots[1][i] - ph1);
+        polynomials[5][i] = 16 * (yMidDots[1][i] - ph1);
 
         if (mu > 1) {
           final double ph2 = yp1 - yp0;
-          polynoms[6][i] = 16 * (yMidDots[2][i] - ph2 + polynoms[4][i]);
+          polynomials[6][i] = 16 * (yMidDots[2][i] - ph2 + polynomials[4][i]);
 
           if (mu > 2) {
             final double ph3 = 6 * (bspl - aspl);
-            polynoms[7][i] = 16 * (yMidDots[3][i] - ph3 + 3 * polynoms[5][i]);
+            polynomials[7][i] = 16 * (yMidDots[3][i] - ph3 + 3 * polynomials[5][i]);
 
             for (int j = 4; j <= mu; ++j) {
               final double fac1 = 0.5 * j * (j - 1);
               final double fac2 = 2 * fac1 * (j - 2) * (j - 3);
-              polynoms[j+4][i] =
-                  16 * (yMidDots[j][i] + fac1 * polynoms[j+2][i] - fac2 * polynoms[j][i]);
+              polynomials[j+4][i] =
+                  16 * (yMidDots[j][i] + fac1 * polynomials[j+2][i] - fac2 * polynomials[j][i]);
             }
 
           }
@@ -298,7 +303,7 @@ class GraggBulirschStoerStepInterpolator
     double error = 0;
     if (currentDegree >= 5) {
       for (int i = 0; i < scale.length; ++i) {
-        final double e = polynoms[currentDegree][i] / scale[i];
+        final double e = polynomials[currentDegree][i] / scale[i];
         error += e * e;
       }
       error = FastMath.sqrt(error / scale.length) * errfac[currentDegree - 5];
@@ -309,7 +314,7 @@ class GraggBulirschStoerStepInterpolator
   /** {@inheritDoc} */
   @Override
   protected void computeInterpolatedStateAndDerivatives(final double theta,
-                                          final double oneMinusThetaH) {
+                                                        final double oneMinusThetaH) {
 
     final int dimension = currentState.length;
 
@@ -324,20 +329,20 @@ class GraggBulirschStoerStepInterpolator
 
     for (int i = 0; i < dimension; ++i) {
 
-        final double p0 = polynoms[0][i];
-        final double p1 = polynoms[1][i];
-        final double p2 = polynoms[2][i];
-        final double p3 = polynoms[3][i];
+        final double p0 = polynomials[0][i];
+        final double p1 = polynomials[1][i];
+        final double p2 = polynomials[2][i];
+        final double p3 = polynomials[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];
+            double c = polynomials[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;
+                c = polynomials[j][i] + c * d * theta05;
             }
             interpolatedState[i]       += t4 * c;
             interpolatedDerivatives[i] += (t4 * cDot + t4Dot * c) / h;
@@ -367,7 +372,7 @@ class GraggBulirschStoerStepInterpolator
     out.writeInt(currentDegree);
     for (int k = 0; k <= currentDegree; ++k) {
       for (int l = 0; l < dimension; ++l) {
-        out.writeDouble(polynoms[k][l]);
+        out.writeDouble(polynomials[k][l]);
       }
     }
 
@@ -376,7 +381,7 @@ class GraggBulirschStoerStepInterpolator
   /** {@inheritDoc} */
   @Override
   public void readExternal(final ObjectInput in)
-    throws IOException {
+    throws IOException, ClassNotFoundException {
 
     // read the base class
     final double t = readBaseExternal(in);
@@ -389,7 +394,7 @@ class GraggBulirschStoerStepInterpolator
 
     for (int k = 0; k <= currentDegree; ++k) {
       for (int l = 0; l < dimension; ++l) {
-        polynoms[k][l] = in.readDouble();
+        polynomials[k][l] = in.readDouble();
       }
     }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java?rev=1176734&r1=1176733&r2=1176734&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java Wed Sep 28 05:56:42 2011
@@ -21,7 +21,7 @@ package org.apache.commons.math.ode.nons
 import org.apache.commons.math.exception.MathIllegalArgumentException;
 import org.apache.commons.math.exception.MathIllegalStateException;
 import org.apache.commons.math.ode.AbstractIntegrator;
-import org.apache.commons.math.ode.ExpandableFirstOrderDifferentialEquations;
+import org.apache.commons.math.ode.ExpandableStatefulODE;
 import org.apache.commons.math.ode.sampling.StepHandler;
 import org.apache.commons.math.util.FastMath;
 
@@ -90,27 +90,18 @@ public abstract class RungeKuttaIntegrat
   }
 
   /** {@inheritDoc} */
-  public double integrate(final ExpandableFirstOrderDifferentialEquations equations,
-                          final double t0, final double[] z0,
-                          final double t, final double[] z)
+  public void integrate(final ExpandableStatefulODE equations, final double t)
       throws MathIllegalStateException, MathIllegalArgumentException {
 
-    sanityChecks(equations, t0, z0, t, z);
+    sanityChecks(equations, t);
     setEquations(equations);
     resetEvaluations();
-    final boolean forward = t > t0;
+    final boolean forward = t > equations.getTime();
 
     // create some internal working arrays
-    final int totalDim = equations.getDimension();
-    final int mainDim  = equations.getMainSetDimension();
-    final double[] y0  = new double[totalDim];
-    final double[] y   = new double[totalDim];
-    System.arraycopy(z0, 0, y0, 0, mainDim);
-    System.arraycopy(equations.getCurrentAdditionalStates(), 0, y0, mainDim, totalDim - mainDim);
-    final int stages = c.length + 1;
-    if (y != y0) {
-      System.arraycopy(y0, 0, y, 0, y0.length);
-    }
+    final double[] y0      = equations.getCompleteState();
+    final double[] y       = y0.clone();
+    final int stages       = c.length + 1;
     final double[][] yDotK = new double[stages][];
     for (int i = 0; i < stages; ++i) {
       yDotK [i] = new double[y0.length];
@@ -120,11 +111,12 @@ public abstract class RungeKuttaIntegrat
 
     // set up an interpolator sharing the integrator arrays
     final RungeKuttaStepInterpolator interpolator = (RungeKuttaStepInterpolator) prototype.copy();
-    interpolator.reinitialize(this, yTmp, yDotK, forward);
-    interpolator.storeTime(t0);
+    interpolator.reinitialize(this, yTmp, yDotK, forward,
+                              equations.getPrimaryMapper(), equations.getSecondaryMappers());
+    interpolator.storeTime(equations.getTime());
 
     // set up integration control objects
-    stepStart = t0;
+    stepStart = equations.getTime();
     stepSize  = forward ? step : -step;
     for (StepHandler handler : stepHandlers) {
         handler.reset();
@@ -185,14 +177,12 @@ public abstract class RungeKuttaIntegrat
 
     } while (!isLastStep);
 
-    // dispatch result between main and additional states
-    System.arraycopy(y, 0, z, 0, z.length);
-    equations.setCurrentAdditionalState(y);
+    // dispatch results
+    equations.setTime(stepStart);
+    equations.setCompleteState(y);
 
-    final double stopTime = stepStart;
     stepStart = Double.NaN;
     stepSize  = Double.NaN;
-    return stopTime;
 
   }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java?rev=1176734&r1=1176733&r2=1176734&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java Wed Sep 28 05:56:42 2011
@@ -22,6 +22,7 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 
 import org.apache.commons.math.ode.AbstractIntegrator;
+import org.apache.commons.math.ode.EquationsMapper;
 import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
 
 /** This class represents an interpolator over the last step during an
@@ -120,10 +121,14 @@ abstract class RungeKuttaStepInterpolato
    * @param yDotArray reference to the integrator array holding all the
    * intermediate slopes
    * @param forward integration direction indicator
+   * @param primaryMapper equations mapper for the primary equations set
+   * @param secondaryMappers equations mappers for the secondary equations sets
    */
   public void reinitialize(final AbstractIntegrator rkIntegrator,
-                           final double[] y, final double[][] yDotArray, final boolean forward) {
-    reinitialize(y, forward);
+                           final double[] y, final double[][] yDotArray, final boolean forward,
+                           final EquationsMapper primaryMapper,
+                           final EquationsMapper[] secondaryMappers) {
+    reinitialize(y, forward, primaryMapper, secondaryMappers);
     this.yDotK = yDotArray;
     this.integrator = rkIntegrator;
   }
@@ -153,7 +158,7 @@ abstract class RungeKuttaStepInterpolato
   /** {@inheritDoc} */
   @Override
   public void readExternal(final ObjectInput in)
-    throws IOException {
+    throws IOException, ClassNotFoundException {
 
     // read the base class
     final double t = readBaseExternal(in);

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java?rev=1176734&r1=1176733&r2=1176734&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java Wed Sep 28 05:56:42 2011
@@ -21,6 +21,8 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 
+import org.apache.commons.math.ode.EquationsMapper;
+
 /** This abstract class represents an interpolator over the last step
  * during an ODE integration.
  *
@@ -56,6 +58,18 @@ public abstract class AbstractStepInterp
   /** interpolated derivatives */
   protected double[] interpolatedDerivatives;
 
+  /** interpolated primary state */
+  protected double[] interpolatedPrimaryState;
+
+  /** interpolated primary derivatives */
+  protected double[] interpolatedPrimaryDerivatives;
+
+  /** interpolated secondary state */
+  protected double[][] interpolatedSecondaryState;
+
+  /** interpolated secondary derivatives */
+  protected double[][] interpolatedSecondaryDerivatives;
+
   /** global previous time */
   private double globalPreviousTime;
 
@@ -77,6 +91,11 @@ public abstract class AbstractStepInterp
   /** indicator for dirty state. */
   private boolean dirtyState;
 
+  /** Equations mapper for the primary equations set. */
+  private EquationsMapper primaryMapper;
+
+  /** Equations mappers for the secondary equations sets. */
+  private EquationsMapper[] secondaryMappers;
 
   /** Simple constructor.
    * This constructor builds an instance that is not usable yet, the
@@ -90,41 +109,45 @@ public abstract class AbstractStepInterp
    * initializing the copy.
    */
   protected AbstractStepInterpolator() {
-    globalPreviousTime      = Double.NaN;
-    globalCurrentTime       = Double.NaN;
-    softPreviousTime        = Double.NaN;
-    softCurrentTime         = Double.NaN;
-    h                       = Double.NaN;
-    interpolatedTime        = Double.NaN;
-    currentState            = null;
-    interpolatedState       = null;
-    interpolatedDerivatives = null;
-    finalized               = false;
-    this.forward            = true;
-    this.dirtyState         = true;
-  }
-
-  /** Simple constructor.
-   * @param y reference to the integrator array holding the state at
-   * the end of the step
-   * @param forward integration direction indicator
-   */
-  protected AbstractStepInterpolator(final double[] y, final boolean forward) {
-
     globalPreviousTime = Double.NaN;
     globalCurrentTime  = Double.NaN;
     softPreviousTime   = Double.NaN;
     softCurrentTime    = Double.NaN;
     h                  = Double.NaN;
     interpolatedTime   = Double.NaN;
+    currentState       = null;
+    finalized          = false;
+    this.forward       = true;
+    this.dirtyState    = true;
+    primaryMapper      = null;
+    secondaryMappers   = null;
+    allocateInterpolatedArrays(-1, null, null);
+  }
 
-    currentState            = y;
-    interpolatedState       = new double[y.length];
-    interpolatedDerivatives = new double[y.length];
-
-    finalized         = false;
-    this.forward      = forward;
-    this.dirtyState   = true;
+  /** Simple constructor.
+   * @param y reference to the integrator array holding the state at
+   * the end of the step
+   * @param forward integration direction indicator
+   * @param primaryMapper equations mapper for the primary equations set
+   * @param secondaryMappers equations mappers for the secondary equations sets
+   */
+  protected AbstractStepInterpolator(final double[] y, final boolean forward,
+                                     final EquationsMapper primaryMapper,
+                                     final EquationsMapper[] secondaryMappers) {
+
+    globalPreviousTime    = Double.NaN;
+    globalCurrentTime     = Double.NaN;
+    softPreviousTime      = Double.NaN;
+    softCurrentTime       = Double.NaN;
+    h                     = Double.NaN;
+    interpolatedTime      = Double.NaN;
+    currentState          = y;
+    finalized             = false;
+    this.forward          = forward;
+    this.dirtyState       = true;
+    this.primaryMapper    = primaryMapper;
+    this.secondaryMappers = (secondaryMappers == null) ? null : secondaryMappers.clone();
+    allocateInterpolatedArrays(y.length, primaryMapper, secondaryMappers);
 
   }
 
@@ -154,43 +177,89 @@ public abstract class AbstractStepInterp
     h                  = interpolator.h;
     interpolatedTime   = interpolator.interpolatedTime;
 
-    if (interpolator.currentState != null) {
-      currentState            = interpolator.currentState.clone();
-      interpolatedState       = interpolator.interpolatedState.clone();
-      interpolatedDerivatives = interpolator.interpolatedDerivatives.clone();
+    if (interpolator.currentState == null) {
+        currentState = null;
+        allocateInterpolatedArrays(-1, null, null);
     } else {
-      currentState            = null;
-      interpolatedState       = null;
-      interpolatedDerivatives = null;
+      currentState                     = interpolator.currentState.clone();
+      interpolatedState                = interpolator.interpolatedState.clone();
+      interpolatedDerivatives          = interpolator.interpolatedDerivatives.clone();
+      interpolatedPrimaryState         = interpolator.interpolatedPrimaryState.clone();
+      interpolatedPrimaryDerivatives   = interpolator.interpolatedPrimaryDerivatives.clone();
+      interpolatedSecondaryState       = new double[interpolator.interpolatedSecondaryState.length][];
+      interpolatedSecondaryDerivatives = new double[interpolator.interpolatedSecondaryDerivatives.length][];
+      for (int i = 0; i < interpolatedSecondaryState.length; ++i) {
+          interpolatedSecondaryState[i]       = interpolator.interpolatedSecondaryState[i].clone();
+          interpolatedSecondaryDerivatives[i] = interpolator.interpolatedSecondaryDerivatives[i].clone();
+      }
     }
 
-    finalized  = interpolator.finalized;
-    forward    = interpolator.forward;
-    dirtyState = interpolator.dirtyState;
+    finalized        = interpolator.finalized;
+    forward          = interpolator.forward;
+    dirtyState       = interpolator.dirtyState;
+    primaryMapper    = interpolator.primaryMapper;
+    secondaryMappers = (interpolator.secondaryMappers == null) ?
+                       null : interpolator.secondaryMappers.clone();
 
   }
 
+  /** Allocate the various interpolated states arrays.
+   * @param dimension total dimension (negative if arrays should be set to null)
+   * @param primaryMapper equations mapper for the primary equations set
+   * @param secondaryMappers equations mappers for the secondary equations sets
+   */
+  private void allocateInterpolatedArrays(final int dimension,
+                                          final EquationsMapper primaryMapper,
+                                          final EquationsMapper[] secondaryMappers) {
+      if (dimension < 0) {
+          interpolatedState                = null;
+          interpolatedDerivatives          = null;
+          interpolatedPrimaryState         = null;
+          interpolatedPrimaryDerivatives   = null;
+          interpolatedSecondaryState       = null;
+          interpolatedSecondaryDerivatives = null;
+      } else {
+          interpolatedState                = new double[dimension];
+          interpolatedDerivatives          = new double[dimension];
+          interpolatedPrimaryState         = new double[primaryMapper.getDimension()];
+          interpolatedPrimaryDerivatives   = new double[primaryMapper.getDimension()];
+          if (secondaryMappers == null) {
+              interpolatedSecondaryState       = null;
+              interpolatedSecondaryDerivatives = null;
+          } else {
+              interpolatedSecondaryState       = new double[secondaryMappers.length][];
+              interpolatedSecondaryDerivatives = new double[secondaryMappers.length][];
+              for (int i = 0; i < secondaryMappers.length; ++i) {
+                  interpolatedSecondaryState[i]       = new double[secondaryMappers[i].getDimension()];
+                  interpolatedSecondaryDerivatives[i] = new double[secondaryMappers[i].getDimension()];
+              }
+          }
+      }
+  }
+
   /** Reinitialize the instance
-   * @param y reference to the integrator array holding the state at
-   * the end of the step
+   * @param y reference to the integrator array holding the state at the end of the step
    * @param isForward integration direction indicator
+   * @param primaryMapper equations mapper for the primary equations set
+   * @param secondaryMappers equations mappers for the secondary equations sets
    */
-  protected void reinitialize(final double[] y, final boolean isForward) {
-
-    globalPreviousTime = Double.NaN;
-    globalCurrentTime  = Double.NaN;
-    softPreviousTime   = Double.NaN;
-    softCurrentTime    = Double.NaN;
-    h                  = Double.NaN;
-    interpolatedTime   = Double.NaN;
-
-    currentState            = y;
-    interpolatedState       = new double[y.length];
-    interpolatedDerivatives = new double[y.length];
-
-    finalized         = false;
-    this.forward      = isForward;
-    this.dirtyState   = true;
+  protected void reinitialize(final double[] y, final boolean isForward,
+                              final EquationsMapper primaryMapper,
+                              final EquationsMapper[] secondaryMappers) {
+
+    globalPreviousTime    = Double.NaN;
+    globalCurrentTime     = Double.NaN;
+    softPreviousTime      = Double.NaN;
+    softCurrentTime       = Double.NaN;
+    h                     = Double.NaN;
+    interpolatedTime      = Double.NaN;
+    currentState          = y;
+    finalized             = false;
+    this.forward          = isForward;
+    this.dirtyState       = true;
+    this.primaryMapper    = primaryMapper;
+    this.secondaryMappers = secondaryMappers.clone();
+    allocateInterpolatedArrays(y.length, primaryMapper, secondaryMappers);
 
   }
 
@@ -328,9 +397,9 @@ public abstract class AbstractStepInterp
   protected abstract void computeInterpolatedStateAndDerivatives(double theta,
                                                                  double oneMinusThetaH);
 
-  /** {@inheritDoc} */
-  public double[] getInterpolatedState() {
-
+  /** Lazy evaluation of complete interpolated state.
+   */
+  private void evaluateCompleteInterpolatedState() {
       // lazy evaluation of the state
       if (dirtyState) {
           final double oneMinusThetaH = globalCurrentTime - interpolatedTime;
@@ -338,24 +407,38 @@ public abstract class AbstractStepInterp
           computeInterpolatedStateAndDerivatives(theta, oneMinusThetaH);
           dirtyState = false;
       }
+  }
 
-      return interpolatedState;
-
+  /** {@inheritDoc} */
+  public double[] getInterpolatedState() {
+      evaluateCompleteInterpolatedState();
+      primaryMapper.extractEquationData(interpolatedState,
+                                        interpolatedPrimaryState);
+      return interpolatedPrimaryState;
   }
 
   /** {@inheritDoc} */
   public double[] getInterpolatedDerivatives() {
+      evaluateCompleteInterpolatedState();
+      primaryMapper.extractEquationData(interpolatedDerivatives,
+                                        interpolatedPrimaryDerivatives);
+      return interpolatedPrimaryDerivatives;
+  }
 
-      // lazy evaluation of the state
-      if (dirtyState) {
-          final double oneMinusThetaH = globalCurrentTime - interpolatedTime;
-          final double theta = (h == 0) ? 0 : (h - oneMinusThetaH) / h;
-          computeInterpolatedStateAndDerivatives(theta, oneMinusThetaH);
-          dirtyState = false;
-      }
-
-      return interpolatedDerivatives;
+  /** {@inheritDoc} */
+  public double[] getInterpolatedSecondaryState(final int index) {
+      evaluateCompleteInterpolatedState();
+      secondaryMappers[index].extractEquationData(interpolatedState,
+                                                  interpolatedSecondaryState[index]);
+      return interpolatedSecondaryState[index];
+  }
 
+  /** {@inheritDoc} */
+  public double[] getInterpolatedSecondaryDerivatives(final int index) {
+      evaluateCompleteInterpolatedState();
+      secondaryMappers[index].extractEquationData(interpolatedDerivatives,
+                                                  interpolatedSecondaryDerivatives[index]);
+      return interpolatedSecondaryDerivatives[index];
   }
 
   /**
@@ -439,6 +522,11 @@ public abstract class AbstractStepInterp
     out.writeDouble(softCurrentTime);
     out.writeDouble(h);
     out.writeBoolean(forward);
+    out.writeObject(primaryMapper);
+    out.write(secondaryMappers.length);
+    for (final EquationsMapper  mapper : secondaryMappers) {
+        out.writeObject(mapper);
+    }
 
     if (currentState != null) {
         for (int i = 0; i < currentState.length; ++i) {
@@ -468,11 +556,11 @@ public abstract class AbstractStepInterp
    * properly calling the {@link #setInterpolatedTime} method later,
    * once all rest of the object state has been set up properly.
    * @param in stream where to read the state from
-   * @return interpolated time be set later by the caller
+   * @return interpolated time to be set later by the caller
    * @exception IOException in case of read error
    */
   protected double readBaseExternal(final ObjectInput in)
-    throws IOException {
+    throws IOException, ClassNotFoundException {
 
     final int dimension = in.readInt();
     globalPreviousTime  = in.readDouble();
@@ -481,6 +569,11 @@ public abstract class AbstractStepInterp
     softCurrentTime     = in.readDouble();
     h                   = in.readDouble();
     forward             = in.readBoolean();
+    primaryMapper       = (EquationsMapper) in.readObject();
+    secondaryMappers    = new EquationsMapper[in.read()];
+    for (int i = 0; i < secondaryMappers.length; ++i) {
+        secondaryMappers[i] = (EquationsMapper) in.readObject();
+    }
     dirtyState          = true;
 
     if (dimension < 0) {
@@ -493,9 +586,8 @@ public abstract class AbstractStepInterp
     }
 
     // we do NOT handle the interpolated time and state here
-    interpolatedTime        = Double.NaN;
-    interpolatedState       = (dimension < 0) ? null : new double[dimension];
-    interpolatedDerivatives = (dimension < 0) ? null : new double[dimension];
+    interpolatedTime = Double.NaN;
+    allocateInterpolatedArrays(dimension, primaryMapper, secondaryMappers);
 
     finalized = true;
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/NordsieckStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/NordsieckStepInterpolator.java?rev=1176734&r1=1176733&r2=1176734&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/NordsieckStepInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/NordsieckStepInterpolator.java Wed Sep 28 05:56:42 2011
@@ -23,6 +23,7 @@ import java.io.ObjectOutput;
 import java.util.Arrays;
 
 import org.apache.commons.math.linear.Array2DRowRealMatrix;
+import org.apache.commons.math.ode.EquationsMapper;
 import org.apache.commons.math.util.FastMath;
 
 /**
@@ -104,10 +105,14 @@ public class NordsieckStepInterpolator e
      * @param y reference to the integrator array holding the state at
      * the end of the step
      * @param forward integration direction indicator
+     * @param primaryMapper equations mapper for the primary equations set
+     * @param secondaryMappers equations mappers for the secondary equations sets
      */
     @Override
-    public void reinitialize(final double[] y, final boolean forward) {
-        super.reinitialize(y, forward);
+    public void reinitialize(final double[] y, final boolean forward,
+                             final EquationsMapper primaryMapper,
+                             final EquationsMapper[] secondaryMappers) {
+        super.reinitialize(y, forward, primaryMapper, secondaryMappers);
         stateVariation = new double[y.length];
     }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/StepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/StepInterpolator.java?rev=1176734&r1=1176733&r2=1176734&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/StepInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/StepInterpolator.java Wed Sep 28 05:56:42 2011
@@ -101,6 +101,40 @@ public interface StepInterpolator extend
    */
   double[] getInterpolatedDerivatives();
 
+  /** Get the interpolated secondary state corresponding to the secondary equations.
+   * <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>
+   * @param index index of the secondary set, as returned by {@link
+   * org.apache.commons.math.ode.ExpandableStatefulODE#addSecondaryEquations(
+   * org.apache.commons.math.ode.SecondaryEquations)
+   * ExpandableStatefulODE.addSecondaryEquations(SecondaryEquations)}
+   * @return interpolated secondary state at the current interpolation date
+   * @see #getInterpolatedState()
+   * @see #getInterpolatedDerivatives()
+   * @see #getInterpolatedSecondaryDerivatives(String)
+   * @see #setInterpolatedTime(double)
+   * @since 3.0
+   */
+  double[] getInterpolatedSecondaryState(int index);
+
+  /** Get the interpolated secondary derivatives corresponding to the secondary equations.
+   * <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>
+   * @param index index of the secondary set, as returned by {@link
+   * org.apache.commons.math.ode.ExpandableStatefulODE#addSecondaryEquations(
+   * org.apache.commons.math.ode.SecondaryEquations)
+   * ExpandableStatefulODE.addSecondaryEquations(SecondaryEquations)}
+   * @return interpolated secondary derivatives at the current interpolation date
+   * @see #getInterpolatedState()
+   * @see #getInterpolatedDerivatives()
+   * @see #getInterpolatedSecondaryState(String)
+   * @see #setInterpolatedTime(double)
+   * @since 3.0
+   */
+  double[] getInterpolatedSecondaryDerivatives(int index);
+
   /** 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/trunk/src/main/resources/META-INF/localization/LocalizedFormats_fr.properties
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/resources/META-INF/localization/LocalizedFormats_fr.properties?rev=1176734&r1=1176733&r2=1176734&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/resources/META-INF/localization/LocalizedFormats_fr.properties (original)
+++ commons/proper/math/trunk/src/main/resources/META-INF/localization/LocalizedFormats_fr.properties Wed Sep 28 05:56:42 2011
@@ -281,7 +281,7 @@ UNBOUNDED_SOLUTION = solution non born\u
 UNKNOWN_MODE = mode {0} inconnu, modes connus : {1} ({2}), {3} ({4}), {5} ({6}), {7} ({8}), {9} ({10}) et {11} ({12})
 UNKNOWN_ADDITIONAL_EQUATION = \u00e9quation additionnelle inconnue
 UNKNOWN_PARAMETER = param\u00e8tre {0} inconnu
-UNMATCHED_ODE_IN_EXTENDED_SET = l''\u00e9quation diff\u00e9rentielle ne correspond pas \u00e0 l''\u00e9quation principale du jeu \u00e9tendu
+UNMATCHED_ODE_IN_EXPANDED_SET = l''\u00e9quation diff\u00e9rentielle ne correspond pas \u00e0 l''\u00e9quation principale du jeu \u00e9tendu
 CANNOT_PARSE_AS_TYPE = cha\u00eene {0} non analysable (\u00e0 partir de la position {1}) en un objet de type {2}
 CANNOT_PARSE = cha\u00eene {0} non analysable (\u00e0 partir de la position {1})
 UNPARSEABLE_3D_VECTOR = vecteur 3D non analysable : "{0}"

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/JacobianMatricesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/JacobianMatricesTest.java?rev=1176734&r1=1176733&r2=1176734&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/JacobianMatricesTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/JacobianMatricesTest.java Wed Sep 28 05:56:42 2011
@@ -85,7 +85,7 @@ public class JacobianMatricesTest {
 
     @Test
     public void testInternalDifferentiation() {
-        ExpandableFirstOrderIntegrator integ =
+        AbstractIntegrator integ =
             new DormandPrince54Integrator(1.0e-8, 100.0, new double[] { 1.0e-4, 1.0e-4 }, new double[] { 1.0e-4, 1.0e-4 });
         double hP = 1.0e-12;
         double hY = 1.0e-12;
@@ -97,15 +97,19 @@ public class JacobianMatricesTest {
             double[] z = { 1.3, b };
             double[][] dZdZ0 = new double[2][2];
             double[]   dZdP  = new double[2];
-            ExpandableFirstOrderDifferentialEquations efode = new ExpandableFirstOrderDifferentialEquations(brusselator);
-            JacobianMatrices jacob = new JacobianMatrices(efode, brusselator);
+
+            JacobianMatrices jacob = new JacobianMatrices(brusselator, new double[] { hY, hY }, ParamBrusselator.B);
             jacob.setParameterizedODE(brusselator);
-            jacob.selectParameters(ParamBrusselator.B);
-            jacob.setMainStateSteps(new double[] { hY, hY });
             jacob.setParameterStep(ParamBrusselator.B, hP);
             jacob.setInitialParameterJacobian(ParamBrusselator.B, new double[] { 0.0, 1.0 });
+
+            ExpandableStatefulODE efode = new ExpandableStatefulODE(brusselator);
+            efode.setTime(0);
+            efode.setPrimaryState(z);
+            jacob.registerVariationalEquations(efode);
+
             integ.setMaxEvaluations(5000);
-            integ.integrate(efode, 0, z, 20.0, z);
+            integ.integrate(efode, 20.0);
             jacob.getCurrentMainSetJacobian(dZdZ0);
             jacob.getCurrentParameterJacobian(ParamBrusselator.B, dZdP);
 //            Assert.assertEquals(5000, integ.getMaxEvaluations());
@@ -123,7 +127,7 @@ public class JacobianMatricesTest {
 
     @Test
     public void testAnalyticalDifferentiation() {
-        ExpandableFirstOrderIntegrator integ =
+        AbstractIntegrator integ =
             new DormandPrince54Integrator(1.0e-8, 100.0, new double[] { 1.0e-4, 1.0e-4 }, new double[] { 1.0e-4, 1.0e-4 });
         SummaryStatistics residualsP0 = new SummaryStatistics();
         SummaryStatistics residualsP1 = new SummaryStatistics();
@@ -132,13 +136,18 @@ public class JacobianMatricesTest {
             double[] z = { 1.3, b };
             double[][] dZdZ0 = new double[2][2];
             double[]   dZdP  = new double[2];
-            ExpandableFirstOrderDifferentialEquations efode = new ExpandableFirstOrderDifferentialEquations(brusselator);
-            JacobianMatrices jacob = new JacobianMatrices(efode, brusselator);
-            jacob.setParameterJacobianProvider(brusselator);
-            jacob.selectParameters(Brusselator.B);
+
+            JacobianMatrices jacob = new JacobianMatrices(brusselator, Brusselator.B);
+            jacob.addParameterJacobianProvider(brusselator);
             jacob.setInitialParameterJacobian(Brusselator.B, new double[] { 0.0, 1.0 });
+
+            ExpandableStatefulODE efode = new ExpandableStatefulODE(brusselator);
+            efode.setTime(0);
+            efode.setPrimaryState(z);
+            jacob.registerVariationalEquations(efode);
+
             integ.setMaxEvaluations(5000);
-            integ.integrate(efode, 0, z, 20.0, z);
+            integ.integrate(efode, 20.0);
             jacob.getCurrentMainSetJacobian(dZdZ0);
             jacob.getCurrentParameterJacobian(Brusselator.B, dZdP);
 //            Assert.assertEquals(5000, integ.getMaxEvaluations());
@@ -156,23 +165,28 @@ public class JacobianMatricesTest {
     @Test
     public void testFinalResult() {
 
-        ExpandableFirstOrderIntegrator integ =
+        AbstractIntegrator integ =
             new DormandPrince54Integrator(1.0e-8, 100.0, new double[] { 1.0e-10, 1.0e-10 }, new double[] { 1.0e-10, 1.0e-10 });
         double[] y = new double[] { 0.0, 1.0 };
         Circle circle = new Circle(y, 1.0, 1.0, 0.1);
 
-        ExpandableFirstOrderDifferentialEquations efode = new ExpandableFirstOrderDifferentialEquations(circle);
-        JacobianMatrices jacob = new JacobianMatrices(efode, circle);
-        jacob.setParameterJacobianProvider(circle);
-        jacob.selectParameters(Circle.CX, Circle.CY, Circle.OMEGA);
+        JacobianMatrices jacob = new JacobianMatrices(circle, Circle.CX, Circle.CY, Circle.OMEGA);
+        jacob.addParameterJacobianProvider(circle);
         jacob.setInitialMainStateJacobian(circle.exactDyDy0(0));
         jacob.setInitialParameterJacobian(Circle.CX, circle.exactDyDcx(0));
         jacob.setInitialParameterJacobian(Circle.CY, circle.exactDyDcy(0));
         jacob.setInitialParameterJacobian(Circle.OMEGA, circle.exactDyDom(0));
+
+        ExpandableStatefulODE efode = new ExpandableStatefulODE(circle);
+        efode.setTime(0);
+        efode.setPrimaryState(y);
+        jacob.registerVariationalEquations(efode);
+
         integ.setMaxEvaluations(5000);
 
         double t = 18 * FastMath.PI;
-        integ.integrate(efode, 0, y, t, y);
+        integ.integrate(efode, t);
+        y = efode.getPrimaryState();
         for (int i = 0; i < y.length; ++i) {
             Assert.assertEquals(circle.exactY(t)[i], y[i], 1.0e-9);
         }
@@ -204,7 +218,7 @@ public class JacobianMatricesTest {
     @Test
     public void testParameterizable() {
 
-        ExpandableFirstOrderIntegrator integ =
+        AbstractIntegrator integ =
             new DormandPrince54Integrator(1.0e-8, 100.0, new double[] { 1.0e-10, 1.0e-10 }, new double[] { 1.0e-10, 1.0e-10 });
         double[] y = new double[] { 0.0, 1.0 };
         ParameterizedCircle pcircle = new ParameterizedCircle(y, 1.0, 1.0, 0.1);
@@ -212,25 +226,29 @@ public class JacobianMatricesTest {
 //        pcircle.setParameter(ParameterizedCircle.CY, 1.0);
 //        pcircle.setParameter(ParameterizedCircle.OMEGA, 0.1);
 
-        ExpandableFirstOrderDifferentialEquations efode = new ExpandableFirstOrderDifferentialEquations(pcircle);
-
         double hP = 1.0e-12;
         double hY = 1.0e-12;
 
-        JacobianMatrices jacob = new JacobianMatrices(efode, pcircle);
-        jacob.setParameterJacobianProvider(pcircle);
+        JacobianMatrices jacob = new JacobianMatrices(pcircle, new double[] { hY, hY },
+                                                      Circle.CX, Circle.OMEGA);
+        jacob.addParameterJacobianProvider(pcircle);
         jacob.setParameterizedODE(pcircle);
-        jacob.selectParameters(Circle.CX, Circle.OMEGA);
-        jacob.setMainStateSteps(new double[] { hY, hY });
         jacob.setParameterStep(Circle.OMEGA, hP);
         jacob.setInitialMainStateJacobian(pcircle.exactDyDy0(0));
         jacob.setInitialParameterJacobian(Circle.CX, pcircle.exactDyDcx(0));
 //        jacob.setInitialParameterJacobian(Circle.CY, circle.exactDyDcy(0));
         jacob.setInitialParameterJacobian(Circle.OMEGA, pcircle.exactDyDom(0));
+
+        ExpandableStatefulODE efode = new ExpandableStatefulODE(pcircle);
+        efode.setTime(0);
+        efode.setPrimaryState(y);
+        jacob.registerVariationalEquations(efode);
+
         integ.setMaxEvaluations(50000);
 
         double t = 18 * FastMath.PI;
-        integ.integrate(efode, 0, y, t, y);
+        integ.integrate(efode, t);
+        y = efode.getPrimaryState();
         for (int i = 0; i < y.length; ++i) {
             Assert.assertEquals(pcircle.exactY(t)[i], y[i], 1.0e-9);
         }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java?rev=1176734&r1=1176733&r2=1176734&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java Wed Sep 28 05:56:42 2011
@@ -26,6 +26,7 @@ import java.io.ObjectOutputStream;
 import java.util.Random;
 
 import org.apache.commons.math.ode.ContinuousOutputModel;
+import org.apache.commons.math.ode.EquationsMapper;
 import org.apache.commons.math.ode.TestProblem1;
 import org.apache.commons.math.ode.TestProblem3;
 import org.apache.commons.math.ode.sampling.StepHandler;
@@ -42,7 +43,9 @@ public class EulerStepInterpolatorTest {
     double[]   y    =   { 0.0, 1.0, -2.0 };
     double[][] yDot = { { 1.0, 2.0, -2.0 } };
     EulerStepInterpolator interpolator = new EulerStepInterpolator();
-    interpolator.reinitialize(new DummyIntegrator(interpolator), y, yDot, true);
+    interpolator.reinitialize(new DummyIntegrator(interpolator), y, yDot, true,
+                              new EquationsMapper(0, y.length),
+                              new EquationsMapper[0]);
     interpolator.storeTime(0);
     interpolator.shift();
     interpolator.storeTime(1);
@@ -63,7 +66,9 @@ public class EulerStepInterpolatorTest {
     double[] y = y0.clone();
     double[][] yDot = { new double[y0.length] };
     EulerStepInterpolator interpolator = new EulerStepInterpolator();
-    interpolator.reinitialize(new DummyIntegrator(interpolator), y, yDot, true);
+    interpolator.reinitialize(new DummyIntegrator(interpolator), y, yDot, true,
+                              new EquationsMapper(0, y.length),
+                              new EquationsMapper[0]);
     interpolator.storeTime(t0);
 
     double dt = 1.0;
@@ -96,7 +101,9 @@ public class EulerStepInterpolatorTest {
     double[]   y    =   { 1.0, 3.0, -4.0 };
     double[][] yDot = { { 1.0, 2.0, -2.0 } };
     EulerStepInterpolator interpolator = new EulerStepInterpolator();
-    interpolator.reinitialize(new DummyIntegrator(interpolator), y, yDot, true);
+    interpolator.reinitialize(new DummyIntegrator(interpolator), y, yDot, true,
+                              new EquationsMapper(0, y.length),
+                              new EquationsMapper[0]);
     interpolator.storeTime(0);
     interpolator.shift();
     interpolator.storeTime(1);

Copied: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java (from r1175683, commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java?p2=commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java&p1=commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java&r1=1175683&r2=1176734&rev=1176734&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java Wed Sep 28 05:56:42 2011
@@ -21,6 +21,8 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 
+import org.apache.commons.math.ode.EquationsMapper;
+
 /** This class is a step interpolator that does nothing.
  *
  * <p>This class is used when the {@link StepHandler "step handler"}
@@ -65,9 +67,11 @@ public class DummyStepInterpolator
    * @param yDot reference to the integrator array holding the state
    * derivative at some arbitrary point within the step
    * @param forward integration direction indicator
+   * @param primaryMapper equations mapper for the primary equations set
+   * @param secondaryMappers equations mappers for the secondary equations sets
    */
   public DummyStepInterpolator(final double[] y, final double[] yDot, final boolean forward) {
-    super(y, forward);
+    super(y, forward, new EquationsMapper(0, y.length), new EquationsMapper[0]);
     currentDerivative = yDot;
   }
 
@@ -128,7 +132,7 @@ public class DummyStepInterpolator
    */
   @Override
   public void readExternal(final ObjectInput in)
-    throws IOException {
+    throws IOException, ClassNotFoundException {
 
     // read the base class
     final double t = readBaseExternal(in);

Propchange: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message