commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1379975 [1/3] - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math3/ode/ main/java/org/apache/commons/math3/ode/events/ main/java/org/apache/commons/math3/ode/nonstiff/ main/java/org/apache/commons/math3/ode/sampling/ tes...
Date Sun, 02 Sep 2012 14:21:02 GMT
Author: luc
Date: Sun Sep  2 14:21:00 2012
New Revision: 1379975

URL: http://svn.apache.org/viewvc?rev=1379975&view=rev
Log:
populate throws declaration for ODE package

Added:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/UnknownParameterException.java
      - copied, changed from r1379974, commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterizedODE.java
Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractParameterizable.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ContinuousOutputModel.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ExpandableStatefulODE.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/FirstOrderDifferentialEquations.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/FirstOrderIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/JacobianMatrices.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/MainStateJacobianProvider.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/MultistepIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianProvider.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianWrapper.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterizedODE.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterizedWrapper.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/SecondaryEquations.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/events/EventState.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsBashforthIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsMoultonIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdaptiveStepsizeIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/GraggBulirschStoerIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/AbstractStepInterpolator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/NordsieckStepInterpolator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepHandler.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepInterpolator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepNormalizer.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/ContinuousOutputModelTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/FirstOrderConverterTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/JacobianMatricesTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/TestProblemHandler.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/EventStateTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/OverlappingEventsTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/ReappearingEventTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/AdamsBashforthIntegratorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/AdamsMoultonIntegratorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaStepInterpolatorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54IntegratorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54StepInterpolatorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853IntegratorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolatorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerIntegratorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerStepInterpolatorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/GillIntegratorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/GillStepInterpolatorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/GraggBulirschStoerIntegratorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/HighamHall54IntegratorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/HighamHall54StepInterpolatorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/MidpointIntegratorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/MidpointStepInterpolatorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/ThreeEighthesIntegratorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/ThreeEighthesStepInterpolatorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/sampling/DummyStepInterpolatorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/sampling/NordsieckStepInterpolatorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/sampling/StepInterpolatorTestUtils.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/sampling/StepNormalizerOutputTestBase.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/sampling/StepNormalizerTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java Sun Sep  2 14:21:00 2012
@@ -29,9 +29,9 @@ import java.util.TreeSet;
 import org.apache.commons.math3.analysis.solvers.BracketingNthOrderBrentSolver;
 import org.apache.commons.math3.analysis.solvers.UnivariateSolver;
 import org.apache.commons.math3.exception.DimensionMismatchException;
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathIllegalStateException;
+import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.exception.MaxCountExceededException;
+import org.apache.commons.math3.exception.NoBracketingException;
 import org.apache.commons.math3.exception.NumberIsTooSmallException;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
 import org.apache.commons.math3.ode.events.EventHandler;
@@ -125,9 +125,14 @@ public abstract class AbstractIntegrator
                                 final double maxCheckInterval,
                                 final double convergence,
                                 final int maxIterationCount) {
-        addEventHandler(handler, maxCheckInterval, convergence,
-                        maxIterationCount,
-                        new BracketingNthOrderBrentSolver(convergence, 5));
+        try {
+            addEventHandler(handler, maxCheckInterval, convergence,
+                            maxIterationCount,
+                            new BracketingNthOrderBrentSolver(convergence, 5));
+        } catch (NumberIsTooSmallException ntse) {
+            // this should never happen
+            throw new MathInternalError();
+        }
     }
 
     /** {@inheritDoc} */
@@ -210,7 +215,8 @@ public abstract class AbstractIntegrator
     /** {@inheritDoc} */
     public double integrate(final FirstOrderDifferentialEquations equations,
                             final double t0, final double[] y0, final double t, final double[] y)
