removed MathUserException from ODE package
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1165792 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e751cc22b6
commit
1de3d116a9
|
@ -95,7 +95,6 @@ public enum LocalizedFormats implements Localizable {
|
|||
ENDPOINTS_NOT_AN_INTERVAL("endpoints do not specify an interval: [{0}, {1}]"),
|
||||
EQUAL_VERTICES_IN_SIMPLEX("equal vertices {0} and {1} in simplex configuration"),
|
||||
EULER_ANGLES_SINGULARITY("Euler angles singularity"),
|
||||
EVALUATION_FAILED("evaluation failed for argument = {0}"),
|
||||
EVALUATION("evaluation"), /* keep */
|
||||
EXPANSION_FACTOR_SMALLER_THAN_ONE("expansion factor smaller than one ({0})"),
|
||||
FACTORIAL_NEGATIVE_PARAMETER("must have n >= 0 for n!, got n = {0}"),
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
package org.apache.commons.math.ode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
|
@ -117,14 +117,12 @@ public class ContinuousOutputModel
|
|||
|
||||
/** Append another model at the end of the instance.
|
||||
* @param model model to add at the end of the instance
|
||||
* @exception MathUserException if user code called from step interpolator
|
||||
* finalization triggers one
|
||||
* @exception IllegalArgumentException if the model to append is not
|
||||
* @exception MathIllegalArgumentException if the model to append is not
|
||||
* compatible with the instance (dimension of the state vector,
|
||||
* propagation direction, hole between the dates)
|
||||
*/
|
||||
public void append(final ContinuousOutputModel model)
|
||||
throws MathUserException {
|
||||
throws MathIllegalArgumentException {
|
||||
|
||||
if (model.steps.size() == 0) {
|
||||
return;
|
||||
|
@ -136,14 +134,12 @@ public class ContinuousOutputModel
|
|||
} else {
|
||||
|
||||
if (getInterpolatedState().length != model.getInterpolatedState().length) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
|
||||
getInterpolatedState().length, model.getInterpolatedState().length);
|
||||
throw new DimensionMismatchException(model.getInterpolatedState().length,
|
||||
getInterpolatedState().length);
|
||||
}
|
||||
|
||||
if (forward ^ model.forward) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
LocalizedFormats.PROPAGATION_DIRECTION_MISMATCH);
|
||||
throw new MathIllegalArgumentException(LocalizedFormats.PROPAGATION_DIRECTION_MISMATCH);
|
||||
}
|
||||
|
||||
final StepInterpolator lastInterpolator = steps.get(index);
|
||||
|
@ -152,8 +148,8 @@ public class ContinuousOutputModel
|
|||
final double step = current - previous;
|
||||
final double gap = model.getInitialTime() - current;
|
||||
if (FastMath.abs(gap) > 1.0e-3 * FastMath.abs(step)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
LocalizedFormats.HOLE_BETWEEN_MODELS_TIME_RANGES, FastMath.abs(gap));
|
||||
throw new MathIllegalArgumentException(LocalizedFormats.HOLE_BETWEEN_MODELS_TIME_RANGES,
|
||||
FastMath.abs(gap));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -184,11 +180,8 @@ 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 MathUserException if user code called from step interpolator
|
||||
* finalization triggers one
|
||||
*/
|
||||
public void handleStep(final StepInterpolator interpolator, final boolean isLast)
|
||||
throws MathUserException {
|
||||
public void handleStep(final StepInterpolator interpolator, final boolean isLast) {
|
||||
|
||||
if (steps.size() == 0) {
|
||||
initialTime = interpolator.getPreviousTime();
|
||||
|
@ -333,10 +326,8 @@ public class ContinuousOutputModel
|
|||
/**
|
||||
* Get the state vector of the interpolated point.
|
||||
* @return state vector at time {@link #getInterpolatedTime}
|
||||
* @exception MathUserException if user code called from step interpolator
|
||||
* finalization triggers one
|
||||
*/
|
||||
public double[] getInterpolatedState() throws MathUserException {
|
||||
public double[] getInterpolatedState() {
|
||||
return steps.get(index).getInterpolatedState();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.commons.math.ode;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
|
||||
/** This class converts second order differential equations to first
|
||||
* order ones.
|
||||
|
@ -97,11 +96,8 @@ public class FirstOrderConverter implements FirstOrderDifferentialEquations {
|
|||
* @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
|
||||
* @throws MathUserException this exception is propagated to the caller if the
|
||||
* underlying user function triggers one
|
||||
*/
|
||||
public void computeDerivatives(final double t, final double[] y, final double[] yDot)
|
||||
throws MathUserException {
|
||||
public void computeDerivatives(final double t, final double[] y, final double[] yDot) {
|
||||
|
||||
// split the state vector in two
|
||||
System.arraycopy(y, 0, z, 0, dimension);
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.commons.math.ode;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
|
||||
|
||||
/** This interface represents a first order differential equations set.
|
||||
|
@ -58,10 +57,7 @@ public interface FirstOrderDifferentialEquations {
|
|||
* @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
|
||||
* @throws MathUserException this user-defined exception should be used if an error is
|
||||
* is triggered by user code
|
||||
*/
|
||||
void computeDerivatives(double t, double[] y, double[] yDot)
|
||||
throws MathUserException;
|
||||
void computeDerivatives(double t, double[] y, double[] yDot);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.commons.math.ode;
|
|||
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.linear.Array2DRowRealMatrix;
|
||||
import org.apache.commons.math.ode.nonstiff.AdaptiveStepsizeIntegrator;
|
||||
|
@ -417,8 +416,7 @@ public abstract class MultistepIntegrator extends AdaptiveStepsizeIntegrator {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void computeDerivatives(double t, double[] y, double[] dot)
|
||||
throws MathUserException {
|
||||
public void computeDerivatives(double t, double[] y, double[] dot) {
|
||||
MultistepIntegrator.this.computeDerivatives(t, y, dot);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.commons.math.ode;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
|
||||
/** This interface represents a second order differential equations set.
|
||||
|
||||
|
@ -60,10 +59,7 @@ public interface SecondOrderDifferentialEquations {
|
|||
* of the state vector
|
||||
* @param yDDot placeholder array where to put the second time derivative
|
||||
* of the state vector
|
||||
* @throws MathUserException this user-defined exception should be used if an error is
|
||||
* is triggered by user code
|
||||
*/
|
||||
void computeSecondDerivatives(double t, double[] y, double[] yDot, double[] yDDot)
|
||||
throws MathUserException;
|
||||
void computeSecondDerivatives(double t, double[] y, double[] yDot, double[] yDDot);
|
||||
|
||||
}
|
||||
|
|
|
@ -259,14 +259,11 @@ public abstract class AdaptiveStepsizeIntegrator
|
|||
* @param y1 work array for a state vector
|
||||
* @param yDot1 work array for the first time derivative of y1
|
||||
* @return first integration step
|
||||
* @exception MathUserException this exception is propagated to
|
||||
* the caller if the underlying user function triggers one
|
||||
*/
|
||||
public double initializeStep(final FirstOrderDifferentialEquations equations,
|
||||
final boolean forward, final int order, final double[] scale,
|
||||
final double t0, final double[] y0, final double[] yDot0,
|
||||
final double[] y1, final double[] yDot1)
|
||||
throws MathUserException {
|
||||
final double[] y1, final double[] yDot1) {
|
||||
|
||||
if (initialStep > 0) {
|
||||
// use the user provided value
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
|
||||
/**
|
||||
|
@ -82,8 +81,7 @@ class ClassicalRungeKuttaStepInterpolator
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void computeInterpolatedStateAndDerivatives(final double theta,
|
||||
final double oneMinusThetaH)
|
||||
throws MathUserException {
|
||||
final double oneMinusThetaH) {
|
||||
|
||||
final double fourTheta = 4 * theta;
|
||||
final double oneMinusTheta = 1 - theta;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.AbstractIntegrator;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
|
||||
|
@ -165,8 +164,7 @@ class DormandPrince54StepInterpolator
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void computeInterpolatedStateAndDerivatives(final double theta,
|
||||
final double oneMinusThetaH)
|
||||
throws MathUserException {
|
||||
final double oneMinusThetaH) {
|
||||
|
||||
if (! vectorsInitialized) {
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.io.IOException;
|
|||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.AbstractIntegrator;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
|
||||
|
@ -311,8 +310,7 @@ class DormandPrince853StepInterpolator
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void computeInterpolatedStateAndDerivatives(final double theta,
|
||||
final double oneMinusThetaH)
|
||||
throws MathUserException {
|
||||
final double oneMinusThetaH) {
|
||||
|
||||
if (! vectorsInitialized) {
|
||||
|
||||
|
@ -385,8 +383,7 @@ class DormandPrince853StepInterpolator
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void doFinalize()
|
||||
throws MathUserException {
|
||||
protected void doFinalize() {
|
||||
|
||||
if (currentState == null) {
|
||||
// we are finalizing an uninitialized instance
|
||||
|
@ -436,7 +433,7 @@ class DormandPrince853StepInterpolator
|
|||
try {
|
||||
// save the local attributes
|
||||
finalizeStep();
|
||||
} catch (MathUserException e) {
|
||||
} catch (Exception e) {
|
||||
IOException ioe = new IOException(e.getLocalizedMessage());
|
||||
ioe.initCause(e);
|
||||
throw ioe;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
|
||||
/**
|
||||
|
@ -78,8 +77,7 @@ class EulerStepInterpolator
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void computeInterpolatedStateAndDerivatives(final double theta,
|
||||
final double oneMinusThetaH)
|
||||
throws MathUserException {
|
||||
final double oneMinusThetaH) {
|
||||
|
||||
for (int i = 0; i < interpolatedState.length; ++i) {
|
||||
interpolatedState[i] = currentState[i] - oneMinusThetaH * yDotK[0][i];
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
|
@ -90,8 +89,7 @@ class GillStepInterpolator
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void computeInterpolatedStateAndDerivatives(final double theta,
|
||||
final double oneMinusThetaH)
|
||||
throws MathUserException {
|
||||
final double oneMinusThetaH) {
|
||||
|
||||
final double twoTheta = 2 * theta;
|
||||
final double fourTheta = 4 * theta;
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.commons.math.ode.nonstiff;
|
|||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolver;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.events.EventHandler;
|
||||
import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
|
||||
|
@ -451,14 +450,11 @@ public class GraggBulirschStoerIntegrator extends AdaptiveStepsizeIntegrator {
|
|||
* @param yTmp placeholder for one state vector
|
||||
* @return true if computation was done properly,
|
||||
* false if stability check failed before end of computation
|
||||
* @throws MathUserException this exception is propagated to the caller if the
|
||||
* underlying user function triggers one
|
||||
*/
|
||||
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)
|
||||
throws MathUserException {
|
||||
final double[] yTmp) {
|
||||
|
||||
final int n = sequence[k];
|
||||
final double subStep = step / n;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
|
||||
/**
|
||||
|
@ -70,8 +69,7 @@ class HighamHall54StepInterpolator
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void computeInterpolatedStateAndDerivatives(final double theta,
|
||||
final double oneMinusThetaH)
|
||||
throws MathUserException {
|
||||
final double oneMinusThetaH) {
|
||||
|
||||
final double theta2 = theta * theta;
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
|
||||
/**
|
||||
|
@ -80,8 +79,7 @@ class MidpointStepInterpolator
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void computeInterpolatedStateAndDerivatives(final double theta,
|
||||
final double oneMinusThetaH)
|
||||
throws MathUserException {
|
||||
final double oneMinusThetaH) {
|
||||
|
||||
final double coeff1 = oneMinusThetaH * theta;
|
||||
final double coeff2 = oneMinusThetaH * (1.0 + theta);
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
|
||||
/**
|
||||
|
@ -85,8 +84,7 @@ class ThreeEighthesStepInterpolator
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void computeInterpolatedStateAndDerivatives(final double theta,
|
||||
final double oneMinusThetaH)
|
||||
throws MathUserException {
|
||||
final double oneMinusThetaH) {
|
||||
|
||||
final double fourTheta2 = 4 * theta * theta;
|
||||
final double s = oneMinusThetaH / 8.0;
|
||||
|
|
|
@ -21,8 +21,6 @@ import java.io.IOException;
|
|||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
|
||||
/** This abstract class represents an interpolator over the last step
|
||||
* during an ODE integration.
|
||||
*
|
||||
|
@ -197,7 +195,7 @@ public abstract class AbstractStepInterpolator
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public StepInterpolator copy() throws MathUserException {
|
||||
public StepInterpolator copy() {
|
||||
|
||||
// finalize the step before performing copy
|
||||
finalizeStep();
|
||||
|
@ -326,15 +324,12 @@ public abstract class AbstractStepInterpolator
|
|||
* (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
|
||||
* @throws MathUserException this exception is propagated to the caller if the
|
||||
* underlying user function triggers one
|
||||
*/
|
||||
protected abstract void computeInterpolatedStateAndDerivatives(double theta,
|
||||
double oneMinusThetaH)
|
||||
throws MathUserException;
|
||||
double oneMinusThetaH);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public double[] getInterpolatedState() throws MathUserException {
|
||||
public double[] getInterpolatedState() {
|
||||
|
||||
// lazy evaluation of the state
|
||||
if (dirtyState) {
|
||||
|
@ -349,7 +344,7 @@ public abstract class AbstractStepInterpolator
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public double[] getInterpolatedDerivatives() throws MathUserException {
|
||||
public double[] getInterpolatedDerivatives() {
|
||||
|
||||
// lazy evaluation of the state
|
||||
if (dirtyState) {
|
||||
|
@ -401,11 +396,8 @@ public abstract class AbstractStepInterpolator
|
|||
* Therefore, subclasses are not allowed not reimplement it, they
|
||||
* should rather reimplement <code>doFinalize</code>.</p>
|
||||
|
||||
* @throws MathUserException this exception is propagated to the
|
||||
* caller if the underlying user function triggers one
|
||||
*/
|
||||
public final void finalizeStep()
|
||||
throws MathUserException {
|
||||
public final void finalizeStep() {
|
||||
if (! finalized) {
|
||||
doFinalize();
|
||||
finalized = true;
|
||||
|
@ -415,11 +407,8 @@ public abstract class AbstractStepInterpolator
|
|||
/**
|
||||
* Really finalize the step.
|
||||
* The default implementation of this method does nothing.
|
||||
* @throws MathUserException this exception is propagated to the
|
||||
* caller if the underlying user function triggers one
|
||||
*/
|
||||
protected void doFinalize()
|
||||
throws MathUserException {
|
||||
protected void doFinalize() {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -465,7 +454,7 @@ public abstract class AbstractStepInterpolator
|
|||
// finalize the step (and don't bother saving the now true flag)
|
||||
try {
|
||||
finalizeStep();
|
||||
} catch (MathUserException e) {
|
||||
} catch (Exception e) {
|
||||
IOException ioe = new IOException(e.getLocalizedMessage());
|
||||
ioe.initCause(e);
|
||||
throw ioe;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.commons.math.ode.sampling;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
|
||||
/**
|
||||
* This interface represents a handler that should be called after
|
||||
|
@ -55,8 +54,7 @@ public interface FixedStepHandler {
|
|||
* provide at the end of the integration a complete array of all
|
||||
* steps), it should build a local copy store this copy.
|
||||
* @param isLast true if the step is the last one
|
||||
* @throws MathUserException if some error condition is encountered
|
||||
*/
|
||||
void handleStep(double t, double[] y, double[] yDot, boolean isLast) throws MathUserException;
|
||||
void handleStep(double t, double[] y, double[] yDot, boolean isLast);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.ObjectInput;
|
|||
import java.io.ObjectOutput;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.linear.Array2DRowRealMatrix;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
|
@ -171,11 +170,8 @@ public class NordsieckStepInterpolator extends AbstractStepInterpolator {
|
|||
* to be preserved across several calls.</p>
|
||||
* @return state vector at time {@link #getInterpolatedTime}
|
||||
* @see #getInterpolatedDerivatives()
|
||||
* @throws MathUserException if this call induces an automatic
|
||||
* step finalization that throws one
|
||||
*/
|
||||
public double[] getInterpolatedStateVariation()
|
||||
throws MathUserException {
|
||||
public double[] getInterpolatedStateVariation() {
|
||||
// compute and ignore interpolated state
|
||||
// to make sure state variation is computed as a side effect
|
||||
getInterpolatedState();
|
||||
|
|
|
@ -19,8 +19,6 @@ package org.apache.commons.math.ode.sampling;
|
|||
|
||||
import java.io.Externalizable;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
|
||||
/** This interface represents an interpolator over the last step
|
||||
* during an ODE integration.
|
||||
*
|
||||
|
@ -89,10 +87,8 @@ public interface StepInterpolator extends Externalizable {
|
|||
* to be preserved across several calls.</p>
|
||||
* @return state vector at time {@link #getInterpolatedTime}
|
||||
* @see #getInterpolatedDerivatives()
|
||||
* @exception MathUserException if user code called from step interpolator
|
||||
* finalization triggers one
|
||||
*/
|
||||
double[] getInterpolatedState() throws MathUserException;
|
||||
double[] getInterpolatedState();
|
||||
|
||||
/**
|
||||
* Get the derivatives of the state vector of the interpolated point.
|
||||
|
@ -101,11 +97,9 @@ public interface StepInterpolator extends Externalizable {
|
|||
* to be preserved across several calls.</p>
|
||||
* @return derivatives of the state vector at time {@link #getInterpolatedTime}
|
||||
* @see #getInterpolatedState()
|
||||
* @exception MathUserException if user code called from step interpolator
|
||||
* finalization triggers one
|
||||
* @since 2.0
|
||||
*/
|
||||
double[] getInterpolatedDerivatives() throws MathUserException;
|
||||
double[] getInterpolatedDerivatives();
|
||||
|
||||
/** Check if the natural integration direction is forward.
|
||||
* <p>This method provides the integration direction as specified by
|
||||
|
@ -123,10 +117,8 @@ public interface StepInterpolator extends Externalizable {
|
|||
* original one. Both can be used with different settings for
|
||||
* interpolated time without any side effect.</p>
|
||||
* @return a deep copy of the instance, which can be used independently.
|
||||
* @exception MathUserException if user code called from step interpolator
|
||||
* finalization triggers one
|
||||
* @see #setInterpolatedTime(double)
|
||||
*/
|
||||
StepInterpolator copy() throws MathUserException;
|
||||
StepInterpolator copy();
|
||||
|
||||
}
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
|
||||
package org.apache.commons.math.ode.sampling;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.sampling.FixedStepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
|
@ -194,11 +190,8 @@ public class StepNormalizer implements StepHandler {
|
|||
* should build a local copy using the clone method and store this
|
||||
* copy.
|
||||
* @param isLast true if the step is the last one
|
||||
* @throws MathUserException this exception is propagated to the
|
||||
* caller if the underlying user function triggers one
|
||||
*/
|
||||
public void handleStep(final StepInterpolator interpolator,
|
||||
final boolean isLast) throws MathUserException {
|
||||
public void handleStep(final StepInterpolator interpolator, final boolean isLast) {
|
||||
// The first time, update the last state with the start information.
|
||||
if (lastState == null) {
|
||||
firstTime = interpolator.getPreviousTime();
|
||||
|
@ -270,10 +263,8 @@ public class StepNormalizer implements StepHandler {
|
|||
/**
|
||||
* Invokes the underlying step handler for the current normalized step.
|
||||
* @param isLast true if the step is the last one
|
||||
* @throws MathUserException this exception is propagated to the
|
||||
* caller if the underlying user function triggers one
|
||||
*/
|
||||
private void doNormalizedStep(boolean isLast) throws MathUserException {
|
||||
private void doNormalizedStep(boolean isLast) {
|
||||
if (!bounds.firstIncluded() && firstTime == lastTime) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,6 @@ EMPTY_STRING_FOR_IMAGINARY_CHARACTER = cha\u00eene vide pour le caract\u00e8 ima
|
|||
ENDPOINTS_NOT_AN_INTERVAL = les bornes ne d\u00e9finissent pas un intervalle : [{0}, {1}]
|
||||
EQUAL_VERTICES_IN_SIMPLEX = sommets {0} et {1} \u00e9gaux dans la configuration du simplex
|
||||
EULER_ANGLES_SINGULARITY = singularit\u00e9 d''angles d''Euler
|
||||
EVALUATION_FAILED = erreur d''\u00e9valuation pour l''argument {0}
|
||||
EVALUATION = \u00e9valuation
|
||||
EXPANSION_FACTOR_SMALLER_THAN_ONE = facteur d''extension inf\u00e9rieur \u00e0 un ({0})
|
||||
FACTORIAL_NEGATIVE_PARAMETER = n doit \u00eatre positif pour le calcul de n!, or n = {0}
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.commons.math.ode;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.nonstiff.DormandPrince54Integrator;
|
||||
import org.apache.commons.math.ode.nonstiff.DormandPrince853Integrator;
|
||||
import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
|
||||
|
@ -84,8 +83,7 @@ public class ContinuousOutputModelTest {
|
|||
// theoretical solution: y[0] = cos(t), y[1] = sin(t)
|
||||
FirstOrderDifferentialEquations problem =
|
||||
new FirstOrderDifferentialEquations() {
|
||||
public void computeDerivatives(double t, double[] y, double[] dot)
|
||||
throws MathUserException {
|
||||
public void computeDerivatives(double t, double[] y, double[] dot) {
|
||||
dot[0] = -y[1];
|
||||
dot[1] = y[0];
|
||||
}
|
||||
|
@ -130,8 +128,7 @@ public class ContinuousOutputModelTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testErrorConditions()
|
||||
throws MathUserException {
|
||||
public void testErrorConditions() {
|
||||
|
||||
ContinuousOutputModel cm = new ContinuousOutputModel();
|
||||
cm.handleStep(buildInterpolator(0, new double[] { 0.0, 1.0, -2.0 }, 1), true);
|
||||
|
@ -151,8 +148,7 @@ public class ContinuousOutputModelTest {
|
|||
}
|
||||
|
||||
private boolean checkAppendError(ContinuousOutputModel cm,
|
||||
double t0, double[] y0, double t1)
|
||||
throws MathUserException {
|
||||
double t0, double[] y0, double t1) {
|
||||
try {
|
||||
ContinuousOutputModel otherCm = new ContinuousOutputModel();
|
||||
otherCm.handleStep(buildInterpolator(t0, y0, t1), true);
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
package org.apache.commons.math.ode;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ODEIntegrator;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
@ -67,9 +65,7 @@ public class TestProblemHandler
|
|||
expectedStepStart = Double.NaN;
|
||||
}
|
||||
|
||||
public void handleStep(StepInterpolator interpolator,
|
||||
boolean isLast)
|
||||
throws MathUserException {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||
|
||||
double start = integrator.getCurrentStepStart();
|
||||
if (FastMath.abs((start - problem.getInitialTime()) / integrator.getCurrentSignedStepsize()) > 0.001) {
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.util.List;
|
|||
|
||||
import org.apache.commons.math.analysis.solvers.BaseSecantSolver;
|
||||
import org.apache.commons.math.analysis.solvers.PegasusSolver;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
import org.apache.commons.math.ode.nonstiff.DormandPrince853Integrator;
|
||||
|
@ -114,7 +113,7 @@ public class OverlappingEventsTest implements FirstOrderDifferentialEquations {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void computeDerivatives(double t, double[] y, double[] yDot) throws MathUserException {
|
||||
public void computeDerivatives(double t, double[] y, double[] yDot) {
|
||||
yDot[0] = 1.0;
|
||||
yDot[1] = 2.0;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.commons.math.ode.nonstiff;
|
|||
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
|
@ -248,8 +247,7 @@ public class ClassicalRungeKuttaIntegratorTest {
|
|||
public void reset() {
|
||||
maxError = 0;
|
||||
}
|
||||
public void handleStep(StepInterpolator interpolator,
|
||||
boolean isLast) throws MathUserException {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||
|
||||
double[] interpolatedY = interpolator.getInterpolatedState ();
|
||||
double[] theoreticalY = pb.computeTheoreticalState(interpolator.getCurrentTime());
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
import org.apache.commons.math.ode.TestProblem1;
|
||||
|
@ -272,9 +271,7 @@ public class DormandPrince54IntegratorTest {
|
|||
nbSteps = 0;
|
||||
maxError = 0;
|
||||
}
|
||||
public void handleStep(StepInterpolator interpolator,
|
||||
boolean isLast)
|
||||
throws MathUserException {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||
|
||||
++nbSteps;
|
||||
for (int a = 1; a < 10; ++a) {
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.io.ObjectInputStream;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
|
@ -113,8 +112,7 @@ public class DormandPrince54StepInterpolatorTest {
|
|||
scalAbsoluteTolerance,
|
||||
scalRelativeTolerance);
|
||||
integ.addStepHandler(new StepHandler() {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast)
|
||||
throws MathUserException {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||
StepInterpolator cloned = interpolator.copy();
|
||||
double tA = cloned.getPreviousTime();
|
||||
double tB = cloned.getCurrentTime();
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
|
@ -296,9 +295,7 @@ public class DormandPrince853IntegratorTest {
|
|||
nbSteps = 0;
|
||||
maxError = 0;
|
||||
}
|
||||
public void handleStep(StepInterpolator interpolator,
|
||||
boolean isLast)
|
||||
throws MathUserException {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||
|
||||
++nbSteps;
|
||||
for (int a = 1; a < 10; ++a) {
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.io.ObjectInputStream;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
|
@ -113,8 +112,7 @@ public class DormandPrince853StepInterpolatorTest {
|
|||
scalAbsoluteTolerance,
|
||||
scalRelativeTolerance);
|
||||
integ.addStepHandler(new StepHandler() {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast)
|
||||
throws MathUserException {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||
StepInterpolator cloned = interpolator.copy();
|
||||
double tA = cloned.getPreviousTime();
|
||||
double tB = cloned.getCurrentTime();
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.io.ObjectInputStream;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
|
@ -56,8 +55,7 @@ public class EulerStepInterpolatorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void interpolationAtBounds()
|
||||
throws MathUserException {
|
||||
public void interpolationAtBounds() {
|
||||
|
||||
double t0 = 0;
|
||||
double[] y0 = {0.0, 1.0, -2.0};
|
||||
|
@ -93,8 +91,7 @@ public class EulerStepInterpolatorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void interpolationInside()
|
||||
throws MathUserException {
|
||||
public void interpolationInside() {
|
||||
|
||||
double[] y = { 1.0, 3.0, -4.0 };
|
||||
double[][] yDot = { { 1.0, 2.0, -2.0 } };
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.commons.math.ode.nonstiff;
|
|||
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
import org.apache.commons.math.ode.TestProblem1;
|
||||
|
@ -183,8 +182,7 @@ public class GillIntegratorTest {
|
|||
public void reset() {
|
||||
maxError = 0;
|
||||
}
|
||||
public void handleStep(StepInterpolator interpolator,
|
||||
boolean isLast) throws MathUserException {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||
|
||||
double[] interpolatedY = interpolator.getInterpolatedState();
|
||||
double[] theoreticalY = pb.computeTheoreticalState(interpolator.getCurrentTime());
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
|
@ -275,7 +274,7 @@ public class GraggBulirschStoerIntegratorTest {
|
|||
|
||||
public void reset() {}
|
||||
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) throws MathUserException {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||
double t = interpolator.getCurrentTime();
|
||||
interpolator.setInterpolatedTime(t);
|
||||
double[] y = interpolator.getInterpolatedState();
|
||||
|
@ -308,9 +307,7 @@ public class GraggBulirschStoerIntegratorTest {
|
|||
nbSteps = 0;
|
||||
maxError = 0;
|
||||
}
|
||||
public void handleStep(StepInterpolator interpolator,
|
||||
boolean isLast)
|
||||
throws MathUserException {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||
|
||||
++nbSteps;
|
||||
for (int a = 1; a < 100; ++a) {
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.io.ObjectInputStream;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
|
@ -115,8 +114,7 @@ public class GraggBulirschStoerStepInterpolatorTest {
|
|||
scalAbsoluteTolerance,
|
||||
scalRelativeTolerance);
|
||||
integ.addStepHandler(new StepHandler() {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast)
|
||||
throws MathUserException {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||
StepInterpolator cloned = interpolator.copy();
|
||||
double tA = cloned.getPreviousTime();
|
||||
double tB = cloned.getCurrentTime();
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math.ode.nonstiff;
|
|||
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.MathIllegalNumberException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
|
@ -43,12 +43,11 @@ public class HighamHall54IntegratorTest {
|
|||
new HighamHall54Integrator(0.0, 1.0, 1.0e-10, 1.0e-10);
|
||||
FirstOrderDifferentialEquations equations =
|
||||
new FirstOrderDifferentialEquations() {
|
||||
public void computeDerivatives(double t, double[] y, double[] dot)
|
||||
throws MathUserException {
|
||||
public void computeDerivatives(double t, double[] y, double[] dot) {
|
||||
if (t < -0.5) {
|
||||
throw new MathUserException(LocalizedFormats.SIMPLE_MESSAGE, "oops");
|
||||
throw new LocalException(t);
|
||||
} else {
|
||||
throw new MathUserException(new RuntimeException("oops"));
|
||||
throw new RuntimeException("oops");
|
||||
}
|
||||
}
|
||||
public int getDimension() {
|
||||
|
@ -59,14 +58,14 @@ public class HighamHall54IntegratorTest {
|
|||
try {
|
||||
integrator.integrate(equations, -1.0, new double[1], 0.0, new double[1]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
} catch(LocalException de) {
|
||||
// expected behavior
|
||||
}
|
||||
|
||||
try {
|
||||
integrator.integrate(equations, 0.0, new double[1], 1.0, new double[1]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
} catch(RuntimeException de) {
|
||||
// expected behavior
|
||||
}
|
||||
|
||||
|
@ -187,8 +186,8 @@ public class HighamHall54IntegratorTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEventsErrors() throws Exception {
|
||||
@Test(expected=LocalException.class)
|
||||
public void testEventsErrors() {
|
||||
|
||||
final TestProblem1 pb = new TestProblem1();
|
||||
double minStep = 0;
|
||||
|
@ -210,7 +209,7 @@ public class HighamHall54IntegratorTest {
|
|||
double middle = (pb.getInitialTime() + pb.getFinalTime()) / 2;
|
||||
double offset = t - middle;
|
||||
if (offset > 0) {
|
||||
throw new MathUserException(LocalizedFormats.EVALUATION_FAILED, t);
|
||||
throw new LocalException(t);
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
@ -218,17 +217,19 @@ public class HighamHall54IntegratorTest {
|
|||
}
|
||||
}, Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000);
|
||||
|
||||
try {
|
||||
integ.integrate(pb,
|
||||
pb.getInitialTime(), pb.getInitialState(),
|
||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch (MathUserException ie) {
|
||||
// expected behavior
|
||||
}
|
||||
integ.integrate(pb,
|
||||
pb.getInitialTime(), pb.getInitialState(),
|
||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||
|
||||
}
|
||||
|
||||
private static class LocalException extends MathIllegalNumberException {
|
||||
private static final long serialVersionUID = 3041292643919807960L;
|
||||
protected LocalException(Number wrong) {
|
||||
super(LocalizedFormats.SIMPLE_MESSAGE, wrong);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEventsNoConvergence() throws Exception {
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.io.ObjectInputStream;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
|
@ -113,8 +112,7 @@ public class HighamHall54StepInterpolatorTest {
|
|||
scalAbsoluteTolerance,
|
||||
scalRelativeTolerance);
|
||||
integ.addStepHandler(new StepHandler() {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast)
|
||||
throws MathUserException {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||
StepInterpolator cloned = interpolator.copy();
|
||||
double tA = cloned.getPreviousTime();
|
||||
double tB = cloned.getCurrentTime();
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.commons.math.ode.nonstiff;
|
|||
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
import org.apache.commons.math.ode.TestProblem1;
|
||||
|
@ -175,8 +174,7 @@ public class ThreeEighthesIntegratorTest {
|
|||
maxError = 0;
|
||||
}
|
||||
|
||||
public void handleStep(StepInterpolator interpolator,
|
||||
boolean isLast) throws MathUserException {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||
|
||||
double[] interpolatedY = interpolator.getInterpolatedState();
|
||||
double[] theoreticalY = pb.computeTheoreticalState(interpolator.getCurrentTime());
|
||||
|
|
|
@ -18,16 +18,14 @@
|
|||
package org.apache.commons.math.ode.sampling;
|
||||
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
|
||||
import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -35,7 +33,7 @@ import org.junit.Test;
|
|||
public class DummyStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void testNoReset() throws MathUserException {
|
||||
public void testNoReset() {
|
||||
|
||||
double[] y = { 0.0, 1.0, -2.0 };
|
||||
DummyStepInterpolator interpolator = new DummyStepInterpolator(y, new double[y.length], true);
|
||||
|
@ -51,8 +49,7 @@ public class DummyStepInterpolatorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFixedState()
|
||||
throws MathUserException {
|
||||
public void testFixedState() {
|
||||
|
||||
double[] y = { 1.0, 3.0, -4.0 };
|
||||
DummyStepInterpolator interpolator = new DummyStepInterpolator(y, new double[y.length], true);
|
||||
|
@ -76,7 +73,7 @@ public class DummyStepInterpolatorTest {
|
|||
|
||||
@Test
|
||||
public void testSerialization()
|
||||
throws MathUserException, IOException, ClassNotFoundException {
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
double[] y = { 0.0, 1.0, -2.0 };
|
||||
DummyStepInterpolator interpolator = new DummyStepInterpolator(y, new double[y.length], true);
|
||||
|
@ -132,8 +129,8 @@ public class DummyStepInterpolatorTest {
|
|||
super(y, new double[y.length], forward);
|
||||
}
|
||||
@Override
|
||||
protected void doFinalize() throws MathUserException {
|
||||
throw new MathUserException(LocalizedFormats.SIMPLE_MESSAGE, "");
|
||||
protected void doFinalize() {
|
||||
throw new MathIllegalStateException(LocalizedFormats.SIMPLE_MESSAGE, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.apache.commons.math.ode.sampling;
|
||||
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
import org.apache.commons.math.ode.TestProblemAbstract;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
@ -30,8 +29,7 @@ public class StepInterpolatorTestUtils {
|
|||
final double threshold) {
|
||||
integrator.addStepHandler(new StepHandler() {
|
||||
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast)
|
||||
throws MathUserException {
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||
|
||||
final double h = 0.001 * (interpolator.getCurrentTime() - interpolator.getPreviousTime());
|
||||
final double t = interpolator.getCurrentTime() - 300 * h;
|
||||
|
|
|
@ -5,7 +5,6 @@ import static org.junit.Assert.assertArrayEquals;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
import org.apache.commons.math.ode.nonstiff.GraggBulirschStoerIntegrator;
|
||||
|
@ -208,14 +207,12 @@ public abstract class StepNormalizerOutputTestBase
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void computeDerivatives(double t, double[] y, double[] yDot)
|
||||
throws MathUserException {
|
||||
public void computeDerivatives(double t, double[] y, double[] yDot) {
|
||||
yDot[0] = y[0];
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void handleStep(double t, double[] y, double[] yDot, boolean isLast)
|
||||
throws MathUserException {
|
||||
public void handleStep(double t, double[] y, double[] yDot, boolean isLast) {
|
||||
output.add(t);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue