You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2012/09/02 16:21:02 UTC
svn commit: r1379975 [2/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...
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/AbstractStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/AbstractStepInterpolator.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/AbstractStepInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/AbstractStepInterpolator.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.EquationsMapper;
/** This abstract class represents an interpolator over the last step
@@ -262,7 +265,7 @@ public abstract class AbstractStepInterp
}
/** {@inheritDoc} */
- public StepInterpolator copy() {
+ public StepInterpolator copy() throws MaxCountExceededException {
// finalize the step before performing copy
finalizeStep();
@@ -391,13 +394,17 @@ public abstract class AbstractStepInterp
* (theta is zero at the previous time step and one at the current time step)
* @param oneMinusThetaH time gap between the interpolated time and
* the current time
+ * @exception MaxCountExceededException if the number of functions evaluations is exceeded
*/
protected abstract void computeInterpolatedStateAndDerivatives(double theta,
- double oneMinusThetaH);
+ double oneMinusThetaH)
+ throws MaxCountExceededException;
/** Lazy evaluation of complete interpolated state.
+ * @exception MaxCountExceededException if the number of functions evaluations is exceeded
*/
- private void evaluateCompleteInterpolatedState() {
+ private void evaluateCompleteInterpolatedState()
+ throws MaxCountExceededException {
// lazy evaluation of the state
if (dirtyState) {
final double oneMinusThetaH = globalCurrentTime - interpolatedTime;
@@ -408,34 +415,54 @@ public abstract class AbstractStepInterp
}
/** {@inheritDoc} */
- public double[] getInterpolatedState() {
+ public double[] getInterpolatedState() throws MaxCountExceededException {
evaluateCompleteInterpolatedState();
- primaryMapper.extractEquationData(interpolatedState,
- interpolatedPrimaryState);
+ try {
+ primaryMapper.extractEquationData(interpolatedState,
+ interpolatedPrimaryState);
+ } catch (DimensionMismatchException dme) {
+ // this should never happen
+ throw new MathInternalError(dme);
+ }
return interpolatedPrimaryState;
}
/** {@inheritDoc} */
- public double[] getInterpolatedDerivatives() {
+ public double[] getInterpolatedDerivatives() throws MaxCountExceededException {
evaluateCompleteInterpolatedState();
- primaryMapper.extractEquationData(interpolatedDerivatives,
- interpolatedPrimaryDerivatives);
+ try {
+ primaryMapper.extractEquationData(interpolatedDerivatives,
+ interpolatedPrimaryDerivatives);
+ } catch (DimensionMismatchException dme) {
+ // this should never happen
+ throw new MathInternalError(dme);
+ }
return interpolatedPrimaryDerivatives;
}
/** {@inheritDoc} */
- public double[] getInterpolatedSecondaryState(final int index) {
+ public double[] getInterpolatedSecondaryState(final int index) throws MaxCountExceededException {
evaluateCompleteInterpolatedState();
- secondaryMappers[index].extractEquationData(interpolatedState,
- interpolatedSecondaryState[index]);
+ try {
+ secondaryMappers[index].extractEquationData(interpolatedState,
+ interpolatedSecondaryState[index]);
+ } catch (DimensionMismatchException dme) {
+ // this should never happen
+ throw new MathInternalError(dme);
+ }
return interpolatedSecondaryState[index];
}
/** {@inheritDoc} */
- public double[] getInterpolatedSecondaryDerivatives(final int index) {
+ public double[] getInterpolatedSecondaryDerivatives(final int index) throws MaxCountExceededException {
evaluateCompleteInterpolatedState();
- secondaryMappers[index].extractEquationData(interpolatedDerivatives,
- interpolatedSecondaryDerivatives[index]);
+ try {
+ secondaryMappers[index].extractEquationData(interpolatedDerivatives,
+ interpolatedSecondaryDerivatives[index]);
+ } catch (DimensionMismatchException dme) {
+ // this should never happen
+ throw new MathInternalError(dme);
+ }
return interpolatedSecondaryDerivatives[index];
}
@@ -477,8 +504,10 @@ public abstract class AbstractStepInterp
* Therefore, subclasses are not allowed not reimplement it, they
* should rather reimplement <code>doFinalize</code>.</p>
+ * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+
*/
- public final void finalizeStep() {
+ public final void finalizeStep() throws MaxCountExceededException {
if (! finalized) {
doFinalize();
finalized = true;
@@ -488,8 +517,9 @@ public abstract class AbstractStepInterp
/**
* Really finalize the step.
* The default implementation of this method does nothing.
+ * @exception MaxCountExceededException if the number of functions evaluations is exceeded
*/
- protected void doFinalize() {
+ protected void doFinalize() throws MaxCountExceededException {
}
/** {@inheritDoc} */
@@ -537,8 +567,14 @@ public abstract class AbstractStepInterp
// we do not store the interpolated state,
// it will be recomputed as needed after reading
- // finalize the step (and don't bother saving the now true flag)
- finalizeStep();
+ try {
+ // finalize the step (and don't bother saving the now true flag)
+ finalizeStep();
+ } catch (MaxCountExceededException mcee) {
+ final IOException ioe = new IOException(mcee.getLocalizedMessage());
+ ioe.initCause(mcee);
+ throw ioe;
+ }
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/NordsieckStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/NordsieckStepInterpolator.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/NordsieckStepInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/NordsieckStepInterpolator.java Sun Sep 2 14:21:00 2012
@@ -22,6 +22,7 @@ import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Arrays;
+import org.apache.commons.math3.exception.MaxCountExceededException;
import org.apache.commons.math3.linear.Array2DRowRealMatrix;
import org.apache.commons.math3.ode.EquationsMapper;
import org.apache.commons.math3.util.FastMath;
@@ -175,8 +176,9 @@ public class NordsieckStepInterpolator e
* to be preserved across several calls.</p>
* @return state vector at time {@link #getInterpolatedTime}
* @see #getInterpolatedDerivatives()
+ * @exception MaxCountExceededException if the number of functions evaluations is exceeded
*/
- public double[] getInterpolatedStateVariation() {
+ public double[] getInterpolatedStateVariation() throws MaxCountExceededException {
// compute and ignore interpolated state
// to make sure state variation is computed as a side effect
getInterpolatedState();
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepHandler.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepHandler.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepHandler.java Sun Sep 2 14:21:00 2012
@@ -17,6 +17,8 @@
package org.apache.commons.math3.ode.sampling;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+
/**
* This interface represents a handler that should be called after
@@ -65,7 +67,10 @@ public interface StepHandler {
* Keeping only a reference to the interpolator and reusing it will
* result in unpredictable behavior (potentially crashing the application).
* @param isLast true if the step is the last one
+ * @exception MaxCountExceededException if the interpolator throws one because
+ * the number of functions evaluations is exceeded
*/
- void handleStep(StepInterpolator interpolator, boolean isLast);
+ void handleStep(StepInterpolator interpolator, boolean isLast)
+ throws MaxCountExceededException;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepInterpolator.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepInterpolator.java Sun Sep 2 14:21:00 2012
@@ -19,6 +19,8 @@ package org.apache.commons.math3.ode.sam
import java.io.Externalizable;
+import org.apache.commons.math3.exception.MaxCountExceededException;
+
/** This interface represents an interpolator over the last step
* during an ODE integration.
*
@@ -87,8 +89,9 @@ public interface StepInterpolator extend
* to be preserved across several calls.</p>
* @return state vector at time {@link #getInterpolatedTime}
* @see #getInterpolatedDerivatives()
+ * @exception MaxCountExceededException if the number of functions evaluations is exceeded
*/
- double[] getInterpolatedState();
+ double[] getInterpolatedState() throws MaxCountExceededException;
/**
* Get the derivatives of the state vector of the interpolated point.
@@ -98,8 +101,9 @@ public interface StepInterpolator extend
* @return derivatives of the state vector at time {@link #getInterpolatedTime}
* @see #getInterpolatedState()
* @since 2.0
+ * @exception MaxCountExceededException if the number of functions evaluations is exceeded
*/
- double[] getInterpolatedDerivatives();
+ double[] getInterpolatedDerivatives() throws MaxCountExceededException;
/** Get the interpolated secondary state corresponding to the secondary equations.
* <p>The returned vector is a reference to a reused array, so
@@ -115,8 +119,9 @@ public interface StepInterpolator extend
* @see #getInterpolatedSecondaryDerivatives(int)
* @see #setInterpolatedTime(double)
* @since 3.0
+ * @exception MaxCountExceededException if the number of functions evaluations is exceeded
*/
- double[] getInterpolatedSecondaryState(int index);
+ double[] getInterpolatedSecondaryState(int index) throws MaxCountExceededException;
/** Get the interpolated secondary derivatives corresponding to the secondary equations.
* <p>The returned vector is a reference to a reused array, so
@@ -132,8 +137,9 @@ public interface StepInterpolator extend
* @see #getInterpolatedSecondaryState(int)
* @see #setInterpolatedTime(double)
* @since 3.0
+ * @exception MaxCountExceededException if the number of functions evaluations is exceeded
*/
- double[] getInterpolatedSecondaryDerivatives(int index);
+ double[] getInterpolatedSecondaryDerivatives(int index) throws MaxCountExceededException;
/** Check if the natural integration direction is forward.
* <p>This method provides the integration direction as specified by
@@ -152,7 +158,9 @@ public interface StepInterpolator extend
* interpolated time without any side effect.</p>
* @return a deep copy of the instance, which can be used independently.
* @see #setInterpolatedTime(double)
+ * @exception MaxCountExceededException if the number of functions evaluations is exceeded
+ * during step finalization
*/
- StepInterpolator copy();
+ StepInterpolator copy() throws MaxCountExceededException;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepNormalizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepNormalizer.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepNormalizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/StepNormalizer.java Sun Sep 2 14:21:00 2012
@@ -17,6 +17,7 @@
package org.apache.commons.math3.ode.sampling;
+import org.apache.commons.math3.exception.MaxCountExceededException;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.util.Precision;
@@ -196,8 +197,11 @@ public class StepNormalizer implements S
* should build a local copy using the clone method and store this
* copy.
* @param isLast true if the step is the last one
+ * @exception MaxCountExceededException if the interpolator throws one because
+ * the number of functions evaluations is exceeded
*/
- public void handleStep(final StepInterpolator interpolator, final boolean isLast) {
+ public void handleStep(final StepInterpolator interpolator, final boolean isLast)
+ throws MaxCountExceededException {
// The first time, update the last state with the start information.
if (lastState == null) {
firstTime = interpolator.getPreviousTime();
@@ -282,8 +286,11 @@ public class StepNormalizer implements S
* @param interpolator interpolator for the last accepted step, to use to
* get the interpolated information
* @param t the time for which to store the interpolated information
+ * @exception MaxCountExceededException if the interpolator throws one because
+ * the number of functions evaluations is exceeded
*/
- private void storeStep(StepInterpolator interpolator, double t) {
+ private void storeStep(StepInterpolator interpolator, double t)
+ throws MaxCountExceededException {
lastTime = t;
interpolator.setInterpolatedTime(lastTime);
System.arraycopy(interpolator.getInterpolatedState(), 0,
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/ContinuousOutputModelTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/ContinuousOutputModelTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/ContinuousOutputModelTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/ContinuousOutputModelTest.java Sun Sep 2 14:21:00 2012
@@ -19,6 +19,11 @@ package org.apache.commons.math3.ode;
import java.util.Random;
+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.NoBracketingException;
+import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.ode.nonstiff.DormandPrince54Integrator;
import org.apache.commons.math3.ode.nonstiff.DormandPrince853Integrator;
import org.apache.commons.math3.ode.sampling.DummyStepInterpolator;
@@ -37,7 +42,7 @@ public class ContinuousOutputModelTest {
}
@Test
- public void testBoundaries() {
+ public void testBoundaries() throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
integ.addStepHandler(new ContinuousOutputModel());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
@@ -49,7 +54,7 @@ public class ContinuousOutputModelTest {
}
@Test
- public void testRandomAccess() {
+ public void testRandomAccess() throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
ContinuousOutputModel cm = new ContinuousOutputModel();
integ.addStepHandler(cm);
@@ -78,7 +83,7 @@ public class ContinuousOutputModelTest {
}
@Test
- public void testModelsMerging() {
+ public void testModelsMerging() throws MaxCountExceededException, MathIllegalArgumentException {
// theoretical solution: y[0] = cos(t), y[1] = sin(t)
FirstOrderDifferentialEquations problem =
@@ -128,7 +133,7 @@ public class ContinuousOutputModelTest {
}
@Test
- public void testErrorConditions() {
+ public void testErrorConditions() throws MaxCountExceededException, MathIllegalArgumentException {
ContinuousOutputModel cm = new ContinuousOutputModel();
cm.handleStep(buildInterpolator(0, new double[] { 0.0, 1.0, -2.0 }, 1), true);
@@ -148,7 +153,8 @@ public class ContinuousOutputModelTest {
}
private boolean checkAppendError(ContinuousOutputModel cm,
- double t0, double[] y0, double t1) {
+ double t0, double[] y0, double t1)
+ throws MaxCountExceededException, MathIllegalArgumentException {
try {
ContinuousOutputModel otherCm = new ContinuousOutputModel();
otherCm.handleStep(buildInterpolator(t0, y0, t1), true);
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/FirstOrderConverterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/FirstOrderConverterTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/FirstOrderConverterTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/FirstOrderConverterTest.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.ode.nonstiff.ClassicalRungeKuttaIntegrator;
import org.apache.commons.math3.util.FastMath;
import org.junit.Assert;
@@ -37,7 +39,8 @@ public class FirstOrderConverterTest {
}
@Test
- public void testDecreasingSteps() {
+ public void testDecreasingSteps()
+ throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
double previousError = Double.NaN;
for (int i = 0; i < 10; ++i) {
@@ -54,14 +57,16 @@ public class FirstOrderConverterTest {
}
@Test
- public void testSmallStep() {
+ public void testSmallStep()
+ throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
double error = integrateWithSpecifiedStep(4.0, 0.0, 1.0, 1.0e-4)
- FastMath.sin(4.0);
Assert.assertTrue(FastMath.abs(error) < 1.0e-10);
}
@Test
- public void testBigStep() {
+ public void testBigStep()
+ throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
double error = integrateWithSpecifiedStep(4.0, 0.0, 1.0, 0.5)
- FastMath.sin(4.0);
Assert.assertTrue(FastMath.abs(error) > 0.1);
@@ -94,8 +99,7 @@ public class FirstOrderConverterTest {
private double integrateWithSpecifiedStep(double omega,
double t0, double t,
- double step)
- throws MathIllegalStateException, MathIllegalArgumentException {
+ double step) throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
double[] y0 = new double[2];
y0[0] = FastMath.sin(omega * t0);
y0[1] = omega * FastMath.cos(omega * t0);
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/JacobianMatricesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/JacobianMatricesTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/JacobianMatricesTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/JacobianMatricesTest.java Sun Sep 2 14:21:00 2012
@@ -17,6 +17,11 @@
package org.apache.commons.math3.ode;
+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.JacobianMatrices.MismatchedEquations;
import org.apache.commons.math3.ode.nonstiff.DormandPrince54Integrator;
import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
import org.apache.commons.math3.util.FastMath;
@@ -26,8 +31,10 @@ import org.junit.Test;
public class JacobianMatricesTest {
@Test
- public void testLowAccuracyExternalDifferentiation() {
- // this test does not really test FirstOrderIntegratorWithJacobians,
+ public void testLowAccuracyExternalDifferentiation()
+ throws NumberIsTooSmallException, DimensionMismatchException,
+ MaxCountExceededException, NoBracketingException {
+ // this test does not really test JacobianMatrices,
// it only shows that WITHOUT this class, attempting to recover
// the jacobians from external differentiation on simple integration
// results with low accuracy gives very poor results. In fact,
@@ -57,7 +64,9 @@ public class JacobianMatricesTest {
}
@Test
- public void testHighAccuracyExternalDifferentiation() {
+ public void testHighAccuracyExternalDifferentiation()
+ throws NumberIsTooSmallException, DimensionMismatchException,
+ MaxCountExceededException, NoBracketingException, UnknownParameterException {
FirstOrderIntegrator 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 hP = 1.0e-12;
@@ -84,7 +93,10 @@ public class JacobianMatricesTest {
}
@Test
- public void testInternalDifferentiation() {
+ public void testInternalDifferentiation()
+ throws NumberIsTooSmallException, DimensionMismatchException,
+ MaxCountExceededException, NoBracketingException,
+ UnknownParameterException, MismatchedEquations {
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;
@@ -126,7 +138,10 @@ public class JacobianMatricesTest {
}
@Test
- public void testAnalyticalDifferentiation() {
+ public void testAnalyticalDifferentiation()
+ throws MaxCountExceededException, DimensionMismatchException,
+ NumberIsTooSmallException, NoBracketingException,
+ UnknownParameterException, MismatchedEquations {
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();
@@ -163,7 +178,10 @@ public class JacobianMatricesTest {
}
@Test
- public void testFinalResult() {
+ public void testFinalResult()
+ throws MaxCountExceededException, DimensionMismatchException,
+ NumberIsTooSmallException, NoBracketingException,
+ UnknownParameterException, MismatchedEquations {
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 });
@@ -216,28 +234,30 @@ public class JacobianMatricesTest {
}
@Test
- public void testParameterizable() {
+ public void testParameterizable()
+ throws MaxCountExceededException, DimensionMismatchException,
+ NumberIsTooSmallException, NoBracketingException,
+ UnknownParameterException, MismatchedEquations {
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);
-// pcircle.setParameter(ParameterizedCircle.CX, 1.0);
-// pcircle.setParameter(ParameterizedCircle.CY, 1.0);
-// pcircle.setParameter(ParameterizedCircle.OMEGA, 0.1);
double hP = 1.0e-12;
double hY = 1.0e-12;
JacobianMatrices jacob = new JacobianMatrices(pcircle, new double[] { hY, hY },
- Circle.CX, Circle.OMEGA);
- jacob.addParameterJacobianProvider(pcircle);
+ ParameterizedCircle.CX, ParameterizedCircle.CY,
+ ParameterizedCircle.OMEGA);
jacob.setParameterizedODE(pcircle);
- jacob.setParameterStep(Circle.OMEGA, hP);
+ jacob.setParameterStep(ParameterizedCircle.CX, hP);
+ jacob.setParameterStep(ParameterizedCircle.CY, hP);
+ jacob.setParameterStep(ParameterizedCircle.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));
+ jacob.setInitialParameterJacobian(ParameterizedCircle.CX, pcircle.exactDyDcx(0));
+ jacob.setInitialParameterJacobian(ParameterizedCircle.CY, pcircle.exactDyDcy(0));
+ jacob.setInitialParameterJacobian(ParameterizedCircle.OMEGA, pcircle.exactDyDom(0));
ExpandableStatefulODE efode = new ExpandableStatefulODE(pcircle);
efode.setTime(0);
@@ -262,13 +282,13 @@ public class JacobianMatricesTest {
}
double[] dydp0 = new double[2];
- jacob.getCurrentParameterJacobian(Circle.CX, dydp0);
+ jacob.getCurrentParameterJacobian(ParameterizedCircle.CX, dydp0);
for (int i = 0; i < dydp0.length; ++i) {
Assert.assertEquals(pcircle.exactDyDcx(t)[i], dydp0[i], 5.0e-4);
}
double[] dydp1 = new double[2];
- jacob.getCurrentParameterJacobian(Circle.OMEGA, dydp1);
+ jacob.getCurrentParameterJacobian(ParameterizedCircle.OMEGA, dydp1);
for (int i = 0; i < dydp1.length; ++i) {
Assert.assertEquals(pcircle.exactDyDom(t)[i], dydp1[i], 1.0e-2);
}
@@ -308,9 +328,13 @@ public class JacobianMatricesTest {
public void computeParameterJacobian(double t, double[] y, double[] yDot,
String paramName, double[] dFdP) {
- complainIfNotSupported(paramName);
- dFdP[0] = -y[0];
- dFdP[1] = y[0];
+ if (isSupported(paramName)) {
+ dFdP[0] = -y[0];
+ dFdP[1] = y[0];
+ } else {
+ dFdP[0] = 0;
+ dFdP[1] = 0;
+ }
}
public double dYdP0() {
@@ -341,14 +365,14 @@ public class JacobianMatricesTest {
/** {@inheritDoc} */
public double getParameter(final String name)
- throws IllegalArgumentException {
+ throws UnknownParameterException {
complainIfNotSupported(name);
return b;
}
/** {@inheritDoc} */
public void setParameter(final String name, final double value)
- throws IllegalArgumentException {
+ throws UnknownParameterException {
complainIfNotSupported(name);
b = value;
}
@@ -408,7 +432,8 @@ public class JacobianMatricesTest {
}
public void computeParameterJacobian(double t, double[] y, double[] yDot,
- String paramName, double[] dFdP) {
+ String paramName, double[] dFdP)
+ throws UnknownParameterException {
complainIfNotSupported(paramName);
if (paramName.equals(CX)) {
dFdP[0] = 0;
@@ -462,55 +487,11 @@ public class JacobianMatricesTest {
return new double[] { -t * (sin * dx0 + cos * dy0) , t * (cos * dx0 - sin * dy0) };
}
- public double[][] exactDyDp(double t) {
- double cos = FastMath.cos(omega * t);
- double sin = FastMath.sin(omega * t);
- double dx0 = y0[0] - cx;
- double dy0 = y0[1] - cy;
- return new double[][] {
- { 1 - cos, sin, -t * (sin * dx0 + cos * dy0) },
- { -sin, 1 - cos, t * (cos * dx0 - sin * dy0) }
- };
- }
-
- public double[] exactYDot(double t) {
- double oCos = omega * FastMath.cos(omega * t);
- double oSin = omega * FastMath.sin(omega * t);
- double dx0 = y0[0] - cx;
- double dy0 = y0[1] - cy;
- return new double[] {
- -oSin * dx0 - oCos * dy0,
- oCos * dx0 - oSin * dy0
- };
- }
-
- public double[][] exactDyDy0Dot(double t) {
- double oCos = omega * FastMath.cos(omega * t);
- double oSin = omega * FastMath.sin(omega * t);
- return new double[][] {
- { -oSin, -oCos },
- { oCos, -oSin }
- };
- }
-
- public double[][] exactDyDpDot(double t) {
- double cos = FastMath.cos(omega * t);
- double sin = FastMath.sin(omega * t);
- double oCos = omega * cos;
- double oSin = omega * sin;
- double dx0 = y0[0] - cx;
- double dy0 = y0[1] - cy;
- return new double[][] {
- { oSin, oCos, -sin * dx0 - cos * dy0 - t * ( oCos * dx0 - oSin * dy0) },
- { -oCos, oSin, cos * dx0 - sin * dy0 + t * (-oSin * dx0 - oCos * dy0) }
- };
- }
-
}
/** ODE representing a point moving on a circle with provided center and angular rate. */
private static class ParameterizedCircle extends AbstractParameterizable
- implements FirstOrderDifferentialEquations, ParameterJacobianProvider, ParameterizedODE {
+ implements FirstOrderDifferentialEquations, ParameterizedODE {
public static final String CX = "cx";
public static final String CY = "cy";
@@ -538,36 +519,29 @@ public class JacobianMatricesTest {
yDot[1] = omega * (y[0] - cx);
}
- public void computeParameterJacobian(double t, double[] y, double[] yDot,
- String paramName, double[] dFdP)
- throws IllegalArgumentException {
- if (paramName.equals(CX)) {
- dFdP[0] = 0;
- dFdP[1] = -omega;
- } else {
- throw new IllegalArgumentException();
- }
- }
-
public double getParameter(final String name)
- throws IllegalArgumentException {
- if (name.equals(CY)) {
- return cy;
+ throws UnknownParameterException {
+ if (name.equals(CX)) {
+ return cx;
+ } else if (name.equals(CY)) {
+ return cy;
} else if (name.equals(OMEGA)) {
return omega;
} else {
- throw new IllegalArgumentException();
+ throw new UnknownParameterException(name);
}
}
public void setParameter(final String name, final double value)
- throws IllegalArgumentException {
- if (name.equals(CY)) {
+ throws UnknownParameterException {
+ if (name.equals(CX)) {
+ cx = value;
+ } else if (name.equals(CY)) {
cy = value;
} else if (name.equals(OMEGA)) {
omega = value;
} else {
- throw new IllegalArgumentException();
+ throw new UnknownParameterException(name);
}
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/TestProblemHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/TestProblemHandler.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/TestProblemHandler.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/TestProblemHandler.java Sun Sep 2 14:21:00 2012
@@ -17,6 +17,7 @@
package org.apache.commons.math3.ode;
+import org.apache.commons.math3.exception.MaxCountExceededException;
import org.apache.commons.math3.ode.sampling.StepHandler;
import org.apache.commons.math3.ode.sampling.StepInterpolator;
import org.apache.commons.math3.util.FastMath;
@@ -68,7 +69,7 @@ public class TestProblemHandler
expectedStepStart = Double.NaN;
}
- public void handleStep(StepInterpolator interpolator, boolean isLast) {
+ public void handleStep(StepInterpolator interpolator, boolean isLast) throws MaxCountExceededException {
double start = integrator.getCurrentStepStart();
if (FastMath.abs((start - problem.getInitialTime()) / integrator.getCurrentSignedStepsize()) > 0.001) {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/EventStateTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/EventStateTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/EventStateTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/EventStateTest.java Sun Sep 2 14:21:00 2012
@@ -19,6 +19,10 @@ package org.apache.commons.math3.ode.eve
import org.apache.commons.math3.analysis.solvers.BrentSolver;
+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.FirstOrderDifferentialEquations;
import org.apache.commons.math3.ode.nonstiff.DormandPrince853Integrator;
import org.apache.commons.math3.ode.sampling.AbstractStepInterpolator;
@@ -30,7 +34,7 @@ public class EventStateTest {
// JIRA: MATH-322
@Test
- public void closeEvents() {
+ public void closeEvents() throws MaxCountExceededException, NoBracketingException {
final double r1 = 90.0;
final double r2 = 135.0;
@@ -79,7 +83,9 @@ public class EventStateTest {
// Jira: MATH-695
@Test
- public void testIssue695() {
+ public void testIssue695()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
FirstOrderDifferentialEquations equation = new FirstOrderDifferentialEquations() {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/OverlappingEventsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/OverlappingEventsTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/OverlappingEventsTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/OverlappingEventsTest.java Sun Sep 2 14:21:00 2012
@@ -21,6 +21,10 @@ import java.util.List;
import org.apache.commons.math3.analysis.solvers.BaseSecantSolver;
import org.apache.commons.math3.analysis.solvers.PegasusSolver;
+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.FirstOrderDifferentialEquations;
import org.apache.commons.math3.ode.FirstOrderIntegrator;
import org.apache.commons.math3.ode.nonstiff.DormandPrince853Integrator;
@@ -48,7 +52,9 @@ public class OverlappingEventsTest imple
* EventHandler.g(double, double[])}.
*/
@Test
- public void testOverlappingEvents0() {
+ public void testOverlappingEvents0()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
test(0);
}
@@ -58,7 +64,9 @@ public class OverlappingEventsTest imple
* EventHandler.g(double, double[])}.
*/
@Test
- public void testOverlappingEvents1() {
+ public void testOverlappingEvents1()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
test(1);
}
@@ -68,7 +76,9 @@ public class OverlappingEventsTest imple
* {@link org.apache.commons.math3.ode.events.EventHandler#g(double, double[])
* EventHandler.g(double, double[])}.
*/
- public void test(int eventType) {
+ public void test(int eventType)
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
double e = 1e-15;
FirstOrderIntegrator integrator = new DormandPrince853Integrator(e, 100.0, 1e-7, 1e-7);
BaseSecantSolver rootSolver = new PegasusSolver(e, e);
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/ReappearingEventTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/ReappearingEventTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/ReappearingEventTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/events/ReappearingEventTest.java Sun Sep 2 14:21:00 2012
@@ -21,6 +21,10 @@ import static org.junit.Assert.assertEqu
import java.util.Arrays;
import org.apache.commons.math3.analysis.solvers.PegasusSolver;
+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.FirstOrderDifferentialEquations;
import org.apache.commons.math3.ode.FirstOrderIntegrator;
import org.apache.commons.math3.ode.events.EventHandler;
@@ -30,18 +34,24 @@ import org.junit.Test;
public class ReappearingEventTest {
@Test
- public void testDormandPrince() {
+ public void testDormandPrince()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
double tEnd = test(1);
assertEquals(10.0, tEnd, 1e-7);
}
@Test
- public void testGragg() {
+ public void testGragg()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
double tEnd = test(2);
assertEquals(10.0, tEnd, 1e-7);
}
- public double test(int integratorType) {
+ public double test(int integratorType)
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
double e = 1e-15;
FirstOrderIntegrator integrator;
integrator = (integratorType == 1)
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/AdamsBashforthIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/AdamsBashforthIntegratorTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/AdamsBashforthIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/AdamsBashforthIntegratorTest.java Sun Sep 2 14:21:00 2012
@@ -20,6 +20,7 @@ package org.apache.commons.math3.ode.non
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.FirstOrderIntegrator;
import org.apache.commons.math3.ode.TestProblem1;
@@ -33,7 +34,7 @@ import org.junit.Test;
public class AdamsBashforthIntegratorTest {
@Test(expected=DimensionMismatchException.class)
- public void dimensionCheck() {
+ public void dimensionCheck() throws NumberIsTooSmallException, DimensionMismatchException, MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
FirstOrderIntegrator integ =
new AdamsBashforthIntegrator(2, 0.0, 1.0, 1.0e-10, 1.0e-10);
@@ -43,7 +44,7 @@ public class AdamsBashforthIntegratorTes
}
@Test(expected=NumberIsTooSmallException.class)
- public void testMinStep() {
+ public void testMinStep() throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
double minStep = 0.1 * (pb.getFinalTime() - pb.getInitialTime());
@@ -63,7 +64,7 @@ public class AdamsBashforthIntegratorTes
}
@Test
- public void testIncreasingTolerance()
+ public void testIncreasingTolerance() throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException
{
int previousCalls = Integer.MAX_VALUE;
@@ -100,7 +101,7 @@ public class AdamsBashforthIntegratorTes
}
@Test(expected = MaxCountExceededException.class)
- public void exceedMaxEvaluations() {
+ public void exceedMaxEvaluations() throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
double range = pb.getFinalTime() - pb.getInitialTime();
@@ -116,7 +117,7 @@ public class AdamsBashforthIntegratorTes
}
@Test
- public void backward() {
+ public void backward() throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
@@ -134,7 +135,7 @@ public class AdamsBashforthIntegratorTes
}
@Test
- public void polynomial() {
+ public void polynomial() throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
TestProblem6 pb = new TestProblem6();
double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/AdamsMoultonIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/AdamsMoultonIntegratorTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/AdamsMoultonIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/AdamsMoultonIntegratorTest.java Sun Sep 2 14:21:00 2012
@@ -20,6 +20,7 @@ package org.apache.commons.math3.ode.non
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.FirstOrderIntegrator;
import org.apache.commons.math3.ode.TestProblem1;
@@ -33,7 +34,9 @@ import org.junit.Test;
public class AdamsMoultonIntegratorTest {
@Test(expected=DimensionMismatchException.class)
- public void dimensionCheck() {
+ public void dimensionCheck()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
FirstOrderIntegrator integ =
new AdamsMoultonIntegrator(2, 0.0, 1.0, 1.0e-10, 1.0e-10);
@@ -43,7 +46,9 @@ public class AdamsMoultonIntegratorTest
}
@Test(expected=NumberIsTooSmallException.class)
- public void testMinStep() {
+ public void testMinStep()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
double minStep = 0.1 * (pb.getFinalTime() - pb.getInitialTime());
@@ -64,7 +69,8 @@ public class AdamsMoultonIntegratorTest
@Test
public void testIncreasingTolerance()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
int previousCalls = Integer.MAX_VALUE;
for (int i = -12; i < -2; ++i) {
@@ -100,7 +106,9 @@ public class AdamsMoultonIntegratorTest
}
@Test(expected = MaxCountExceededException.class)
- public void exceedMaxEvaluations() {
+ public void exceedMaxEvaluations()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
double range = pb.getFinalTime() - pb.getInitialTime();
@@ -116,7 +124,9 @@ public class AdamsMoultonIntegratorTest
}
@Test
- public void backward() {
+ public void backward()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
@@ -134,7 +144,9 @@ public class AdamsMoultonIntegratorTest
}
@Test
- public void polynomial() {
+ public void polynomial()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem6 pb = new TestProblem6();
double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java Sun Sep 2 14:21:00 2012
@@ -19,6 +19,8 @@ package org.apache.commons.math3.ode.non
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.FirstOrderDifferentialEquations;
import org.apache.commons.math3.ode.FirstOrderIntegrator;
@@ -38,7 +40,9 @@ import org.junit.Test;
public class ClassicalRungeKuttaIntegratorTest {
@Test
- public void testMissedEndEvent() {
+ public void testMissedEndEvent()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
final double t0 = 1878250320.0000029;
final double tEvent = 1878250379.9999986;
final double[] k = { 1.0e-4, 1.0e-5, 1.0e-6 };
@@ -95,7 +99,9 @@ public class ClassicalRungeKuttaIntegrat
}
@Test
- public void testSanityChecks() {
+ public void testSanityChecks()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
try {
TestProblem1 pb = new TestProblem1();
new ClassicalRungeKuttaIntegrator(0.01).integrate(pb,
@@ -124,7 +130,8 @@ public class ClassicalRungeKuttaIntegrat
@Test
public void testDecreasingSteps()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblemAbstract[] problems = TestProblemFactory.getProblems();
for (int k = 0; k < problems.length; ++k) {
@@ -173,7 +180,8 @@ public class ClassicalRungeKuttaIntegrat
@Test
public void testSmallStep()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
@@ -192,7 +200,8 @@ public class ClassicalRungeKuttaIntegrat
@Test
public void testBigStep()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.2;
@@ -211,7 +220,8 @@ public class ClassicalRungeKuttaIntegrat
@Test
public void testBackward()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
@@ -230,7 +240,8 @@ public class ClassicalRungeKuttaIntegrat
@Test
public void testKepler()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
final TestProblem3 pb = new TestProblem3(0.9);
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
@@ -250,7 +261,8 @@ public class ClassicalRungeKuttaIntegrat
public void init(double t0, double[] y0, double t) {
maxError = 0;
}
- public void handleStep(StepInterpolator interpolator, boolean isLast) {
+ public void handleStep(StepInterpolator interpolator, boolean isLast)
+ throws MaxCountExceededException {
double[] interpolatedY = interpolator.getInterpolatedState ();
double[] theoreticalY = pb.computeTheoreticalState(interpolator.getCurrentTime());
@@ -273,7 +285,8 @@ public class ClassicalRungeKuttaIntegrat
@Test
public void testStepSize()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
final double step = 1.23456;
FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
integ.addStepHandler(new StepHandler() {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaStepInterpolatorTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaStepInterpolatorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaStepInterpolatorTest.java Sun Sep 2 14:21:00 2012
@@ -25,6 +25,10 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Random;
+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.ContinuousOutputModel;
import org.apache.commons.math3.ode.TestProblem3;
import org.apache.commons.math3.ode.sampling.StepHandler;
@@ -36,7 +40,8 @@ public class ClassicalRungeKuttaStepInte
@Test
public void derivativesConsistency()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem3 pb = new TestProblem3();
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
ClassicalRungeKuttaIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
@@ -45,7 +50,9 @@ public class ClassicalRungeKuttaStepInte
@Test
public void serialization()
- throws IOException, ClassNotFoundException {
+ throws IOException, ClassNotFoundException,
+ DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem3 pb = new TestProblem3(0.9);
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54IntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54IntegratorTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54IntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54IntegratorTest.java Sun Sep 2 14:21:00 2012
@@ -18,6 +18,8 @@
package org.apache.commons.math3.ode.nonstiff;
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.FirstOrderIntegrator;
import org.apache.commons.math3.ode.TestProblem1;
@@ -37,7 +39,9 @@ import org.junit.Test;
public class DormandPrince54IntegratorTest {
@Test(expected=DimensionMismatchException.class)
- public void testDimensionCheck() {
+ public void testDimensionCheck()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
DormandPrince54Integrator integrator = new DormandPrince54Integrator(0.0, 1.0,
1.0e-10, 1.0e-10);
@@ -47,7 +51,9 @@ public class DormandPrince54IntegratorTe
}
@Test(expected=NumberIsTooSmallException.class)
- public void testMinStep() {
+ public void testMinStep()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
double minStep = 0.1 * (pb.getFinalTime() - pb.getInitialTime());
@@ -69,7 +75,8 @@ public class DormandPrince54IntegratorTe
@Test
public void testSmallLastStep()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblemAbstract pb = new TestProblem5();
double minStep = 1.25;
@@ -95,7 +102,8 @@ public class DormandPrince54IntegratorTe
@Test
public void testBackward()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
double minStep = 0;
@@ -146,7 +154,8 @@ public class DormandPrince54IntegratorTe
@Test
public void testIncreasingTolerance()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
int previousCalls = Integer.MAX_VALUE;
for (int i = -12; i < -2; ++i) {
@@ -188,7 +197,8 @@ public class DormandPrince54IntegratorTe
@Test
public void testEvents()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem4 pb = new TestProblem4();
double minStep = 0;
@@ -222,7 +232,8 @@ public class DormandPrince54IntegratorTe
@Test
public void testKepler()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
final TestProblem3 pb = new TestProblem3(0.9);
double minStep = 0;
@@ -245,7 +256,8 @@ public class DormandPrince54IntegratorTe
@Test
public void testVariableSteps()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
final TestProblem3 pb = new TestProblem3(0.9);
double minStep = 0;
@@ -270,7 +282,8 @@ public class DormandPrince54IntegratorTe
nbSteps = 0;
maxError = 0;
}
- public void handleStep(StepInterpolator interpolator, boolean isLast) {
+ public void handleStep(StepInterpolator interpolator, boolean isLast)
+ throws MaxCountExceededException {
++nbSteps;
for (int a = 1; a < 10; ++a) {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54StepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54StepInterpolatorTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54StepInterpolatorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54StepInterpolatorTest.java Sun Sep 2 14:21:00 2012
@@ -25,6 +25,10 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Random;
+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.ContinuousOutputModel;
import org.apache.commons.math3.ode.TestProblem3;
import org.apache.commons.math3.ode.sampling.StepHandler;
@@ -38,7 +42,8 @@ public class DormandPrince54StepInterpol
@Test
public void derivativesConsistency()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem3 pb = new TestProblem3(0.1);
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
@@ -52,7 +57,9 @@ public class DormandPrince54StepInterpol
@Test
public void serialization()
- throws IOException, ClassNotFoundException {
+ throws IOException, ClassNotFoundException,
+ DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem3 pb = new TestProblem3(0.9);
double minStep = 0;
@@ -102,7 +109,8 @@ public class DormandPrince54StepInterpol
@Test
public void checkClone()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem3 pb = new TestProblem3(0.9);
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
@@ -112,7 +120,8 @@ public class DormandPrince54StepInterpol
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.addStepHandler(new StepHandler() {
- public void handleStep(StepInterpolator interpolator, boolean isLast) {
+ public void handleStep(StepInterpolator interpolator, boolean isLast)
+ throws MaxCountExceededException {
StepInterpolator cloned = interpolator.copy();
double tA = cloned.getPreviousTime();
double tB = cloned.getCurrentTime();
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853IntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853IntegratorTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853IntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853IntegratorTest.java Sun Sep 2 14:21:00 2012
@@ -18,6 +18,8 @@
package org.apache.commons.math3.ode.nonstiff;
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.FirstOrderDifferentialEquations;
import org.apache.commons.math3.ode.FirstOrderIntegrator;
@@ -37,7 +39,9 @@ import org.junit.Test;
public class DormandPrince853IntegratorTest {
@Test
- public void testMissedEndEvent() {
+ public void testMissedEndEvent()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
final double t0 = 1878250320.0000029;
final double tEvent = 1878250379.9999986;
final double[] k = { 1.0e-4, 1.0e-5, 1.0e-6 };
@@ -97,7 +101,9 @@ public class DormandPrince853IntegratorT
}
@Test(expected=DimensionMismatchException.class)
- public void testDimensionCheck() {
+ public void testDimensionCheck()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
DormandPrince853Integrator integrator = new DormandPrince853Integrator(0.0, 1.0,
1.0e-10, 1.0e-10);
@@ -108,7 +114,9 @@ public class DormandPrince853IntegratorT
}
@Test(expected=NumberIsTooSmallException.class)
- public void testNullIntervalCheck() {
+ public void testNullIntervalCheck()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
DormandPrince853Integrator integrator = new DormandPrince853Integrator(0.0, 1.0,
1.0e-10, 1.0e-10);
@@ -119,7 +127,9 @@ public class DormandPrince853IntegratorT
}
@Test(expected=NumberIsTooSmallException.class)
- public void testMinStep() {
+ public void testMinStep()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
double minStep = 0.1 * (pb.getFinalTime() - pb.getInitialTime());
@@ -141,7 +151,8 @@ public class DormandPrince853IntegratorT
@Test
public void testIncreasingTolerance()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
int previousCalls = Integer.MAX_VALUE;
AdaptiveStepsizeIntegrator integ =
@@ -177,7 +188,9 @@ public class DormandPrince853IntegratorT
}
@Test
- public void testTooLargeFirstStep() {
+ public void testTooLargeFirstStep()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
AdaptiveStepsizeIntegrator integ =
new DormandPrince853Integrator(0, Double.POSITIVE_INFINITY, Double.NaN, Double.NaN);
@@ -204,7 +217,8 @@ public class DormandPrince853IntegratorT
@Test
public void testBackward()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
double minStep = 0;
@@ -228,7 +242,8 @@ public class DormandPrince853IntegratorT
@Test
public void testEvents()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem4 pb = new TestProblem4();
double minStep = 0;
@@ -261,7 +276,8 @@ public class DormandPrince853IntegratorT
@Test
public void testKepler()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
final TestProblem3 pb = new TestProblem3(0.9);
double minStep = 0;
@@ -284,7 +300,8 @@ public class DormandPrince853IntegratorT
@Test
public void testVariableSteps()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
final TestProblem3 pb = new TestProblem3(0.9);
double minStep = 0;
@@ -305,7 +322,8 @@ public class DormandPrince853IntegratorT
@Test
public void testUnstableDerivative()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
final StepProblem stepProblem = new StepProblem(0.0, 1.0, 2.0);
FirstOrderIntegrator integ =
new DormandPrince853Integrator(0.1, 10, 1.0e-12, 0.0);
@@ -323,7 +341,8 @@ public class DormandPrince853IntegratorT
nbSteps = 0;
maxError = 0;
}
- public void handleStep(StepInterpolator interpolator, boolean isLast) {
+ public void handleStep(StepInterpolator interpolator, boolean isLast)
+ throws MaxCountExceededException {
++nbSteps;
for (int a = 1; a < 10; ++a) {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolatorTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolatorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolatorTest.java Sun Sep 2 14:21:00 2012
@@ -25,6 +25,10 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Random;
+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.ContinuousOutputModel;
import org.apache.commons.math3.ode.TestProblem3;
import org.apache.commons.math3.ode.sampling.StepHandler;
@@ -38,7 +42,8 @@ public class DormandPrince853StepInterpo
@Test
public void derivativesConsistency()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem3 pb = new TestProblem3(0.1);
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
@@ -52,7 +57,9 @@ public class DormandPrince853StepInterpo
@Test
public void serialization()
- throws IOException, ClassNotFoundException {
+ throws IOException, ClassNotFoundException,
+ DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem3 pb = new TestProblem3(0.9);
double minStep = 0;
@@ -102,7 +109,8 @@ public class DormandPrince853StepInterpo
@Test
public void checklone()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem3 pb = new TestProblem3(0.9);
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
@@ -112,7 +120,8 @@ public class DormandPrince853StepInterpo
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.addStepHandler(new StepHandler() {
- public void handleStep(StepInterpolator interpolator, boolean isLast) {
+ public void handleStep(StepInterpolator interpolator, boolean isLast)
+ throws MaxCountExceededException {
StepInterpolator cloned = interpolator.copy();
double tA = cloned.getPreviousTime();
double tB = cloned.getCurrentTime();
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerIntegratorTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerIntegratorTest.java Sun Sep 2 14:21:00 2012
@@ -19,6 +19,9 @@ package org.apache.commons.math3.ode.non
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.FirstOrderDifferentialEquations;
import org.apache.commons.math3.ode.FirstOrderIntegrator;
import org.apache.commons.math3.ode.TestProblem1;
@@ -36,7 +39,9 @@ import org.junit.Test;
public class EulerIntegratorTest {
@Test(expected=DimensionMismatchException.class)
- public void testDimensionCheck() {
+ public void testDimensionCheck()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
new EulerIntegrator(0.01).integrate(pb,
0.0, new double[pb.getDimension()+10],
@@ -46,7 +51,8 @@ public class EulerIntegratorTest {
@Test
public void testDecreasingSteps()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblemAbstract[] problems = TestProblemFactory.getProblems();
for (int k = 0; k < problems.length; ++k) {
@@ -92,7 +98,8 @@ public class EulerIntegratorTest {
@Test
public void testSmallStep()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
@@ -113,7 +120,8 @@ public class EulerIntegratorTest {
@Test
public void testBigStep()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.2;
@@ -133,7 +141,8 @@ public class EulerIntegratorTest {
@Test
public void testBackward()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
@@ -152,7 +161,8 @@ public class EulerIntegratorTest {
@Test
public void testStepSize()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
final double step = 1.23456;
FirstOrderIntegrator integ = new EulerIntegrator(step);
integ.addStepHandler(new StepHandler() {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerStepInterpolatorTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerStepInterpolatorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerStepInterpolatorTest.java Sun Sep 2 14:21:00 2012
@@ -25,6 +25,10 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Random;
+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.ContinuousOutputModel;
import org.apache.commons.math3.ode.EquationsMapper;
import org.apache.commons.math3.ode.TestProblem1;
@@ -38,7 +42,7 @@ import org.junit.Test;
public class EulerStepInterpolatorTest {
@Test
- public void noReset() {
+ public void noReset() throws MaxCountExceededException {
double[] y = { 0.0, 1.0, -2.0 };
double[][] yDot = { { 1.0, 2.0, -2.0 } };
@@ -58,7 +62,7 @@ public class EulerStepInterpolatorTest {
}
@Test
- public void interpolationAtBounds() {
+ public void interpolationAtBounds() throws MaxCountExceededException {
double t0 = 0;
double[] y0 = {0.0, 1.0, -2.0};
@@ -96,7 +100,7 @@ public class EulerStepInterpolatorTest {
}
@Test
- public void interpolationInside() {
+ public void interpolationInside() throws MaxCountExceededException {
double[] y = { 0.0, 1.0, -2.0 };
double[][] yDot = { { 1.0, 2.0, -2.0 } };
@@ -127,7 +131,8 @@ public class EulerStepInterpolatorTest {
@Test
public void derivativesConsistency()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem3 pb = new TestProblem3();
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
EulerIntegrator integ = new EulerIntegrator(step);
@@ -136,7 +141,9 @@ public class EulerStepInterpolatorTest {
@Test
public void serialization()
- throws IOException, ClassNotFoundException {
+ throws IOException, ClassNotFoundException,
+ DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/GillIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/GillIntegratorTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/GillIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/GillIntegratorTest.java Sun Sep 2 14:21:00 2012
@@ -19,6 +19,9 @@ package org.apache.commons.math3.ode.non
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.FirstOrderDifferentialEquations;
import org.apache.commons.math3.ode.FirstOrderIntegrator;
import org.apache.commons.math3.ode.TestProblem1;
@@ -37,7 +40,9 @@ import org.junit.Test;
public class GillIntegratorTest {
@Test(expected=DimensionMismatchException.class)
- public void testDimensionCheck() {
+ public void testDimensionCheck()
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
new GillIntegrator(0.01).integrate(pb,
0.0, new double[pb.getDimension()+10],
@@ -47,7 +52,8 @@ public class GillIntegratorTest {
@Test
public void testDecreasingSteps()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblemAbstract[] problems = TestProblemFactory.getProblems();
for (int k = 0; k < problems.length; ++k) {
@@ -93,7 +99,8 @@ public class GillIntegratorTest {
@Test
public void testSmallStep()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
@@ -113,7 +120,8 @@ public class GillIntegratorTest {
@Test
public void testBigStep()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem1 pb = new TestProblem1();
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.2;
@@ -132,7 +140,8 @@ public class GillIntegratorTest {
@Test
public void testBackward()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
@@ -151,7 +160,8 @@ public class GillIntegratorTest {
@Test
public void testKepler()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
final TestProblem3 pb = new TestProblem3(0.9);
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
@@ -165,7 +175,8 @@ public class GillIntegratorTest {
@Test
public void testUnstableDerivative()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
final StepProblem stepProblem = new StepProblem(0.0, 1.0, 2.0);
FirstOrderIntegrator integ = new GillIntegrator(0.3);
integ.addEventHandler(stepProblem, 1.0, 1.0e-12, 1000);
@@ -181,7 +192,8 @@ public class GillIntegratorTest {
public void init(double t0, double[] y0, double t) {
maxError = 0;
}
- public void handleStep(StepInterpolator interpolator, boolean isLast) {
+ public void handleStep(StepInterpolator interpolator, boolean isLast)
+ throws MaxCountExceededException {
double[] interpolatedY = interpolator.getInterpolatedState();
double[] theoreticalY = pb.computeTheoreticalState(interpolator.getCurrentTime());
@@ -204,7 +216,8 @@ public class GillIntegratorTest {
@Test
public void testStepSize()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
final double step = 1.23456;
FirstOrderIntegrator integ = new GillIntegrator(step);
integ.addStepHandler(new StepHandler() {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/GillStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/GillStepInterpolatorTest.java?rev=1379975&r1=1379974&r2=1379975&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/GillStepInterpolatorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/ode/nonstiff/GillStepInterpolatorTest.java Sun Sep 2 14:21:00 2012
@@ -25,6 +25,10 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Random;
+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.ContinuousOutputModel;
import org.apache.commons.math3.ode.TestProblem3;
import org.apache.commons.math3.ode.sampling.StepHandler;
@@ -36,7 +40,8 @@ public class GillStepInterpolatorTest {
@Test
public void testDerivativesConsistency()
- {
+ throws DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem3 pb = new TestProblem3();
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
GillIntegrator integ = new GillIntegrator(step);
@@ -45,7 +50,9 @@ public class GillStepInterpolatorTest {
@Test
public void serialization()
- throws IOException, ClassNotFoundException {
+ throws IOException, ClassNotFoundException,
+ DimensionMismatchException, NumberIsTooSmallException,
+ MaxCountExceededException, NoBracketingException {
TestProblem3 pb = new TestProblem3(0.9);
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;