-        throws MathIllegalStateException, MathIllegalArgumentException {
+        throws DimensionMismatchException, NumberIsTooSmallException,
+               MaxCountExceededException, NoBracketingException {
 
         if (y0.length != equations.getDimension()) {
             throw new DimensionMismatchException(y0.length, equations.getDimension());
@@ -246,21 +252,25 @@ public abstract class AbstractIntegrator
      * @param equations complete set of differential equations to integrate
      * @param t target time for the integration
      * (can be set to a value smaller than <code>t0</code> for backward integration)
-     * @throws MathIllegalStateException if the integrator cannot perform integration
-     * @throws MathIllegalArgumentException if integration parameters are wrong (typically
-     * too small integration span)
+     * @exception NumberIsTooSmallException if integration step is too small
+     * @throws DimensionMismatchException if the dimension of the complete state does not
+     * match the complete equations sets dimension
+     * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+     * @exception NoBracketingException if the location of an event cannot be bracketed
      */
     public abstract void integrate(ExpandableStatefulODE equations, double t)
-        throws MathIllegalStateException, MathIllegalArgumentException;
+        throws NumberIsTooSmallException, DimensionMismatchException,
+               MaxCountExceededException, NoBracketingException;
 
     /** Compute the derivatives and check the number of evaluations.
      * @param t current value of the independent <I>time</I> variable
      * @param y array containing the current value of the state vector
      * @param yDot placeholder array where to put the time derivative of the state vector
      * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+     * @exception DimensionMismatchException if arrays dimensions do not match equations settings
      */
     public void computeDerivatives(final double t, final double[] y, final double[] yDot)
-        throws MaxCountExceededException {
+        throws MaxCountExceededException, DimensionMismatchException {
         evaluations.incrementCount();
         expandable.computeDerivatives(t, y, yDot);
     }
@@ -283,12 +293,15 @@ public abstract class AbstractIntegrator
      * @param yDot placeholder array where to put the time derivative of the state vector
      * @param tEnd final integration time
      * @return time at end of step
-     * @exception MathIllegalStateException if the value of one event state cannot be evaluated
+     * @exception MaxCountExceededException if the interpolator throws one because
+     * the number of functions evaluations is exceeded
+     * @exception NoBracketingException if the location of an event cannot be bracketed
+     * @exception DimensionMismatchException if arrays dimensions do not match equations settings
      * @since 2.2
      */
     protected double acceptStep(final AbstractStepInterpolator interpolator,
                                 final double[] y, final double[] yDot, final double tEnd)
-        throws MathIllegalStateException {
+        throws MaxCountExceededException, DimensionMismatchException, NoBracketingException {
 
             double previousT = interpolator.getGlobalPreviousTime();
             final double currentT = interpolator.getGlobalCurrentTime();
@@ -397,9 +410,11 @@ public abstract class AbstractIntegrator
      * @param equations set of differential equations
      * @param t target time for the integration
      * @exception NumberIsTooSmallException if integration span is too small
+     * @exception DimensionMismatchException if adaptive step size integrators
+     * tolerance arrays dimensions are not compatible with equations settings
      */
     protected void sanityChecks(final ExpandableStatefulODE equations, final double t)
-        throws NumberIsTooSmallException {
+        throws NumberIsTooSmallException, DimensionMismatchException {
 
         final double threshold = 1000 * FastMath.ulp(FastMath.max(FastMath.abs(equations.getTime()),
                                                                   FastMath.abs(t)));

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractParameterizable.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractParameterizable.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractParameterizable.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractParameterizable.java Sun Sep  2 14:21:00 2012
@@ -19,9 +19,6 @@ package org.apache.commons.math3.ode;
 import java.util.ArrayList;
 import java.util.Collection;
 
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.util.LocalizedFormats;
-
 /** This abstract class provides boilerplate parameters list.
  *
  * @version $Id$
@@ -68,13 +65,13 @@ public abstract class AbstractParameteri
 
     /** Check if a parameter is supported and throw an IllegalArgumentException if not.
      * @param name name of the parameter to check
-     * @exception MathIllegalArgumentException if the parameter is not supported
+     * @exception UnknownParameterException if the parameter is not supported
      * @see #isSupported(String)
      */
     public void complainIfNotSupported(final String name)
-        throws MathIllegalArgumentException {
+        throws UnknownParameterException {
         if (!isSupported(name)) {
-            throw new MathIllegalArgumentException(LocalizedFormats.UNKNOWN_PARAMETER, name);
+            throw new UnknownParameterException(name);
         }
     }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ContinuousOutputModel.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ContinuousOutputModel.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ContinuousOutputModel.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ContinuousOutputModel.java Sun Sep  2 14:21:00 2012
@@ -23,6 +23,7 @@ import java.util.List;
 
 import org.apache.commons.math3.exception.DimensionMismatchException;
 import org.apache.commons.math3.exception.MathIllegalArgumentException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
 import org.apache.commons.math3.ode.sampling.StepHandler;
 import org.apache.commons.math3.ode.sampling.StepInterpolator;
@@ -123,9 +124,11 @@ public class ContinuousOutputModel
    * @exception MathIllegalArgumentException if the model to append is not
    * compatible with the instance (dimension of the state vector,
    * propagation direction, hole between the dates)
+   * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+   * during step finalization
    */
   public void append(final ContinuousOutputModel model)
-    throws MathIllegalArgumentException {
+    throws MathIllegalArgumentException, MaxCountExceededException {
 
     if (model.steps.size() == 0) {
       return;
@@ -180,8 +183,11 @@ public class ContinuousOutputModel
    * the instance for later use.
    * @param interpolator interpolator for the last accepted step.
    * @param isLast true if the step is the last one
+   * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+   * during step finalization
    */
-  public void handleStep(final StepInterpolator interpolator, final boolean isLast) {
+  public void handleStep(final StepInterpolator interpolator, final boolean isLast)
+      throws MaxCountExceededException {
 
     if (steps.size() == 0) {
       initialTime = interpolator.getPreviousTime();
@@ -326,8 +332,9 @@ public class ContinuousOutputModel
   /**
    * Get the state vector of the interpolated point.
    * @return state vector at time {@link #getInterpolatedTime}
+   * @exception MaxCountExceededException if the number of functions evaluations is exceeded
    */
-  public double[] getInterpolatedState() {
+  public double[] getInterpolatedState() throws MaxCountExceededException {
     return steps.get(index).getInterpolatedState();
   }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ExpandableStatefulODE.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ExpandableStatefulODE.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ExpandableStatefulODE.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ExpandableStatefulODE.java Sun Sep  2 14:21:00 2012
@@ -20,6 +20,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
 
 
 /**
@@ -107,8 +108,11 @@ public class ExpandableStatefulODE {
      * @param t current value of the independent <I>time</I> variable
      * @param y array containing the current value of the complete state vector
      * @param yDot placeholder array where to put the time derivative of the complete state vector
+     * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+     * @exception DimensionMismatchException if arrays dimensions do not match equations settings
      */
-    public void computeDerivatives(final double t, final double[] y, final double[] yDot) {
+    public void computeDerivatives(final double t, final double[] y, final double[] yDot)
+        throws MaxCountExceededException, DimensionMismatchException {
 
         // compute derivatives of the primary equations
         primaryMapper.extractEquationData(y, primaryState);
@@ -279,7 +283,7 @@ public class ExpandableStatefulODE {
      * @throws DimensionMismatchException if the dimension of the complete state does not
      * match the complete equations sets dimension
      */
-    public double[] getCompleteState() {
+    public double[] getCompleteState() throws DimensionMismatchException {
 
         // allocate complete array
         double[] completeState = new double[getTotalDimension()];

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/FirstOrderDifferentialEquations.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/FirstOrderDifferentialEquations.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/FirstOrderDifferentialEquations.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/FirstOrderDifferentialEquations.java Sun Sep  2 14:21:00 2012
@@ -17,6 +17,9 @@
 
 package org.apache.commons.math3.ode;
 
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+
 
 
 /** This interface represents a first order differential equations set.
@@ -57,7 +60,10 @@ public interface FirstOrderDifferentialE
      * @param t current value of the independent <I>time</I> variable
      * @param y array containing the current value of the state vector
      * @param yDot placeholder array where to put the time derivative of the state vector
+     * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+     * @exception DimensionMismatchException if arrays dimensions do not match equations settings
      */
-    void computeDerivatives(double t, double[] y, double[] yDot);
+    void computeDerivatives(double t, double[] y, double[] yDot)
+        throws MaxCountExceededException, DimensionMismatchException;
 
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/FirstOrderIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/FirstOrderIntegrator.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/FirstOrderIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/FirstOrderIntegrator.java Sun Sep  2 14:21:00 2012
@@ -17,8 +17,10 @@
 
 package org.apache.commons.math3.ode;
 
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathIllegalStateException;
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+import org.apache.commons.math3.exception.NoBracketingException;
+import org.apache.commons.math3.exception.NumberIsTooSmallException;
 
 /** This interface represents a first order integrator for
  * differential equations.
@@ -52,12 +54,14 @@ public interface FirstOrderIntegrator ex
    * @return stop time, will be the same as target time if integration reached its
    * target, but may be different if some {@link
    * org.apache.commons.math3.ode.events.EventHandler} stops it at some point.
-   * @throws MathIllegalStateException if the integrator cannot perform integration
-   * @throws MathIllegalArgumentException if integration parameters are wrong (typically
-   * too small integration span)
+   * @exception DimensionMismatchException if arrays dimension do not match equations settings
+   * @exception NumberIsTooSmallException if integration step is too small
+   * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+   * @exception NoBracketingException if the location of an event cannot be bracketed
    */
   double integrate (FirstOrderDifferentialEquations equations,
                     double t0, double[] y0, double t, double[] y)
-      throws MathIllegalStateException, MathIllegalArgumentException;
+      throws DimensionMismatchException, NumberIsTooSmallException,
+             MaxCountExceededException, NoBracketingException;
 
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/JacobianMatrices.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/JacobianMatrices.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/JacobianMatrices.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/JacobianMatrices.java Sun Sep  2 14:21:00 2012
@@ -18,10 +18,13 @@ package org.apache.commons.math3.ode;
 
 import java.lang.reflect.Array;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.commons.math3.exception.DimensionMismatchException;
 import org.apache.commons.math3.exception.MathIllegalArgumentException;
+import org.apache.commons.math3.exception.MathInternalError;
+import org.apache.commons.math3.exception.MaxCountExceededException;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
 
 /**
@@ -96,12 +99,12 @@ public class JacobianMatrices {
      * @param hY step used for finite difference computation with respect to state vector
      * @param parameters parameters to consider for Jacobian matrices processing
      * (may be null if parameters Jacobians is not desired)
-     * @exception MathIllegalArgumentException if one parameter is not supported
-     * or there is a dimension mismatch with {@code hY}
+     * @exception DimensionMismatchException if there is a dimension mismatch between
+     * the steps array {@code hY} and the equation dimension
      */
     public JacobianMatrices(final FirstOrderDifferentialEquations fode, final double[] hY,
                             final String... parameters)
-        throws MathIllegalArgumentException {
+        throws DimensionMismatchException {
         this(new MainStateJacobianWrapper(fode, hY), parameters);
     }
 
@@ -116,11 +119,9 @@ public class JacobianMatrices {
      * @param jode the primary first order differential equations set to extend
      * @param parameters parameters to consider for Jacobian matrices processing
      * (may be null if parameters Jacobians is not desired)
-     * @exception MathIllegalArgumentException if one parameter is not supported
      */
     public JacobianMatrices(final MainStateJacobianProvider jode,
-                            final String... parameters)
-        throws MathIllegalArgumentException {
+                            final String... parameters) {
 
         this.efode = null;
         this.index = -1;
@@ -155,19 +156,21 @@ public class JacobianMatrices {
 
     /** Register the variational equations for the Jacobians matrices to the expandable set.
      * @param expandable expandable set into which variational equations should be registered
-     * @exception MathIllegalArgumentException if the primary set of the expandable set does
+     * @throws DimensionMismatchException if the dimension of the partial state does not
+     * match the selected equations set dimension
+     * @exception MismatchedEquations if the primary set of the expandable set does
      * not match the one used to build the instance
      * @see ExpandableStatefulODE#addSecondaryEquations(SecondaryEquations)
      */
     public void registerVariationalEquations(final ExpandableStatefulODE expandable)
-        throws MathIllegalArgumentException {
+        throws DimensionMismatchException, MismatchedEquations {
 
         // safety checks
         final FirstOrderDifferentialEquations ode = (jode instanceof MainStateJacobianWrapper) ?
                                                     ((MainStateJacobianWrapper) jode).ode :
                                                     jode;
         if (expandable.getPrimary() != ode) {
-            throw new MathIllegalArgumentException(LocalizedFormats.UNMATCHED_ODE_IN_EXPANDED_SET);
+            throw new MismatchedEquations();
         }
 
         efode = expandable;
@@ -183,7 +186,7 @@ public class JacobianMatrices {
         jacobianProviders.add(provider);
     }
 
-    /** Add a parameter Jacobian provider.
+    /** Set a parameter Jacobian provider.
      * @param parameterizedOde the parameterized ODE to compute the parameter Jacobian matrix using finite differences
      */
     public void setParameterizedODE(final ParameterizedODE parameterizedOde) {
@@ -206,9 +209,10 @@ public class JacobianMatrices {
      * @param parameter parameter to consider for Jacobian processing
      * @param hP step for Jacobian finite difference computation w.r.t. the specified parameter
      * @see ParameterizedODE
-     * @exception IllegalArgumentException if the parameter is not supported
+     * @exception UnknownParameterException if the parameter is not supported
      */
-    public void setParameterStep(final String parameter, final double hP) {
+    public void setParameterStep(final String parameter, final double hP)
+        throws UnknownParameterException {
 
         for (ParameterConfiguration param: selectedParameters) {
             if (parameter.equals(param.getParameterName())) {
@@ -218,7 +222,7 @@ public class JacobianMatrices {
             }
         }
 
-        throw new MathIllegalArgumentException(LocalizedFormats.UNKNOWN_PARAMETER, parameter);
+        throw new UnknownParameterException(parameter);
 
     }
 
@@ -257,10 +261,11 @@ public class JacobianMatrices {
      * </p>
      * @param pName parameter name
      * @param dYdP initial Jacobian column vector with respect to the parameter
-     * @exception MathIllegalArgumentException if a parameter is not supported
+     * @exception UnknownParameterException if a parameter is not supported
+     * @throws DimensionMismatchException if the column vector does not match state dimension
      */
     public void setInitialParameterJacobian(final String pName, final double[] dYdP)
-        throws MathIllegalArgumentException {
+        throws UnknownParameterException, DimensionMismatchException {
 
         // Check dimensions
         checkDimension(stateDim, dYdP);
@@ -278,7 +283,7 @@ public class JacobianMatrices {
             i += stateDim;
         }
 
-        throw new MathIllegalArgumentException(LocalizedFormats.UNKNOWN_PARAMETER, pName);
+        throw new UnknownParameterException(pName);
 
     }
 
@@ -346,7 +351,8 @@ public class JacobianMatrices {
 
         /** {@inheritDoc} */
         public void computeDerivatives(final double t, final double[] y, final double[] yDot,
-                                       final double[] z, final double[] zDot) {
+                                       final double[] z, final double[] zDot)
+            throws MaxCountExceededException, DimensionMismatchException {
 
             // Lazy initialization
             if (dirtyParameter && (paramDim != 0)) {
@@ -382,31 +388,33 @@ public class JacobianMatrices {
                 int startIndex = stateDim * stateDim;
                 for (ParameterConfiguration param: selectedParameters) {
                     boolean found = false;
-                    for (ParameterJacobianProvider provider: jacobianProviders) {
+                    for (int k = 0 ; (!found) && (k < jacobianProviders.size()); ++k) {
+                        final ParameterJacobianProvider provider = jacobianProviders.get(k);
                         if (provider.isSupported(param.getParameterName())) {
                             try {
-                                provider.computeParameterJacobian(t, y, yDot, param.getParameterName(), dFdP);
-                                for (int i = 0; i < stateDim; ++i) {
-                                    final double[] dFdYi = dFdY[i];
-                                    int zIndex = startIndex;
-                                    double s = dFdP[i];
-                                    for (int l = 0; l < stateDim; ++l) {
-                                        s += dFdYi[l] * z[zIndex];
-                                        zIndex++;
-                                    }
-                                    zDot[startIndex + i] = s;
+                                provider.computeParameterJacobian(t, y, yDot,
+                                                                  param.getParameterName(), dFdP);
+                            } catch (UnknownParameterException upe) {
+                                // this should never happen as we have check support beforehand
+                                throw new MathInternalError(upe);
+                            }
+                            for (int i = 0; i < stateDim; ++i) {
+                                final double[] dFdYi = dFdY[i];
+                                int zIndex = startIndex;
+                                double s = dFdP[i];
+                                for (int l = 0; l < stateDim; ++l) {
+                                    s += dFdYi[l] * z[zIndex];
+                                    zIndex++;
                                 }
-                                startIndex += stateDim;
-                                found = true;
-                                break;
-                            } catch (IllegalArgumentException iae) {
+                                zDot[startIndex + i] = s;
                             }
+                            found = true;
                         }
                     }
                     if (! found) {
-                        throw new MathIllegalArgumentException(LocalizedFormats.UNKNOWN_PARAMETER,
-                                                               param);
+                        Arrays.fill(zDot, startIndex, startIndex + stateDim, 0.0);
                     }
+                    startIndex += stateDim;
                 }
             }
 
@@ -428,11 +436,17 @@ public class JacobianMatrices {
          * @param ode original ODE problem, without jacobians computation skill
          * @param hY step sizes to compute the jacobian df/dy
          * @see JacobianMatrices#setMainStateSteps(double[])
+         * @exception DimensionMismatchException if there is a dimension mismatch between
+         * the steps array {@code hY} and the equation dimension
          */
         public MainStateJacobianWrapper(final FirstOrderDifferentialEquations ode,
-                                        final double[] hY) {
+                                        final double[] hY)
+            throws DimensionMismatchException {
             this.ode = ode;
             this.hY = hY.clone();
+            if (hY.length != ode.getDimension()) {
+                throw new DimensionMismatchException(ode.getDimension(), hY.length);
+            }
         }
 
         /** {@inheritDoc} */
@@ -441,13 +455,14 @@ public class JacobianMatrices {
         }
 
         /** {@inheritDoc} */
-        public void computeDerivatives(double t, double[] y, double[] yDot) {
+        public void computeDerivatives(double t, double[] y, double[] yDot)
+            throws MaxCountExceededException, DimensionMismatchException {
             ode.computeDerivatives(t, y, yDot);
         }
 
         /** {@inheritDoc} */
-        public void computeMainStateJacobian(double t, double[] y, double[] yDot,
-                                             double[][] dFdY) {
+        public void computeMainStateJacobian(double t, double[] y, double[] yDot, double[][] dFdY)
+            throws MaxCountExceededException, DimensionMismatchException {
 
             final int n = ode.getDimension();
             final double[] tmpDot = new double[n];
@@ -465,5 +480,18 @@ public class JacobianMatrices {
 
     }
 
+    /** Special exception for equations mismatch. */
+    public static class MismatchedEquations extends MathIllegalArgumentException {
+
+        /** Serializable UID. */
+        private static final long serialVersionUID = 20120902L;
+
+        /** Simple constructor. */
+        public MismatchedEquations() {
+            super(LocalizedFormats.UNMATCHED_ODE_IN_EXPANDED_SET);
+        }
+
+    }
+
 }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/MainStateJacobianProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/MainStateJacobianProvider.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/MainStateJacobianProvider.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/MainStateJacobianProvider.java Sun Sep  2 14:21:00 2012
@@ -16,6 +16,9 @@
  */
 package org.apache.commons.math3.ode;
 
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+
 /** Interface expanding {@link FirstOrderDifferentialEquations first order
  *  differential equations} in order to compute exactly the main state jacobian
  *  matrix for {@link JacobianMatrices partial derivatives equations}.
@@ -30,7 +33,10 @@ public interface MainStateJacobianProvid
      * @param y array containing the current value of the main state vector
      * @param yDot array containing the current value of the time derivative of the main state vector
      * @param dFdY placeholder array where to put the jacobian matrix of the ODE w.r.t. the main state vector
+     * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+     * @exception DimensionMismatchException if arrays dimensions do not match equations settings
      */
-    void computeMainStateJacobian(double t, double[] y, double[] yDot, double[][] dFdY);
+    void computeMainStateJacobian(double t, double[] y, double[] yDot, double[][] dFdY)
+        throws MaxCountExceededException, DimensionMismatchException;
 
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/MultistepIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/MultistepIntegrator.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/MultistepIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/MultistepIntegrator.java Sun Sep  2 14:21:00 2012
@@ -17,8 +17,10 @@
 
 package org.apache.commons.math3.ode;
 
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathIllegalStateException;
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+import org.apache.commons.math3.exception.NoBracketingException;
+import org.apache.commons.math3.exception.NumberIsTooSmallException;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
 import org.apache.commons.math3.linear.Array2DRowRealMatrix;
 import org.apache.commons.math3.ode.nonstiff.AdaptiveStepsizeIntegrator;
@@ -104,19 +106,21 @@ public abstract class MultistepIntegrato
      * integration)
      * @param scalAbsoluteTolerance allowed absolute error
      * @param scalRelativeTolerance allowed relative error
+     * @exception NumberIsTooSmallException if number of steps is smaller than 2
      */
     protected MultistepIntegrator(final String name, final int nSteps,
                                   final int order,
                                   final double minStep, final double maxStep,
                                   final double scalAbsoluteTolerance,
-                                  final double scalRelativeTolerance) {
+                                  final double scalRelativeTolerance)
+        throws NumberIsTooSmallException {
 
         super(name, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
 
-        if (nSteps <= 1) {
-            throw new MathIllegalArgumentException(
+        if (nSteps < 2) {
+            throw new NumberIsTooSmallException(
                   LocalizedFormats.INTEGRATION_METHOD_NEEDS_AT_LEAST_TWO_PREVIOUS_POINTS,
-                  name);
+                  nSteps, 2, true);
         }
 
         starter = new DormandPrince853Integrator(minStep, maxStep,
@@ -204,10 +208,14 @@ public abstract class MultistepIntegrato
      * @param y0 initial value of the state vector at t0
      * @param t target time for the integration
      * (can be set to a value smaller than <code>t0</code> for backward integration)
-     * @throws MathIllegalStateException if the integrator cannot perform integration
+     * @exception DimensionMismatchException if arrays dimension do not match equations settings
+     * @exception NumberIsTooSmallException if integration step is too small
+     * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+     * @exception NoBracketingException if the location of an event cannot be bracketed
      */
     protected void start(final double t0, final double[] y0, final double t)
-        throws MathIllegalStateException {
+        throws DimensionMismatchException, NumberIsTooSmallException,
+               MaxCountExceededException, NoBracketingException {
 
         // make sure NO user event nor user step handler is triggered,
         // this is the task of the top level integrator, not the task
@@ -335,7 +343,8 @@ public abstract class MultistepIntegrato
         }
 
         /** {@inheritDoc} */
-        public void handleStep(StepInterpolator interpolator, boolean isLast) {
+        public void handleStep(StepInterpolator interpolator, boolean isLast)
+            throws MaxCountExceededException {
 
             final double prev = interpolator.getPreviousTime();
             final double curr = interpolator.getCurrentTime();
@@ -416,7 +425,8 @@ public abstract class MultistepIntegrato
         }
 
         /** {@inheritDoc} */
-        public void computeDerivatives(double t, double[] y, double[] dot) {
+        public void computeDerivatives(double t, double[] y, double[] dot)
+            throws MaxCountExceededException, DimensionMismatchException {
             MultistepIntegrator.this.computeDerivatives(t, y, dot);
         }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianProvider.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianProvider.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianProvider.java Sun Sep  2 14:21:00 2012
@@ -16,7 +16,8 @@
  */
 package org.apache.commons.math3.ode;
 
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
 
 /** Interface to compute exactly Jacobian matrix for some parameter
  *  when computing {@link JacobianMatrices partial derivatives equations}.
@@ -27,7 +28,9 @@ import org.apache.commons.math3.exceptio
 public interface ParameterJacobianProvider extends Parameterizable {
 
     /** Compute the Jacobian matrix of ODE with respect to one parameter.
-     * <p>The parameter must be one given by {@link #getParametersNames()}.</p>
+     * <p>If the parameter does not belong to the collection returned by
+     * {@link #getParametersNames()}, the Jacobian will be set to 0,
+     * but no errors will be triggered.</p>
      * @param t current value of the independent <I>time</I> variable
      * @param y array containing the current value of the main state vector
      * @param yDot array containing the current value of the time derivative
@@ -35,10 +38,12 @@ public interface ParameterJacobianProvid
      * @param paramName name of the parameter to consider
      * @param dFdP placeholder array where to put the Jacobian matrix of the
      * ODE with respect to the parameter
-     * @throws MathIllegalArgumentException if the parameter is not supported
+     * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+     * @exception DimensionMismatchException if arrays dimensions do not match equations settings
+     * @exception UnknownParameterException if the parameter is not supported
      */
     void computeParameterJacobian(double t, double[] y, double[] yDot,
                                   String paramName, double[] dFdP)
-        throws MathIllegalArgumentException;
+        throws DimensionMismatchException, MaxCountExceededException, UnknownParameterException;
 
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianWrapper.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianWrapper.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianWrapper.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianWrapper.java Sun Sep  2 14:21:00 2012
@@ -16,10 +16,16 @@
  */
 package org.apache.commons.math3.ode;
 
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
+import org.apache.commons.math3.exception.MathInternalError;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+
 /** Wrapper class to compute Jacobian matrices by finite differences for ODE
  *  which do not compute them by themselves.
  *
@@ -71,20 +77,30 @@ class ParameterJacobianWrapper implement
 
     /** {@inheritDoc} */
     public void computeParameterJacobian(double t, double[] y, double[] yDot,
-                                         String paramName, double[] dFdP) {
+                                         String paramName, double[] dFdP)
+        throws DimensionMismatchException, MaxCountExceededException {
 
         final int n = fode.getDimension();
-        final double[] tmpDot = new double[n];
-
-        // compute the jacobian df/dp w.r.t. parameter
-        final double p  = pode.getParameter(paramName);
-        final double hP = hParam.get(paramName);
-        pode.setParameter(paramName, p + hP);
-        fode.computeDerivatives(t, y, tmpDot);
-        for (int i = 0; i < n; ++i) {
-            dFdP[i] = (tmpDot[i] - yDot[i]) / hP;
+        if (pode.isSupported(paramName)) {
+            try {
+                final double[] tmpDot = new double[n];
+
+                // compute the jacobian df/dp w.r.t. parameter
+                final double p  = pode.getParameter(paramName);
+                final double hP = hParam.get(paramName);
+                pode.setParameter(paramName, p + hP);
+                fode.computeDerivatives(t, y, tmpDot);
+                for (int i = 0; i < n; ++i) {
+                    dFdP[i] = (tmpDot[i] - yDot[i]) / hP;
+                }
+                pode.setParameter(paramName, p);
+            } catch (MathIllegalArgumentException miae) {
+                // this should never happen as we have checked the parameter is supported
+                throw new MathInternalError(miae);
+            }
+        } else {
+            Arrays.fill(dFdP, 0, n, 0.0);
         }
-        pode.setParameter(paramName, p);
 
     }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterizedODE.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterizedODE.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterizedODE.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterizedODE.java Sun Sep  2 14:21:00 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.math3.ode;
 
+
 /** Interface to compute by finite difference Jacobian matrix for some parameter
  *  when computing {@link JacobianMatrices partial derivatives equations}.
  *
@@ -28,15 +29,15 @@ public interface ParameterizedODE extend
     /** Get parameter value from its name.
      * @param name parameter name
      * @return parameter value
-     * @exception IllegalArgumentException if parameter is not supported
+     * @exception UnknownParameterException if parameter is not supported
      */
-    double getParameter(String name) throws IllegalArgumentException;
+    double getParameter(String name) throws UnknownParameterException;
 
     /** Set the value for a given parameter.
      * @param name parameter name
      * @param value parameter value
-     * @exception IllegalArgumentException if parameter is not supported
+     * @exception UnknownParameterException if parameter is not supported
      */
-    void setParameter(String name, double value) throws IllegalArgumentException;
+    void setParameter(String name, double value) throws UnknownParameterException;
 
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterizedWrapper.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterizedWrapper.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterizedWrapper.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterizedWrapper.java Sun Sep  2 14:21:00 2012
@@ -19,8 +19,8 @@ package org.apache.commons.math3.ode;
 import java.util.ArrayList;
 import java.util.Collection;
 
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.util.LocalizedFormats;
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
 
 /** Wrapper class enabling {@link FirstOrderDifferentialEquations basic simple}
  *  ODE instances to be used when processing {@link JacobianMatrices}.
@@ -51,8 +51,11 @@ class ParameterizedWrapper implements Pa
      * @param t current value of the independent <I>time</I> variable
      * @param y array containing the current value of the state vector
      * @param yDot placeholder array where to put the time derivative of the state vector
+     * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+     * @exception DimensionMismatchException if arrays dimensions do not match equations settings
      */
-    public void computeDerivatives(double t, double[] y, double[] yDot) {
+    public void computeDerivatives(double t, double[] y, double[] yDot)
+        throws MaxCountExceededException, DimensionMismatchException {
         fode.computeDerivatives(t, y, yDot);
     }
 
@@ -68,9 +71,9 @@ class ParameterizedWrapper implements Pa
 
     /** {@inheritDoc} */
     public double getParameter(String name)
-        throws MathIllegalArgumentException {
+        throws UnknownParameterException {
         if (!isSupported(name)) {
-            throw new MathIllegalArgumentException(LocalizedFormats.UNKNOWN_PARAMETER, name);
+            throw new UnknownParameterException(name);
         }
         return Double.NaN;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/SecondaryEquations.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/SecondaryEquations.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/SecondaryEquations.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/SecondaryEquations.java Sun Sep  2 14:21:00 2012
@@ -17,6 +17,9 @@
 
 package org.apache.commons.math3.ode;
 
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+
 /**
  * This interface allows users to add secondary differential equations to a primary
  * set of differential equations.
@@ -49,8 +52,11 @@ public interface SecondaryEquations {
      * @param primaryDot array containing the derivative of the primary state vector
      * @param secondary array containing the current value of the secondary state vector
      * @param secondaryDot placeholder array where to put the derivative of the secondary state vector
+     * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+     * @exception DimensionMismatchException if arrays dimensions do not match equations settings
      */
     void computeDerivatives(double t, double[] primary, double[] primaryDot,
-                            double[] secondary, double[] secondaryDot);
+                            double[] secondary, double[] secondaryDot)
+        throws MaxCountExceededException, DimensionMismatchException;
 
 }

Copied: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/UnknownParameterException.java (from r1379974, commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterizedODE.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/UnknownParameterException.java?p2=commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/UnknownParameterException.java&p1=commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterizedODE.java&r1=1379974&r2=1379975&rev=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterizedODE.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/UnknownParameterException.java Sun Sep  2 14:21:00 2012
@@ -16,27 +16,38 @@
  */
 package org.apache.commons.math3.ode;
 
-/** Interface to compute by finite difference Jacobian matrix for some parameter
- *  when computing {@link JacobianMatrices partial derivatives equations}.
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
+import org.apache.commons.math3.exception.util.LocalizedFormats;
+
+/**
+ * Exception to be thrown when a parameter is unknown.
  *
+ * @since 3.1
  * @version $Id$
- * @since 3.0
  */
+public class UnknownParameterException extends MathIllegalArgumentException {
+
+    /** Serializable version Id. */
+    private static final long serialVersionUID = 20120902L;
 
-public interface ParameterizedODE extends Parameterizable {
+    /** Parameter name. */
+    private final String name;
 
-    /** Get parameter value from its name.
-     * @param name parameter name
-     * @return parameter value
-     * @exception IllegalArgumentException if parameter is not supported
+    /**
+     * Construct an exception from the unknown parameter.
+     *
+     * @param name parameter name.
      */
-    double getParameter(String name) throws IllegalArgumentException;
+    public UnknownParameterException(final String name) {
+        super(LocalizedFormats.UNKNOWN_PARAMETER);
+        this.name = name;
+    }
 
-    /** Set the value for a given parameter.
-     * @param name parameter name
-     * @param value parameter value
-     * @exception IllegalArgumentException if parameter is not supported
+    /**
+     * @return the name of the unknown parameter.
      */
-    void setParameter(String name, double value) throws IllegalArgumentException;
+    public String getName() {
+        return name;
+    }
 
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/events/EventState.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/events/EventState.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/events/EventState.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/events/EventState.java Sun Sep  2 14:21:00 2012
@@ -23,8 +23,8 @@ import org.apache.commons.math3.analysis
 import org.apache.commons.math3.analysis.solvers.PegasusSolver;
 import org.apache.commons.math3.analysis.solvers.UnivariateSolver;
 import org.apache.commons.math3.analysis.solvers.UnivariateSolverUtils;
-import org.apache.commons.math3.exception.ConvergenceException;
-import org.apache.commons.math3.ode.events.EventHandler;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+import org.apache.commons.math3.exception.NoBracketingException;
 import org.apache.commons.math3.ode.sampling.StepInterpolator;
 import org.apache.commons.math3.util.FastMath;
 
@@ -148,8 +148,11 @@ public class EventState {
 
     /** Reinitialize the beginning of the step.
      * @param interpolator valid for the current step
+     * @exception MaxCountExceededException if the interpolator throws one because
+     * the number of functions evaluations is exceeded
      */
-    public void reinitializeBegin(final StepInterpolator interpolator) {
+    public void reinitializeBegin(final StepInterpolator interpolator)
+        throws MaxCountExceededException {
 
         t0 = interpolator.getPreviousTime();
         interpolator.setInterpolatedTime(t0);
@@ -182,11 +185,14 @@ public class EventState {
      * @param interpolator step interpolator for the proposed step
      * @return true if the event handler triggers an event before
      * the end of the proposed step
-     * @exception ConvergenceException if an event cannot be located
+     * @exception MaxCountExceededException if the interpolator throws one because
+     * the number of functions evaluations is exceeded
+     * @exception NoBracketingException if the event cannot be bracketed
      */
     public boolean evaluateStep(final StepInterpolator interpolator)
-        throws ConvergenceException {
+        throws MaxCountExceededException, NoBracketingException {
 
+        try {
             forward = interpolator.isForward();
             final double t1 = interpolator.getCurrentTime();
             final double dt = t1 - t0;
@@ -198,9 +204,13 @@ public class EventState {
             final double h = dt / n;
 
             final UnivariateFunction f = new UnivariateFunction() {
-                public double value(final double t) {
-                    interpolator.setInterpolatedTime(t);
-                    return handler.g(t, interpolator.getInterpolatedState());
+                public double value(final double t) throws LocalMaxCountExceededException {
+                    try {
+                        interpolator.setInterpolatedTime(t);
+                        return handler.g(t, interpolator.getInterpolatedState());
+                    } catch (MaxCountExceededException mcee) {
+                        throw new LocalMaxCountExceededException(mcee);
+                    }
                 }
             };
 
@@ -275,6 +285,10 @@ public class EventState {
             pendingEventTime = Double.NaN;
             return false;
 
+        } catch (LocalMaxCountExceededException lmcee) {
+            throw lmcee.getException();
+        }
+
     }
 
     /** Get the occurrence time of the event triggered in the current step.
@@ -341,4 +355,29 @@ public class EventState {
 
     }
 
+    /** Local wrapper to propagate exceptions. */
+    private static class LocalMaxCountExceededException extends RuntimeException {
+
+        /** Serializable UID. */
+        private static final long serialVersionUID = 20120901L;
+
+        /** Wrapped exception. */
+        private final MaxCountExceededException wrapped;
+
+        /** Simple constructor.
+         * @param exception exception to wrap
+         */
+        public LocalMaxCountExceededException(final MaxCountExceededException exception) {
+            wrapped = exception;
+        }
+
+        /** Get the wrapped exception.
+         * @return wrapped exception
+         */
+        public MaxCountExceededException getException() {
+            return wrapped;
+        }
+
+    }
+
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsBashforthIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsBashforthIntegrator.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsBashforthIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsBashforthIntegrator.java Sun Sep  2 14:21:00 2012
@@ -17,8 +17,10 @@
 
 package org.apache.commons.math3.ode.nonstiff;
 
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathIllegalStateException;
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+import org.apache.commons.math3.exception.NoBracketingException;
+import org.apache.commons.math3.exception.NumberIsTooSmallException;
 import org.apache.commons.math3.linear.Array2DRowRealMatrix;
 import org.apache.commons.math3.ode.ExpandableStatefulODE;
 import org.apache.commons.math3.ode.sampling.NordsieckStepInterpolator;
@@ -153,13 +155,13 @@ public class AdamsBashforthIntegrator ex
      * be smaller than this
      * @param scalAbsoluteTolerance allowed absolute error
      * @param scalRelativeTolerance allowed relative error
-     * @exception IllegalArgumentException if order is 1 or less
+     * @exception NumberIsTooSmallException if order is 1 or less
      */
     public AdamsBashforthIntegrator(final int nSteps,
                                     final double minStep, final double maxStep,
                                     final double scalAbsoluteTolerance,
                                     final double scalRelativeTolerance)
-        throws IllegalArgumentException {
+        throws NumberIsTooSmallException {
         super(METHOD_NAME, nSteps, nSteps, minStep, maxStep,
               scalAbsoluteTolerance, scalRelativeTolerance);
     }
@@ -189,7 +191,8 @@ public class AdamsBashforthIntegrator ex
     /** {@inheritDoc} */
     @Override
     public void integrate(final ExpandableStatefulODE equations, final double t)
-        throws MathIllegalStateException, MathIllegalArgumentException {
+        throws NumberIsTooSmallException, DimensionMismatchException,
+               MaxCountExceededException, NoBracketingException {
 
         sanityChecks(equations, t);
         setEquations(equations);

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsIntegrator.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsIntegrator.java Sun Sep  2 14:21:00 2012
@@ -17,8 +17,10 @@
 
 package org.apache.commons.math3.ode.nonstiff;
 
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathIllegalStateException;
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+import org.apache.commons.math3.exception.NoBracketingException;
+import org.apache.commons.math3.exception.NumberIsTooSmallException;
 import org.apache.commons.math3.linear.Array2DRowRealMatrix;
 import org.apache.commons.math3.ode.ExpandableStatefulODE;
 import org.apache.commons.math3.ode.MultistepIntegrator;
@@ -47,13 +49,13 @@ public abstract class AdamsIntegrator ex
      * be smaller than this
      * @param scalAbsoluteTolerance allowed absolute error
      * @param scalRelativeTolerance allowed relative error
-     * @exception IllegalArgumentException if order is 1 or less
+     * @exception NumberIsTooSmallException if order is 1 or less
      */
     public AdamsIntegrator(final String name, final int nSteps, final int order,
                            final double minStep, final double maxStep,
                            final double scalAbsoluteTolerance,
                            final double scalRelativeTolerance)
-        throws IllegalArgumentException {
+        throws NumberIsTooSmallException {
         super(name, nSteps, order, minStep, maxStep,
               scalAbsoluteTolerance, scalRelativeTolerance);
         transformer = AdamsNordsieckTransformer.getInstance(nSteps);
@@ -87,7 +89,8 @@ public abstract class AdamsIntegrator ex
     /** {@inheritDoc} */
     @Override
     public abstract void integrate(final ExpandableStatefulODE equations, final double t)
-        throws MathIllegalStateException, MathIllegalArgumentException;
+        throws NumberIsTooSmallException, DimensionMismatchException,
+               MaxCountExceededException, NoBracketingException;
 
     /** {@inheritDoc} */
     @Override

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsMoultonIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsMoultonIntegrator.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsMoultonIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdamsMoultonIntegrator.java Sun Sep  2 14:21:00 2012
@@ -19,8 +19,10 @@ package org.apache.commons.math3.ode.non
 
 import java.util.Arrays;
 
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathIllegalStateException;
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+import org.apache.commons.math3.exception.NoBracketingException;
+import org.apache.commons.math3.exception.NumberIsTooSmallException;
 import org.apache.commons.math3.linear.Array2DRowRealMatrix;
 import org.apache.commons.math3.linear.RealMatrixPreservingVisitor;
 import org.apache.commons.math3.ode.ExpandableStatefulODE;
@@ -169,13 +171,13 @@ public class AdamsMoultonIntegrator exte
      * be smaller than this
      * @param scalAbsoluteTolerance allowed absolute error
      * @param scalRelativeTolerance allowed relative error
-     * @exception IllegalArgumentException if order is 1 or less
+     * @exception NumberIsTooSmallException if order is 1 or less
      */
     public AdamsMoultonIntegrator(final int nSteps,
                                   final double minStep, final double maxStep,
                                   final double scalAbsoluteTolerance,
                                   final double scalRelativeTolerance)
-        throws IllegalArgumentException {
+        throws NumberIsTooSmallException {
         super(METHOD_NAME, nSteps, nSteps + 1, minStep, maxStep,
               scalAbsoluteTolerance, scalRelativeTolerance);
     }
@@ -206,7 +208,8 @@ public class AdamsMoultonIntegrator exte
     /** {@inheritDoc} */
     @Override
     public void integrate(final ExpandableStatefulODE equations,final double t)
-        throws MathIllegalStateException, MathIllegalArgumentException {
+        throws NumberIsTooSmallException, DimensionMismatchException,
+               MaxCountExceededException, NoBracketingException {
 
         sanityChecks(equations, t);
         setEquations(equations);

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdaptiveStepsizeIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdaptiveStepsizeIntegrator.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdaptiveStepsizeIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/AdaptiveStepsizeIntegrator.java Sun Sep  2 14:21:00 2012
@@ -18,8 +18,8 @@
 package org.apache.commons.math3.ode.nonstiff;
 
 import org.apache.commons.math3.exception.DimensionMismatchException;
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathIllegalStateException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+import org.apache.commons.math3.exception.NoBracketingException;
 import org.apache.commons.math3.exception.NumberIsTooSmallException;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
 import org.apache.commons.math3.ode.AbstractIntegrator;
@@ -242,10 +242,13 @@ public abstract class AdaptiveStepsizeIn
    * @param y1 work array for a state vector
    * @param yDot1 work array for the first time derivative of y1
    * @return first integration step
+   * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+   * @exception DimensionMismatchException if arrays dimensions do not match equations settings
    */
   public double initializeStep(final boolean forward, final int order, final double[] scale,
                                final double t0, final double[] y0, final double[] yDot0,
-                               final double[] y1, final double[] yDot1) {
+                               final double[] y1, final double[] yDot1)
+      throws MaxCountExceededException, DimensionMismatchException {
 
     if (initialStep > 0) {
       // use the user provided value
@@ -341,7 +344,8 @@ public abstract class AdaptiveStepsizeIn
   /** {@inheritDoc} */
   @Override
   public abstract void integrate (ExpandableStatefulODE equations, double t)
-    throws MathIllegalStateException, MathIllegalArgumentException;
+      throws NumberIsTooSmallException, DimensionMismatchException,
+             MaxCountExceededException, NoBracketingException;
 
   /** {@inheritDoc} */
   @Override

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolator.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolator.java Sun Sep  2 14:21:00 2012
@@ -21,6 +21,9 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MathInternalError;
+import org.apache.commons.math3.exception.MaxCountExceededException;
 import org.apache.commons.math3.ode.AbstractIntegrator;
 import org.apache.commons.math3.ode.EquationsMapper;
 import org.apache.commons.math3.ode.sampling.StepInterpolator;
@@ -313,7 +316,8 @@ class DormandPrince853StepInterpolator
   /** {@inheritDoc} */
   @Override
   protected void computeInterpolatedStateAndDerivatives(final double theta,
-                                          final double oneMinusThetaH) {
+                                          final double oneMinusThetaH)
+      throws MaxCountExceededException {
 
     if (! vectorsInitialized) {
 
@@ -402,45 +406,49 @@ class DormandPrince853StepInterpolator
 
   /** {@inheritDoc} */
   @Override
-  protected void doFinalize() {
+  protected void doFinalize() throws MaxCountExceededException {
 
-    if (currentState == null) {
-      // we are finalizing an uninitialized instance
-      return;
-    }
+      try {
+          if (currentState == null) {
+              // we are finalizing an uninitialized instance
+              return;
+          }
 
-    double s;
-    final double[] yTmp = new double[currentState.length];
-    final double pT = getGlobalPreviousTime();
-
-    // k14
-    for (int j = 0; j < currentState.length; ++j) {
-      s = K14_01 * yDotK[0][j]  + K14_06 * yDotK[5][j]  + K14_07 * yDotK[6][j] +
-          K14_08 * yDotK[7][j]  + K14_09 * yDotK[8][j]  + K14_10 * yDotK[9][j] +
-          K14_11 * yDotK[10][j] + K14_12 * yDotK[11][j] + K14_13 * yDotK[12][j];
-      yTmp[j] = currentState[j] + h * s;
-    }
-    integrator.computeDerivatives(pT + C14 * h, yTmp, yDotKLast[0]);
+          double s;
+          final double[] yTmp = new double[currentState.length];
+          final double pT = getGlobalPreviousTime();
+
+          // k14
+          for (int j = 0; j < currentState.length; ++j) {
+              s = K14_01 * yDotK[0][j]  + K14_06 * yDotK[5][j]  + K14_07 * yDotK[6][j] +
+                      K14_08 * yDotK[7][j]  + K14_09 * yDotK[8][j]  + K14_10 * yDotK[9][j] +
+                      K14_11 * yDotK[10][j] + K14_12 * yDotK[11][j] + K14_13 * yDotK[12][j];
+              yTmp[j] = currentState[j] + h * s;
+          }
+          integrator.computeDerivatives(pT + C14 * h, yTmp, yDotKLast[0]);
 
-    // k15
-    for (int j = 0; j < currentState.length; ++j) {
-     s = K15_01 * yDotK[0][j]  + K15_06 * yDotK[5][j]  + K15_07 * yDotK[6][j] +
-         K15_08 * yDotK[7][j]  + K15_09 * yDotK[8][j]  + K15_10 * yDotK[9][j] +
-         K15_11 * yDotK[10][j] + K15_12 * yDotK[11][j] + K15_13 * yDotK[12][j] +
-         K15_14 * yDotKLast[0][j];
-     yTmp[j] = currentState[j] + h * s;
-    }
-    integrator.computeDerivatives(pT + C15 * h, yTmp, yDotKLast[1]);
+          // k15
+          for (int j = 0; j < currentState.length; ++j) {
+              s = K15_01 * yDotK[0][j]  + K15_06 * yDotK[5][j]  + K15_07 * yDotK[6][j] +
+                      K15_08 * yDotK[7][j]  + K15_09 * yDotK[8][j]  + K15_10 * yDotK[9][j] +
+                      K15_11 * yDotK[10][j] + K15_12 * yDotK[11][j] + K15_13 * yDotK[12][j] +
+                      K15_14 * yDotKLast[0][j];
+              yTmp[j] = currentState[j] + h * s;
+          }
+          integrator.computeDerivatives(pT + C15 * h, yTmp, yDotKLast[1]);
 
-    // k16
-    for (int j = 0; j < currentState.length; ++j) {
-      s = K16_01 * yDotK[0][j]  + K16_06 * yDotK[5][j]  + K16_07 * yDotK[6][j] +
-          K16_08 * yDotK[7][j]  + K16_09 * yDotK[8][j]  + K16_10 * yDotK[9][j] +
-          K16_11 * yDotK[10][j] + K16_12 * yDotK[11][j] + K16_13 * yDotK[12][j] +
-          K16_14 * yDotKLast[0][j] +  K16_15 * yDotKLast[1][j];
-      yTmp[j] = currentState[j] + h * s;
-    }
-    integrator.computeDerivatives(pT + C16 * h, yTmp, yDotKLast[2]);
+          // k16
+          for (int j = 0; j < currentState.length; ++j) {
+              s = K16_01 * yDotK[0][j]  + K16_06 * yDotK[5][j]  + K16_07 * yDotK[6][j] +
+                      K16_08 * yDotK[7][j]  + K16_09 * yDotK[8][j]  + K16_10 * yDotK[9][j] +
+                      K16_11 * yDotK[10][j] + K16_12 * yDotK[11][j] + K16_13 * yDotK[12][j] +
+                      K16_14 * yDotKLast[0][j] +  K16_15 * yDotKLast[1][j];
+              yTmp[j] = currentState[j] + h * s;
+          }
+          integrator.computeDerivatives(pT + C16 * h, yTmp, yDotKLast[2]);
+      } catch (DimensionMismatchException dme) {
+          throw new MathInternalError(dme);
+      }
 
   }
 
@@ -449,8 +457,14 @@ class DormandPrince853StepInterpolator
   public void writeExternal(final ObjectOutput out)
     throws IOException {
 
-    // save the local attributes
-    finalizeStep();
+    try {
+        // save the local attributes
+        finalizeStep();
+    } catch (MaxCountExceededException mcee) {
+        final IOException ioe = new IOException(mcee.getLocalizedMessage());
+        ioe.initCause(mcee);
+        throw ioe;
+    }
 
     final int dimension = (currentState == null) ? -1 : currentState.length;
     out.writeInt(dimension);

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java Sun Sep  2 14:21:00 2012
@@ -17,8 +17,10 @@
 
 package org.apache.commons.math3.ode.nonstiff;
 
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathIllegalStateException;
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+import org.apache.commons.math3.exception.NoBracketingException;
+import org.apache.commons.math3.exception.NumberIsTooSmallException;
 import org.apache.commons.math3.ode.ExpandableStatefulODE;
 import org.apache.commons.math3.util.FastMath;
 
@@ -189,7 +191,8 @@ public abstract class EmbeddedRungeKutta
   /** {@inheritDoc} */
   @Override
   public void integrate(final ExpandableStatefulODE equations, final double t)
-      throws MathIllegalStateException, MathIllegalArgumentException {
+      throws NumberIsTooSmallException, DimensionMismatchException,
+             MaxCountExceededException, NoBracketingException {
 
     sanityChecks(equations, t);
     setEquations(equations);

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/GraggBulirschStoerIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/GraggBulirschStoerIntegrator.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/GraggBulirschStoerIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/GraggBulirschStoerIntegrator.java Sun Sep  2 14:21:00 2012
@@ -18,8 +18,10 @@
 package org.apache.commons.math3.ode.nonstiff;
 
 import org.apache.commons.math3.analysis.solvers.UnivariateSolver;
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathIllegalStateException;
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+import org.apache.commons.math3.exception.NoBracketingException;
+import org.apache.commons.math3.exception.NumberIsTooSmallException;
 import org.apache.commons.math3.ode.ExpandableStatefulODE;
 import org.apache.commons.math3.ode.events.EventHandler;
 import org.apache.commons.math3.ode.sampling.AbstractStepInterpolator;
@@ -450,11 +452,14 @@ public class GraggBulirschStoerIntegrato
    * @param yTmp placeholder for one state vector
    * @return true if computation was done properly,
    *         false if stability check failed before end of computation
+   * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+   * @exception DimensionMismatchException if arrays dimensions do not match equations settings
    */
   private boolean tryStep(final double t0, final double[] y0, final double step, final int k,
                           final double[] scale, final double[][] f,
                           final double[] yMiddle, final double[] yEnd,
-                          final double[] yTmp) {
+                          final double[] yTmp)
+      throws MaxCountExceededException, DimensionMismatchException {
 
     final int    n        = sequence[k];
     final double subStep  = step / n;
@@ -542,7 +547,8 @@ public class GraggBulirschStoerIntegrato
   /** {@inheritDoc} */
   @Override
   public void integrate(final ExpandableStatefulODE equations, final double t)
-      throws MathIllegalStateException, MathIllegalArgumentException {
+      throws NumberIsTooSmallException, DimensionMismatchException,
+             MaxCountExceededException, NoBracketingException {
 
     sanityChecks(equations, t);
     setEquations(equations);

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaIntegrator.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaIntegrator.java Sun Sep  2 14:21:00 2012
@@ -18,8 +18,10 @@
 package org.apache.commons.math3.ode.nonstiff;
 
 
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathIllegalStateException;
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+import org.apache.commons.math3.exception.NoBracketingException;
+import org.apache.commons.math3.exception.NumberIsTooSmallException;
 import org.apache.commons.math3.ode.AbstractIntegrator;
 import org.apache.commons.math3.ode.ExpandableStatefulODE;
 import org.apache.commons.math3.util.FastMath;
@@ -91,7 +93,8 @@ public abstract class RungeKuttaIntegrat
   /** {@inheritDoc} */
   @Override
   public void integrate(final ExpandableStatefulODE equations, final double t)
-      throws MathIllegalStateException, MathIllegalArgumentException {
+      throws NumberIsTooSmallException, DimensionMismatchException,
+             MaxCountExceededException, NoBracketingException {
 
     sanityChecks(equations, t);
     setEquations(equations);



Mime
View raw message