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 2008/06/23 10:01:55 UTC
svn commit: r670469 [4/8] - in /commons/proper/math/branches/MATH_2_0/src:
experimental/org/apache/commons/math/analysis/
experimental/org/apache/commons/math/analysis/derivative/
experimental/org/apache/commons/math/function/ experimental/org/apache/c...
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/GraggBulirschStoerIntegrator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/GraggBulirschStoerIntegrator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/GraggBulirschStoerIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,16 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
+
+import org.apache.commons.math.ode.AdaptiveStepsizeIntegrator;
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
+import org.apache.commons.math.ode.IntegratorException;
+import org.apache.commons.math.ode.events.EventHandler;
+import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
+import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
+import org.apache.commons.math.ode.sampling.StepHandler;
/**
* This class implements a Gragg-Bulirsch-Stoer integrator for
@@ -104,11 +113,11 @@
* @param scalAbsoluteTolerance allowed absolute error
* @param scalRelativeTolerance allowed relative error
*/
- public GraggBulirschStoerIntegrator(double minStep, double maxStep,
- double scalAbsoluteTolerance,
- double scalRelativeTolerance) {
+ public GraggBulirschStoerIntegrator(final double minStep, final double maxStep,
+ final double scalAbsoluteTolerance,
+ final double scalRelativeTolerance) {
super(minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
- denseOutput = (handler.requiresDenseOutput() || (! switchesHandler.isEmpty()));
+ denseOutput = (handler.requiresDenseOutput() || (! eventsHandlersManager.isEmpty()));
setStabilityCheck(true, -1, -1, -1);
setStepsizeControl(-1, -1, -1, -1);
setOrderControl(-1, -1, -1);
@@ -126,11 +135,11 @@
* @param vecAbsoluteTolerance allowed absolute error
* @param vecRelativeTolerance allowed relative error
*/
- public GraggBulirschStoerIntegrator(double minStep, double maxStep,
- double[] vecAbsoluteTolerance,
- double[] vecRelativeTolerance) {
+ public GraggBulirschStoerIntegrator(final double minStep, final double maxStep,
+ final double[] vecAbsoluteTolerance,
+ final double[] vecRelativeTolerance) {
super(minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
- denseOutput = (handler.requiresDenseOutput() || (! switchesHandler.isEmpty()));
+ denseOutput = (handler.requiresDenseOutput() || (! eventsHandlersManager.isEmpty()));
setStabilityCheck(true, -1, -1, -1);
setStepsizeControl(-1, -1, -1, -1);
setOrderControl(-1, -1, -1);
@@ -155,9 +164,9 @@
* failure (the factor is reset to default if lower than 0.0001 or
* greater than 0.9999)
*/
- public void setStabilityCheck(boolean performTest,
- int maxIter, int maxChecks,
- double stabilityReduction) {
+ public void setStabilityCheck(final boolean performTest,
+ final int maxIter, final int maxChecks,
+ final double stabilityReduction) {
this.performTest = performTest;
this.maxIter = (maxIter <= 0) ? 2 : maxIter;
@@ -195,8 +204,8 @@
* @param stepControl4 fourth stepsize control factor (the factor
* is reset to default if lower than 1.0001 or greater than 999.9)
*/
- public void setStepsizeControl(double stepControl1, double stepControl2,
- double stepControl3, double stepControl4) {
+ public void setStepsizeControl(final double stepControl1, final double stepControl2,
+ final double stepControl3, final double stepControl4) {
if ((stepControl1 < 0.0001) || (stepControl1 > 0.9999)) {
this.stepControl1 = 0.65;
@@ -247,8 +256,8 @@
* @param orderControl2 second order control factor (the factor
* is reset to default if lower than 0.0001 or greater than 0.9999)
*/
- public void setOrderControl(int maxOrder,
- double orderControl1, double orderControl2) {
+ public void setOrderControl(final int maxOrder,
+ final double orderControl1, final double orderControl2) {
if ((maxOrder <= 6) || (maxOrder % 2 != 0)) {
this.maxOrder = 18;
@@ -276,31 +285,23 @@
* step.
* @param handler handler for the accepted steps
*/
- public void setStepHandler (StepHandler handler) {
+ public void setStepHandler (final StepHandler handler) {
super.setStepHandler(handler);
- denseOutput = (handler.requiresDenseOutput() || (! switchesHandler.isEmpty()));
+ denseOutput = (handler.requiresDenseOutput() || (! eventsHandlersManager.isEmpty()));
// reinitialize the arrays
initializeArrays();
}
- /** Add a switching function to the integrator.
- * @param function switching function
- * @param maxCheckInterval maximal time interval between switching
- * function checks (this interval prevents missing sign changes in
- * case the integration steps becomes very large)
- * @param convergence convergence threshold in the event time search
- * @param maxIterationCount upper limit of the iteration count in
- * the event time search
- */
- public void addSwitchingFunction(SwitchingFunction function,
- double maxCheckInterval,
- double convergence,
- int maxIterationCount) {
- super.addSwitchingFunction(function, maxCheckInterval, convergence, maxIterationCount);
- denseOutput = (handler.requiresDenseOutput() || (! switchesHandler.isEmpty()));
+ /** {@inheritDoc} */
+ public void addEventHandler(final EventHandler function,
+ final double maxCheckInterval,
+ final double convergence,
+ final int maxIterationCount) {
+ super.addEventHandler(function, maxCheckInterval, convergence, maxIterationCount);
+ denseOutput = (handler.requiresDenseOutput() || (! eventsHandlersManager.isEmpty()));
// reinitialize the arrays
initializeArrays();
@@ -310,7 +311,7 @@
/** Initialize the integrator internal arrays. */
private void initializeArrays() {
- int size = maxOrder / 2;
+ final int size = maxOrder / 2;
if ((sequence == null) || (sequence.length != size)) {
// all arrays should be reallocated with the right size
@@ -344,7 +345,7 @@
for (int k = 0; k < size; ++k) {
coeff[k] = (k > 0) ? new double[k] : null;
for (int l = 0; l < k; ++l) {
- double ratio = ((double) sequence[k]) / sequence[k-l-1];
+ final double ratio = ((double) sequence[k]) / sequence[k-l-1];
coeff[k][l] = 1.0 / (ratio * ratio - 1.0);
}
}
@@ -361,8 +362,8 @@
* @param mudif interpolation order control parameter (the parameter
* is reset to default if <= 0 or >= 7)
*/
- public void setInterpolationControl(boolean useInterpolationError,
- int mudif) {
+ public void setInterpolationControl(final boolean useInterpolationError,
+ final int mudif) {
this.useInterpolationError = useInterpolationError;
@@ -374,9 +375,7 @@
}
- /** Get the name of the method.
- * @return name of the method
- */
+ /** {@inheritDoc} */
public String getName() {
return methodName;
}
@@ -386,15 +385,15 @@
* @param y2 second state vector to use for scaling
* @param scale scaling array to update
*/
- private void rescale(double[] y1, double[] y2, double[] scale) {
+ private void rescale(final double[] y1, final double[] y2, final double[] scale) {
if (vecAbsoluteTolerance == null) {
for (int i = 0; i < scale.length; ++i) {
- double yi = Math.max(Math.abs(y1[i]), Math.abs(y2[i]));
+ final double yi = Math.max(Math.abs(y1[i]), Math.abs(y2[i]));
scale[i] = scalAbsoluteTolerance + scalRelativeTolerance * yi;
}
} else {
for (int i = 0; i < scale.length; ++i) {
- double yi = Math.max(Math.abs(y1[i]), Math.abs(y2[i]));
+ final double yi = Math.max(Math.abs(y1[i]), Math.abs(y2[i]));
scale[i] = vecAbsoluteTolerance[i] + vecRelativeTolerance[i] * yi;
}
}
@@ -418,16 +417,16 @@
* @throws DerivativeException this exception is propagated to the caller if the
* underlying user function triggers one
*/
- private boolean tryStep(FirstOrderDifferentialEquations equations,
- double t0, double[] y0, double step, int k,
- double[] scale, double[][] f,
- double[] yMiddle, double[] yEnd,
- double[] yTmp)
+ private boolean tryStep(final FirstOrderDifferentialEquations equations,
+ 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 DerivativeException {
- int n = sequence[k];
- double subStep = step / n;
- double subStep2 = 2 * subStep;
+ final int n = sequence[k];
+ final double subStep = step / n;
+ final double subStep2 = 2 * subStep;
// first substep
double t = t0 + subStep;
@@ -447,7 +446,7 @@
t += subStep;
for (int i = 0; i < y0.length; ++i) {
- double middle = yEnd[i];
+ final double middle = yEnd[i];
yEnd[i] = yTmp[i] + subStep2 * f[j][i];
yTmp[i] = middle;
}
@@ -458,12 +457,12 @@
if (performTest && (j <= maxChecks) && (k < maxIter)) {
double initialNorm = 0.0;
for (int l = 0; l < y0.length; ++l) {
- double ratio = f[0][l] / scale[l];
+ final double ratio = f[0][l] / scale[l];
initialNorm += ratio * ratio;
}
double deltaNorm = 0.0;
for (int l = 0; l < y0.length; ++l) {
- double ratio = (f[j+1][l] - f[0][l]) / scale[l];
+ final double ratio = (f[j+1][l] - f[0][l]) / scale[l];
deltaNorm += ratio * ratio;
}
if (deltaNorm > 4 * Math.max(1.0e-15, initialNorm)) {
@@ -489,7 +488,8 @@
* triangle, without the last element
* @param last last element
*/
- private void extrapolate(int offset, int k, double[][] diag, double[] last) {
+ private void extrapolate(final int offset, final int k,
+ final double[][] diag, final double[] last) {
// update the diagonal
for (int j = 1; j < k; ++j) {
@@ -507,43 +507,28 @@
}
}
- /** Integrate the differential equations up to the given time.
- * <p>This method solves an Initial Value Problem (IVP).</p>
- * <p>Since this method stores some internal state variables made
- * available in its public interface during integration ({@link
- * #getCurrentSignedStepsize()}), it is <em>not</em> thread-safe.</p>
- * @param equations differential equations to integrate
- * @param t0 initial time
- * @param y0 initial value of the state vector at t0
- * @param t target time for the integration
- * (can be set to a value smaller than <code>t0</code> for backward integration)
- * @param y placeholder where to put the state vector at each successful
- * step (and hence at the end of integration), can be the same object as y0
- * @throws IntegratorException if the integrator cannot perform integration
- * @throws DerivativeException this exception is propagated to the caller if
- * the underlying user function triggers one
- */
- public void integrate(FirstOrderDifferentialEquations equations,
- double t0, double[] y0, double t, double[] y)
+ /** {@inheritDoc} */
+ public void integrate(final FirstOrderDifferentialEquations equations,
+ final double t0, final double[] y0, final double t, final double[] y)
throws DerivativeException, IntegratorException {
sanityChecks(equations, t0, y0, t, y);
- boolean forward = (t > t0);
+ final boolean forward = (t > t0);
// create some internal working arrays
- double[] yDot0 = new double[y0.length];
- double[] y1 = new double[y0.length];
- double[] yTmp = new double[y0.length];
- double[] yTmpDot = new double[y0.length];
+ final double[] yDot0 = new double[y0.length];
+ final double[] y1 = new double[y0.length];
+ final double[] yTmp = new double[y0.length];
+ final double[] yTmpDot = new double[y0.length];
- double[][] diagonal = new double[sequence.length-1][];
- double[][] y1Diag = new double[sequence.length-1][];
+ final double[][] diagonal = new double[sequence.length-1][];
+ final double[][] y1Diag = new double[sequence.length-1][];
for (int k = 0; k < sequence.length-1; ++k) {
diagonal[k] = new double[y0.length];
y1Diag[k] = new double[y0.length];
}
- double[][][] fk = new double[sequence.length][][];
+ final double[][][] fk = new double[sequence.length][][];
for (int k = 0; k < sequence.length; ++k) {
fk[k] = new double[sequence[k] + 1][];
@@ -575,19 +560,19 @@
}
// initial scaling
- double[] scale = new double[y0.length];
+ final double[] scale = new double[y0.length];
rescale(y, y, scale);
// initial order selection
- double tol =
+ final double tol =
(vecRelativeTolerance == null) ? scalRelativeTolerance : vecRelativeTolerance[0];
- double log10R = Math.log(Math.max(1.0e-10, tol)) / Math.log(10.0);
+ final double log10R = Math.log(Math.max(1.0e-10, tol)) / Math.log(10.0);
int targetIter = Math.max(1,
Math.min(sequence.length - 2,
(int) Math.floor(0.5 - 0.6 * log10R)));
// set up an interpolator sharing the integrator arrays
AbstractStepInterpolator interpolator = null;
- if (denseOutput || (! switchesHandler.isEmpty())) {
+ if (denseOutput || (! eventsHandlersManager.isEmpty())) {
interpolator = new GraggBulirschStoerStepInterpolator(y, yDot0,
y1, yDot1,
yMidDots, forward);
@@ -643,7 +628,7 @@
((! forward) && (stepStart + stepSize < t))) {
stepSize = t - stepStart;
}
- double nextT = stepStart + stepSize;
+ final double nextT = stepStart + stepSize;
lastStep = forward ? (nextT >= t) : (nextT <= t);
// iterate over several substep sizes
@@ -676,7 +661,7 @@
// estimate the error at the end of the step.
error = 0;
for (int j = 0; j < y0.length; ++j) {
- double e = Math.abs(y1[j] - y1Diag[0][j]) / scale[j];
+ final double e = Math.abs(y1[j] - y1Diag[0][j]) / scale[j];
error += e * e;
}
error = Math.sqrt(error / y0.length);
@@ -691,9 +676,9 @@
maxError = Math.max(4 * error, 1.0);
// compute optimal stepsize for this order
- double exp = 1.0 / (2 * k + 1);
+ final double exp = 1.0 / (2 * k + 1);
double fac = stepControl2 / Math.pow(error / stepControl1, exp);
- double pow = Math.pow(stepControl3, exp);
+ final double pow = Math.pow(stepControl3, exp);
fac = Math.max(pow / stepControl4, Math.min(1 / pow, fac));
optimalStep[k] = Math.abs(filterStep(stepSize * fac, true));
costPerTimeUnit[k] = costPerStep[k] / optimalStep[k];
@@ -712,8 +697,8 @@
// estimate if there is a chance convergence will
// be reached on next iteration, using the
// asymptotic evolution of error
- double ratio = ((double) sequence [k] * sequence[k+1]) /
- (sequence[0] * sequence[0]);
+ final double ratio = ((double) sequence [k] * sequence[k+1]) /
+ (sequence[0] * sequence[0]);
if (error > ratio * ratio) {
// we don't expect to converge on next iteration
// we reject the step immediately and reduce order
@@ -739,7 +724,7 @@
// estimate if there is a chance convergence will
// be reached on next iteration, using the
// asymptotic evolution of error
- double ratio = ((double) sequence[k+1]) / sequence[0];
+ final double ratio = ((double) sequence[k+1]) / sequence[0];
if (error > ratio * ratio) {
// we don't expect to converge on next iteration
// we reject the step immediately
@@ -793,12 +778,12 @@
// derivative at end of step
equations.computeDerivatives(stepStart + stepSize, y1, yDot1);
- int mu = 2 * k - mudif + 3;
+ final int mu = 2 * k - mudif + 3;
for (int l = 0; l < mu; ++l) {
// derivative at middle point of the step
- int l2 = l / 2;
+ final int l2 = l / 2;
double factor = Math.pow(0.5 * sequence[l2], l);
int middleIndex = fk[l2].length / 2;
for (int i = 0; i < y0.length; ++i) {
@@ -830,13 +815,13 @@
if (mu >= 0) {
// estimate the dense output coefficients
- GraggBulirschStoerStepInterpolator gbsInterpolator
+ final GraggBulirschStoerStepInterpolator gbsInterpolator
= (GraggBulirschStoerStepInterpolator) interpolator;
gbsInterpolator.computeCoefficients(mu, stepSize);
if (useInterpolationError) {
// use the interpolation error to limit stepsize
- double interpError = gbsInterpolator.estimateError(scale);
+ final double interpError = gbsInterpolator.estimateError(scale);
hInt = Math.abs(stepSize / Math.max(Math.pow(interpError, 1.0 / (mu+4)),
0.01));
if (interpError > 10.0) {
@@ -845,12 +830,12 @@
}
}
- // Switching functions handling
+ // Discrete events handling
if (!reject) {
interpolator.storeTime(stepStart + stepSize);
- if (switchesHandler.evaluateStep(interpolator)) {
+ if (eventsHandlersManager.evaluateStep(interpolator)) {
reject = true;
- hNew = Math.abs(switchesHandler.getEventTime() - stepStart);
+ hNew = Math.abs(eventsHandlersManager.getEventTime() - stepStart);
}
}
@@ -867,11 +852,11 @@
if (! reject) {
// store end of step state
- double nextStep = stepStart + stepSize;
+ final double nextStep = stepStart + stepSize;
System.arraycopy(y1, 0, y, 0, y0.length);
- switchesHandler.stepAccepted(nextStep, y);
- if (switchesHandler.stop()) {
+ eventsHandlersManager.stepAccepted(nextStep, y);
+ if (eventsHandlersManager.stop()) {
lastStep = true;
}
@@ -880,7 +865,7 @@
handler.handleStep(interpolator, lastStep);
stepStart = nextStep;
- if (switchesHandler.reset(stepStart, y) && ! lastStep) {
+ if (eventsHandlersManager.reset(stepStart, y) && ! lastStep) {
// some switching function has triggered changes that
// invalidate the derivatives, we need to recompute them
firstStepAlreadyComputed = false;
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/GraggBulirschStoerStepInterpolator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/GraggBulirschStoerStepInterpolator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/GraggBulirschStoerStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java Mon Jun 23 01:01:38 2008
@@ -15,12 +15,16 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.IOException;
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
+import org.apache.commons.math.ode.sampling.StepInterpolator;
+
/**
* This class implements an interpolator for the Gragg-Bulirsch-Stoer
* integrator.
@@ -102,7 +106,7 @@
* interpolation polynoms up to the given degree
* @param maxDegree maximal degree to handle
*/
- private void resetTables(int maxDegree) {
+ private void resetTables(final int maxDegree) {
if (maxDegree < 0) {
polynoms = null;
@@ -110,7 +114,7 @@
currentDegree = -1;
} else {
- double[][] newPols = new double[maxDegree + 1][];
+ final double[][] newPols = new double[maxDegree + 1][];
if (polynoms != null) {
System.arraycopy(polynoms, 0, newPols, 0, polynoms.length);
for (int i = polynoms.length; i < newPols.length; ++i) {
@@ -129,9 +133,9 @@
} else {
errfac = new double[maxDegree - 4];
for (int i = 0; i < errfac.length; ++i) {
- int ip5 = i + 5;
+ final int ip5 = i + 5;
errfac[i] = 1.0 / (ip5 * ip5);
- double e = 0.5 * Math.sqrt (((double) (i + 1)) / ip5);
+ final double e = 0.5 * Math.sqrt (((double) (i + 1)) / ip5);
for (int j = 0; j <= i; ++j) {
errfac[i] *= e / (j + 1);
}
@@ -168,10 +172,10 @@
* derivatives at the middle point of the step
* @param forward integration direction indicator
*/
- public GraggBulirschStoerStepInterpolator(double[] y, double[] y0Dot,
- double[] y1, double[] y1Dot,
- double[][] yMidDots,
- boolean forward) {
+ public GraggBulirschStoerStepInterpolator(final double[] y, final double[] y0Dot,
+ final double[] y1, final double[] y1Dot,
+ final double[][] yMidDots,
+ final boolean forward) {
super(y, forward);
this.y0Dot = y0Dot;
@@ -189,11 +193,11 @@
* instance
*/
public GraggBulirschStoerStepInterpolator
- (GraggBulirschStoerStepInterpolator interpolator) {
+ (final GraggBulirschStoerStepInterpolator interpolator) {
super(interpolator);
- int dimension = currentState.length;
+ final int dimension = currentState.length;
// the interpolator has been finalized,
// the following arrays are not needed anymore
@@ -218,9 +222,7 @@
}
- /** Really copy the finalized instance.
- * @return a copy of the finalized instance
- */
+ /** {@inheritDoc} */
protected StepInterpolator doCopy() {
return new GraggBulirschStoerStepInterpolator(this);
}
@@ -230,7 +232,7 @@
* @param mu degree of the interpolation polynom
* @param h current step
*/
- public void computeCoefficients(int mu, double h) {
+ public void computeCoefficients(final int mu, final double h) {
if ((polynoms == null) || (polynoms.length <= (mu + 4))) {
resetTables(mu + 4);
@@ -240,11 +242,11 @@
for (int i = 0; i < currentState.length; ++i) {
- double yp0 = h * y0Dot[i];
- double yp1 = h * y1Dot[i];
- double ydiff = y1[i] - currentState[i];
- double aspl = ydiff - yp1;
- double bspl = yp0 - ydiff;
+ final double yp0 = h * y0Dot[i];
+ final double yp1 = h * y1Dot[i];
+ final double ydiff = y1[i] - currentState[i];
+ final double aspl = ydiff - yp1;
+ final double bspl = yp0 - ydiff;
polynoms[0][i] = currentState[i];
polynoms[1][i] = ydiff;
@@ -256,24 +258,24 @@
}
// compute the remaining coefficients
- double ph0 = 0.5 * (currentState[i] + y1[i]) + 0.125 * (aspl + bspl);
+ final double ph0 = 0.5 * (currentState[i] + y1[i]) + 0.125 * (aspl + bspl);
polynoms[4][i] = 16 * (yMidDots[0][i] - ph0);
if (mu > 0) {
- double ph1 = ydiff + 0.25 * (aspl - bspl);
+ final double ph1 = ydiff + 0.25 * (aspl - bspl);
polynoms[5][i] = 16 * (yMidDots[1][i] - ph1);
if (mu > 1) {
- double ph2 = yp1 - yp0;
+ final double ph2 = yp1 - yp0;
polynoms[6][i] = 16 * (yMidDots[2][i] - ph2 + polynoms[4][i]);
if (mu > 2) {
- double ph3 = 6 * (bspl - aspl);
+ final double ph3 = 6 * (bspl - aspl);
polynoms[7][i] = 16 * (yMidDots[3][i] - ph3 + 3 * polynoms[5][i]);
for (int j = 4; j <= mu; ++j) {
- double fac1 = 0.5 * j * (j - 1);
- double fac2 = 2 * fac1 * (j - 2) * (j - 3);
+ final double fac1 = 0.5 * j * (j - 1);
+ final double fac2 = 2 * fac1 * (j - 2) * (j - 3);
polynoms[j+4][i] =
16 * (yMidDots[j][i] + fac1 * polynoms[j+2][i] - fac2 * polynoms[j][i]);
}
@@ -289,11 +291,11 @@
* @param scale scaling array
* @return estimate of the interpolation error
*/
- public double estimateError(double[] scale) {
+ public double estimateError(final double[] scale) {
double error = 0;
if (currentDegree >= 5) {
for (int i = 0; i < currentState.length; ++i) {
- double e = polynoms[currentDegree][i] / scale[i];
+ final double e = polynoms[currentDegree][i] / scale[i];
error += e * e;
}
error = Math.sqrt(error / currentState.length) * errfac[currentDegree-5];
@@ -301,25 +303,16 @@
return error;
}
- /** Compute the state at the interpolated time.
- * This is the main processing method that should be implemented by
- * the derived classes to perform the interpolation.
- * @param theta normalized interpolation abscissa within the step
- * (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 DerivativeException this exception is propagated to the caller if the
- * underlying user function triggers one
- */
- protected void computeInterpolatedState(double theta,
- double oneMinusThetaH)
+ /** {@inheritDoc} */
+ protected void computeInterpolatedState(final double theta,
+ final double oneMinusThetaH)
throws DerivativeException {
- int dimension = currentState.length;
+ final int dimension = currentState.length;
- double oneMinusTheta = 1.0 - theta;
- double theta05 = theta - 0.5;
- double t4 = theta * oneMinusTheta;
+ final double oneMinusTheta = 1.0 - theta;
+ final double theta05 = theta - 0.5;
+ double t4 = theta * oneMinusTheta;
t4 = t4 * t4;
for (int i = 0; i < dimension; ++i) {
@@ -339,14 +332,11 @@
}
- /** Save the state of the instance.
- * @param out stream where to save the state
- * @exception IOException in case of write error
- */
- public void writeExternal(ObjectOutput out)
+ /** {@inheritDoc} */
+ public void writeExternal(final ObjectOutput out)
throws IOException {
- int dimension = currentState.length;
+ final int dimension = currentState.length;
// save the state of the base class
writeBaseExternal(out);
@@ -361,19 +351,16 @@
}
- /** Read the state of the instance.
- * @param in stream where to read the state from
- * @exception IOException in case of read error
- */
- public void readExternal(ObjectInput in)
+ /** {@inheritDoc} */
+ public void readExternal(final ObjectInput in)
throws IOException {
// read the base class
- double t = readBaseExternal(in);
- int dimension = currentState.length;
+ final double t = readBaseExternal(in);
+ final int dimension = currentState.length;
// read the local attributes
- int degree = in.readInt();
+ final int degree = in.readInt();
resetTables(degree);
currentDegree = degree;
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54Integrator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/HighamHall54Integrator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54Integrator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54Integrator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/HighamHall54Integrator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/HighamHall54Integrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54Integrator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
/**
* This class implements the 5(4) Higham and Hall integrator for
@@ -74,9 +74,9 @@
* @param scalAbsoluteTolerance allowed absolute error
* @param scalRelativeTolerance allowed relative error
*/
- public HighamHall54Integrator(double minStep, double maxStep,
- double scalAbsoluteTolerance,
- double scalRelativeTolerance) {
+ public HighamHall54Integrator(final double minStep, final double maxStep,
+ final double scalAbsoluteTolerance,
+ final double scalRelativeTolerance) {
super(false, staticC, staticA, staticB, new HighamHall54StepInterpolator(),
minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
}
@@ -90,37 +90,27 @@
* @param vecAbsoluteTolerance allowed absolute error
* @param vecRelativeTolerance allowed relative error
*/
- public HighamHall54Integrator(double minStep, double maxStep,
- double[] vecAbsoluteTolerance,
- double[] vecRelativeTolerance) {
+ public HighamHall54Integrator(final double minStep, final double maxStep,
+ final double[] vecAbsoluteTolerance,
+ final double[] vecRelativeTolerance) {
super(false, staticC, staticA, staticB, new HighamHall54StepInterpolator(),
minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
}
- /** Get the name of the method.
- * @return name of the method
- */
+ /** {@inheritDoc} */
public String getName() {
return methodName;
}
- /** Get the order of the method.
- * @return order of the method
- */
+ /** {@inheritDoc} */
public int getOrder() {
return 5;
}
- /** Compute the error ratio.
- * @param yDotK derivatives computed during the first stages
- * @param y0 estimate of the step at the start of the step
- * @param y1 estimate of the step at the end of the step
- * @param h current step
- * @return error ratio, greater than 1 if step should be rejected
- */
- protected double estimateError(double[][] yDotK,
- double[] y0, double[] y1,
- double h) {
+ /** {@inheritDoc} */
+ protected double estimateError(final double[][] yDotK,
+ final double[] y0, final double[] y1,
+ final double h) {
double error = 0;
@@ -130,11 +120,11 @@
errSum += staticE[l] * yDotK[l][j];
}
- double yScale = Math.max(Math.abs(y0[j]), Math.abs(y1[j]));
- double tol = (vecAbsoluteTolerance == null) ?
- (scalAbsoluteTolerance + scalRelativeTolerance * yScale) :
- (vecAbsoluteTolerance[j] + vecRelativeTolerance[j] * yScale);
- double ratio = h * errSum / tol;
+ final double yScale = Math.max(Math.abs(y0[j]), Math.abs(y1[j]));
+ final double tol = (vecAbsoluteTolerance == null) ?
+ (scalAbsoluteTolerance + scalRelativeTolerance * yScale) :
+ (vecAbsoluteTolerance[j] + vecRelativeTolerance[j] * yScale);
+ final double ratio = h * errSum / tol;
error += ratio * ratio;
}
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54Integrator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54Integrator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/HighamHall54StepInterpolator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/HighamHall54StepInterpolator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/HighamHall54StepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,11 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
+
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
+import org.apache.commons.math.ode.sampling.StepInterpolator;
/**
* This class represents an interpolator over the last step during an
@@ -48,37 +52,28 @@
* copy: its arrays are separated from the original arrays of the
* instance
*/
- public HighamHall54StepInterpolator(HighamHall54StepInterpolator interpolator) {
+ public HighamHall54StepInterpolator(final HighamHall54StepInterpolator interpolator) {
super(interpolator);
}
- /** Really copy the finalized instance.
- * @return a copy of the finalized instance
- */
+ /** {@inheritDoc} */
protected StepInterpolator doCopy() {
return new HighamHall54StepInterpolator(this);
}
- /** Compute the state at the interpolated time.
- * @param theta normalized interpolation abscissa within the step
- * (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 DerivativeException this exception is propagated to the caller if the
- * underlying user function triggers one
- */
- protected void computeInterpolatedState(double theta,
- double oneMinusThetaH)
+ /** {@inheritDoc} */
+ protected void computeInterpolatedState(final double theta,
+ final double oneMinusThetaH)
throws DerivativeException {
- double theta2 = theta * theta;
+ final double theta2 = theta * theta;
- double b0 = h * (-1.0/12.0 + theta * (1.0 + theta * (-15.0/4.0 + theta * (16.0/3.0 + theta * -5.0/2.0))));
- double b2 = h * (-27.0/32.0 + theta2 * (459.0/32.0 + theta * (-243.0/8.0 + theta * 135.0/8.0)));
- double b3 = h * (4.0/3.0 + theta2 * (-22.0 + theta * (152.0/3.0 + theta * -30.0)));
- double b4 = h * (-125.0/96.0 + theta2 * (375.0/32.0 + theta * (-625.0/24.0 + theta * 125.0/8.0)));
- double b5 = h * (-5.0/48.0 + theta2 * (-5.0/16.0 + theta * 5.0/12.0));
+ final double b0 = h * (-1.0/12.0 + theta * (1.0 + theta * (-15.0/4.0 + theta * (16.0/3.0 + theta * -5.0/2.0))));
+ final double b2 = h * (-27.0/32.0 + theta2 * (459.0/32.0 + theta * (-243.0/8.0 + theta * 135.0/8.0)));
+ final double b3 = h * (4.0/3.0 + theta2 * (-22.0 + theta * (152.0/3.0 + theta * -30.0)));
+ final double b4 = h * (-125.0/96.0 + theta2 * (375.0/32.0 + theta * (-625.0/24.0 + theta * 125.0/8.0)));
+ final double b5 = h * (-5.0/48.0 + theta2 * (-5.0/16.0 + theta * 5.0/12.0));
for (int i = 0; i < interpolatedState.length; ++i) {
interpolatedState[i] = currentState[i] +
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointIntegrator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/MidpointIntegrator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointIntegrator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointIntegrator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/MidpointIntegrator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/MidpointIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointIntegrator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
/**
* This class implements a second order Runge-Kutta integrator for
@@ -67,13 +67,11 @@
* Build a midpoint integrator with the given step.
* @param step integration step
*/
- public MidpointIntegrator(double step) {
+ public MidpointIntegrator(final double step) {
super(c, a, b, new MidpointStepInterpolator(), step);
}
- /** Get the name of the method.
- * @return name of the method
- */
+ /** {@inheritDoc} */
public String getName() {
return methodName;
}
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointIntegrator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointIntegrator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/MidpointStepInterpolator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/MidpointStepInterpolator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/MidpointStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,11 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
+
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
+import org.apache.commons.math.ode.sampling.StepInterpolator;
/**
* This class implements a step interpolator for second order
@@ -58,34 +62,23 @@
* copy: its arrays are separated from the original arrays of the
* instance
*/
- public MidpointStepInterpolator(MidpointStepInterpolator interpolator) {
+ public MidpointStepInterpolator(final MidpointStepInterpolator interpolator) {
super(interpolator);
}
- /** Really copy the finalized instance.
- * @return a copy of the finalized instance
- */
+ /** {@inheritDoc} */
protected StepInterpolator doCopy() {
return new MidpointStepInterpolator(this);
}
- /** Compute the state at the interpolated time.
- * This is the main processing method that should be implemented by
- * the derived classes to perform the interpolation.
- * @param theta normalized interpolation abscissa within the step
- * (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 DerivativeException this exception is propagated to the caller if the
- * underlying user function triggers one
- */
- protected void computeInterpolatedState(double theta,
- double oneMinusThetaH)
+ /** {@inheritDoc} */
+ protected void computeInterpolatedState(final double theta,
+ final double oneMinusThetaH)
throws DerivativeException {
- double coeff1 = oneMinusThetaH * theta;
- double coeff2 = oneMinusThetaH * (1.0 + theta);
+ final double coeff1 = oneMinusThetaH * theta;
+ final double coeff2 = oneMinusThetaH * (1.0 + theta);
for (int i = 0; i < interpolatedState.length; ++i) {
interpolatedState[i] = currentState[i] +
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointStepInterpolator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java (from r669851, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java&r1=669851&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java Mon Jun 23 01:01:38 2008
@@ -15,10 +15,21 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
import java.util.Collection;
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
+import org.apache.commons.math.ode.FirstOrderIntegrator;
+import org.apache.commons.math.ode.IntegratorException;
+import org.apache.commons.math.ode.events.EventHandler;
+import org.apache.commons.math.ode.events.CombinedEventsManager;
+import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
+import org.apache.commons.math.ode.sampling.DummyStepHandler;
+import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
+import org.apache.commons.math.ode.sampling.StepHandler;
+
/**
* This class implements the common part of all fixed step Runge-Kutta
* integrators for Ordinary Differential Equations.
@@ -56,73 +67,48 @@
* @param prototype prototype of the step interpolator to use
* @param step integration step
*/
- protected RungeKuttaIntegrator(double[] c, double[][] a, double[] b,
- RungeKuttaStepInterpolator prototype,
- double step) {
+ protected RungeKuttaIntegrator(final double[] c, final double[][] a, final double[] b,
+ final RungeKuttaStepInterpolator prototype,
+ final double step) {
this.c = c;
this.a = a;
this.b = b;
this.prototype = prototype;
this.step = step;
handler = DummyStepHandler.getInstance();
- switchesHandler = new SwitchingFunctionsHandler();
+ eventsHandlersManager = new CombinedEventsManager();
resetInternalState();
}
- /** Get the name of the method.
- * @return name of the method
- */
+ /** {@inheritDoc} */
public abstract String getName();
- /** Set the step handler for this integrator.
- * The handler will be called by the integrator for each accepted
- * step.
- * @param handler handler for the accepted steps
- */
- public void setStepHandler (StepHandler handler) {
+ /** {@inheritDoc} */
+ public void setStepHandler (final StepHandler handler) {
this.handler = handler;
}
- /** Get the step handler for this integrator.
- * @return the step handler for this integrator
- */
+ /** {@inheritDoc} */
public StepHandler getStepHandler() {
return handler;
}
- /** Add a switching function to the integrator.
- * @param function switching function
- * @param maxCheckInterval maximal time interval between switching
- * function checks (this interval prevents missing sign changes in
- * case the integration steps becomes very large)
- * @param convergence convergence threshold in the event time search
- * @param maxIterationCount upper limit of the iteration count in
- * the event time search
- * @see #getSwitchingFunctions()
- * @see #clearSwitchingFunctions()
- */
- public void addSwitchingFunction(SwitchingFunction function,
- double maxCheckInterval,
- double convergence,
- int maxIterationCount) {
- switchesHandler.addSwitchingFunction(function, maxCheckInterval, convergence, maxIterationCount);
- }
-
- /** Get all the switching functions that have been added to the integrator.
- * @return an unmodifiable collection of the added switching functions
- * @see #addSwitchingFunction(SwitchingFunction, double, double, int)
- * @see #clearSwitchingFunctions()
- */
- public Collection<SwitchingFunction> getSwitchingFunctions() {
- return switchesHandler.getSwitchingFunctions();
- }
-
- /** Remove all the switching functions that have been added to the integrator.
- * @see #addSwitchingFunction(SwitchingFunction, double, double, int)
- * @see #getSwitchingFunctions()
- */
- public void clearSwitchingFunctions() {
- switchesHandler.clearSwitchingFunctions();
+ /** {@inheritDoc} */
+ public void addEventHandler(final EventHandler function,
+ final double maxCheckInterval,
+ final double convergence,
+ final int maxIterationCount) {
+ eventsHandlersManager.addEventHandler(function, maxCheckInterval, convergence, maxIterationCount);
+ }
+
+ /** {@inheritDoc} */
+ public Collection<EventHandler> getEventsHandlers() {
+ return eventsHandlersManager.getEventsHandlers();
+ }
+
+ /** {@inheritDoc} */
+ public void clearEventsHandlers() {
+ eventsHandlersManager.clearEventsHandlers();
}
/** Perform some sanity checks on the integration parameters.
@@ -133,8 +119,8 @@
* @param y placeholder where to put the state vector
* @exception IntegratorException if some inconsistency is detected
*/
- private void sanityChecks(FirstOrderDifferentialEquations equations,
- double t0, double[] y0, double t, double[] y)
+ private void sanityChecks(final FirstOrderDifferentialEquations equations,
+ final double t0, final double[] y0, final double t, final double[] y)
throws IntegratorException {
if (equations.getDimension() != y0.length) {
throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0}," +
@@ -158,45 +144,30 @@
}
}
- /** Integrate the differential equations up to the given time.
- * <p>This method solves an Initial Value Problem (IVP).</p>
- * <p>Since this method stores some internal state variables made
- * available in its public interface during integration ({@link
- * #getCurrentSignedStepsize()}), it is <em>not</em> thread-safe.</p>
- * @param equations differential equations to integrate
- * @param t0 initial time
- * @param y0 initial value of the state vector at t0
- * @param t target time for the integration
- * (can be set to a value smaller than <code>t0</code> for backward integration)
- * @param y placeholder where to put the state vector at each successful
- * step (and hence at the end of integration), can be the same object as y0
- * @throws IntegratorException if the integrator cannot perform integration
- * @throws DerivativeException this exception is propagated to the caller if
- * the underlying user function triggers one
- */
- public void integrate(FirstOrderDifferentialEquations equations,
- double t0, double[] y0,
- double t, double[] y)
+ /** {@inheritDoc} */
+ public void integrate(final FirstOrderDifferentialEquations equations,
+ final double t0, final double[] y0,
+ final double t, final double[] y)
throws DerivativeException, IntegratorException {
sanityChecks(equations, t0, y0, t, y);
- boolean forward = (t > t0);
+ final boolean forward = (t > t0);
// create some internal working arrays
- int stages = c.length + 1;
+ final int stages = c.length + 1;
if (y != y0) {
System.arraycopy(y0, 0, y, 0, y0.length);
}
- double[][] yDotK = new double[stages][];
+ final double[][] yDotK = new double[stages][];
for (int i = 0; i < stages; ++i) {
yDotK [i] = new double[y0.length];
}
- double[] yTmp = new double[y0.length];
+ final double[] yTmp = new double[y0.length];
// set up an interpolator sharing the integrator arrays
AbstractStepInterpolator interpolator;
- if (handler.requiresDenseOutput() || (! switchesHandler.isEmpty())) {
- RungeKuttaStepInterpolator rki = (RungeKuttaStepInterpolator) prototype.copy();
+ if (handler.requiresDenseOutput() || (! eventsHandlersManager.isEmpty())) {
+ final RungeKuttaStepInterpolator rki = (RungeKuttaStepInterpolator) prototype.copy();
rki.reinitialize(equations, yTmp, yDotK, forward);
interpolator = rki;
} else {
@@ -244,11 +215,11 @@
yTmp[j] = y[j] + stepSize * sum;
}
- // Switching functions handling
+ // Discrete events handling
interpolator.storeTime(stepStart + stepSize);
- if (switchesHandler.evaluateStep(interpolator)) {
+ if (eventsHandlersManager.evaluateStep(interpolator)) {
needUpdate = true;
- stepSize = switchesHandler.getEventTime() - stepStart;
+ stepSize = eventsHandlersManager.getEventTime() - stepStart;
} else {
loop = false;
}
@@ -256,10 +227,10 @@
}
// the step has been accepted
- double nextStep = stepStart + stepSize;
+ final double nextStep = stepStart + stepSize;
System.arraycopy(yTmp, 0, y, 0, y0.length);
- switchesHandler.stepAccepted(nextStep, y);
- if (switchesHandler.stop()) {
+ eventsHandlersManager.stepAccepted(nextStep, y);
+ if (eventsHandlersManager.stop()) {
lastStep = true;
} else {
lastStep = (i == (nbStep - 1));
@@ -270,14 +241,14 @@
handler.handleStep(interpolator, lastStep);
stepStart = nextStep;
- if (switchesHandler.reset(stepStart, y) && ! lastStep) {
- // some switching function has triggered changes that
+ if (eventsHandlersManager.reset(stepStart, y) && ! lastStep) {
+ // some events handler has triggered changes that
// invalidate the derivatives, we need to recompute them
equations.computeDerivatives(stepStart, y, yDotK[0]);
}
if (needUpdate) {
- // a switching function has changed the step
+ // an event handler has changed the step
// we need to recompute stepsize
nbStep = Math.max(1l, Math.abs(Math.round((t - stepStart) / step)));
stepSize = (t - stepStart) / nbStep;
@@ -290,28 +261,12 @@
}
- /** Get the current value of the step start time t<sub>i</sub>.
- * <p>This method can be called during integration (typically by
- * the object implementing the {@link FirstOrderDifferentialEquations
- * differential equations} problem) if the value of the current step that
- * is attempted is needed.</p>
- * <p>The result is undefined if the method is called outside of
- * calls to {@link #integrate}</p>
- * @return current value of the step start time t<sub>i</sub>
- */
+ /** {@inheritDoc} */
public double getCurrentStepStart() {
return stepStart;
}
- /** Get the current signed value of the integration stepsize.
- * <p>This method can be called during integration (typically by
- * the object implementing the {@link FirstOrderDifferentialEquations
- * differential equations} problem) if the signed value of the current stepsize
- * that is tried is needed.</p>
- * <p>The result is undefined if the method is called outside of
- * calls to {@link #integrate}</p>
- * @return current signed value of the stepsize
- */
+ /** {@inheritDoc} */
public double getCurrentSignedStepsize() {
return stepSize;
}
@@ -340,8 +295,8 @@
/** Step handler. */
private StepHandler handler;
- /** Switching functions handler. */
- protected SwitchingFunctionsHandler switchesHandler;
+ /** Events handlers manager. */
+ protected CombinedEventsManager eventsHandlersManager;
/** Current step start time. */
private double stepStart;
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/RungeKuttaStepInterpolator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/RungeKuttaStepInterpolator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/RungeKuttaStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java Mon Jun 23 01:01:38 2008
@@ -15,12 +15,16 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.IOException;
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
+import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
+
/** This class represents an interpolator over the last step during an
* ODE integration for Runge-Kutta and embedded Runge-Kutta integrators.
*
@@ -67,12 +71,12 @@
* @param interpolator interpolator to copy from.
*/
- public RungeKuttaStepInterpolator(RungeKuttaStepInterpolator interpolator) {
+ public RungeKuttaStepInterpolator(final RungeKuttaStepInterpolator interpolator) {
super(interpolator);
if (interpolator.currentState != null) {
- int dimension = currentState.length;
+ final int dimension = currentState.length;
yDotK = new double[interpolator.yDotK.length][];
for (int k = 0; k < interpolator.yDotK.length; ++k) {
@@ -112,18 +116,15 @@
* intermediate slopes
* @param forward integration direction indicator
*/
- public void reinitialize(FirstOrderDifferentialEquations equations,
- double[] y, double[][] yDotK, boolean forward) {
+ public void reinitialize(final FirstOrderDifferentialEquations equations,
+ final double[] y, final double[][] yDotK, final boolean forward) {
reinitialize(y, forward);
this.yDotK = yDotK;
this.equations = equations;
}
- /** Save the state of the instance.
- * @param out stream where to save the state
- * @exception IOException in case of write error
- */
- public void writeExternal(ObjectOutput out)
+ /** {@inheritDoc} */
+ public void writeExternal(final ObjectOutput out)
throws IOException {
// save the state of the base class
@@ -141,18 +142,15 @@
}
- /** Read the state of the instance.
- * @param in stream where to read the state from
- * @exception IOException in case of read error
- */
- public void readExternal(ObjectInput in)
+ /** {@inheritDoc} */
+ public void readExternal(final ObjectInput in)
throws IOException {
// read the base class
- double t = readBaseExternal(in);
+ final double t = readBaseExternal(in);
// read the local attributes
- int kMax = in.readInt();
+ final int kMax = in.readInt();
yDotK = new double[kMax][];
for (int k = 0; k < kMax; ++k) {
yDotK[k] = new double[currentState.length];
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegrator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ThreeEighthesIntegrator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegrator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegrator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ThreeEighthesIntegrator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ThreeEighthesIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegrator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
/**
* This class implements the 3/8 fourth order Runge-Kutta
@@ -71,13 +71,11 @@
* Build a 3/8 integrator with the given step.
* @param step integration step
*/
- public ThreeEighthesIntegrator(double step) {
+ public ThreeEighthesIntegrator(final double step) {
super(c, a, b, new ThreeEighthesStepInterpolator(), step);
}
- /** Get the name of the method.
- * @return name of the method
- */
+ /** {@inheritDoc} */
public String getName() {
return methodName;
}
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegrator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegrator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ThreeEighthesStepInterpolator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ThreeEighthesStepInterpolator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ThreeEighthesStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,11 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
+
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
+import org.apache.commons.math.ode.sampling.StepInterpolator;
/**
* This class implements a step interpolator for the 3/8 fourth
@@ -63,44 +67,33 @@
* copy: its arrays are separated from the original arrays of the
* instance
*/
- public ThreeEighthesStepInterpolator(ThreeEighthesStepInterpolator interpolator) {
+ public ThreeEighthesStepInterpolator(final ThreeEighthesStepInterpolator interpolator) {
super(interpolator);
}
- /** Really copy the finalized instance.
- * @return a copy of the finalized instance
- */
+ /** {@inheritDoc} */
protected StepInterpolator doCopy() {
return new ThreeEighthesStepInterpolator(this);
}
- /** Compute the state at the interpolated time.
- * This is the main processing method that should be implemented by
- * the derived classes to perform the interpolation.
- * @param theta normalized interpolation abscissa within the step
- * (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 DerivativeException this exception is propagated to the caller if the
- * underlying user function triggers one
- */
- protected void computeInterpolatedState(double theta,
- double oneMinusThetaH)
- throws DerivativeException {
-
- double fourTheta2 = 4 * theta * theta;
- double s = oneMinusThetaH / 8.0;
- double coeff1 = s * (1 - 7 * theta + 2 * fourTheta2);
- double coeff2 = 3 * s * (1 + theta - fourTheta2);
- double coeff3 = 3 * s * (1 + theta);
- double coeff4 = s * (1 + theta + fourTheta2);
-
- for (int i = 0; i < interpolatedState.length; ++i) {
- interpolatedState[i] = currentState[i] -
- coeff1 * yDotK[0][i] - coeff2 * yDotK[1][i] -
- coeff3 * yDotK[2][i] - coeff4 * yDotK[3][i];
- }
+ /** {@inheritDoc} */
+ protected void computeInterpolatedState(final double theta,
+ final double oneMinusThetaH)
+ throws DerivativeException {
+
+ final double fourTheta2 = 4 * theta * theta;
+ final double s = oneMinusThetaH / 8.0;
+ final double coeff1 = s * (1 - 7 * theta + 2 * fourTheta2);
+ final double coeff2 = 3 * s * (1 + theta - fourTheta2);
+ final double coeff3 = 3 * s * (1 + theta);
+ final double coeff4 = s * (1 + theta + fourTheta2);
+
+ for (int i = 0; i < interpolatedState.length; ++i) {
+ interpolatedState[i] = currentState[i] -
+ coeff1 * yDotK[0][i] - coeff2 * yDotK[1][i] -
+ coeff3 * yDotK[2][i] - coeff4 * yDotK[3][i];
+ }
}
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesStepInterpolator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/package.html
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/package.html?rev=670469&view=auto
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/package.html (added)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/package.html Mon Jun 23 01:01:38 2008
@@ -0,0 +1,25 @@
+<html>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+ <!-- $Revision: 613620 $ -->
+<body>
+<p>
+This package provides classes to solve non-stiff Ordinary Differential Equations problems.
+</p>
+
+</body>
+</html>
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/package.html
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/package.html?rev=670469&r1=670468&r2=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/package.html (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/package.html Mon Jun 23 01:01:38 2008
@@ -17,7 +17,9 @@
-->
<!-- $Revision$ -->
<body>
+<p>
This package provides classes to solve Ordinary Differential Equations problems.
+</p>
<p>
This package solves Initial Value Problems of the form
@@ -38,25 +40,15 @@
</p>
<p>
-All integrators handle multiple switching functions. This means that
-the integrator can be driven by discrete events (occurring when the
-signs of user-supplied {@link
-org.apache.commons.math.ode.SwitchingFunction switching functions}
-change). The steps are shortened as needed to ensure the events occur
+All integrators handle multiple discrete events detection based on switching
+functions. This means that the integrator can be driven by user specified
+discrete events. The steps are shortened as needed to ensure the events occur
at step boundaries (even if the integrator is a fixed-step
integrator). When the events are triggered, integration can be stopped
(this is called a G-stop facility), the state vector can be changed,
or integration can simply go on. The latter case is useful to handle
discontinuities in the differential equations gracefully and get
-accurate dense output even close to the discontinuity. The events are
-detected when the functions signs are different at the beginning and
-end of the current step, or at several equidistant points inside the
-step if its length becomes larger than the maximal checking interval
-specified for the given switching function. This time interval should
-be set appropriately to avoid missing some switching function sign
-changes (it is possible to set it to
-<code>Double.POSITIVE_INFINITY</code> if the sign changes cannot be
-missed).
+accurate dense output even close to the discontinuity.
</p>
<p>
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AbstractStepInterpolator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AbstractStepInterpolator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AbstractStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java Mon Jun 23 01:01:38 2008
@@ -15,12 +15,17 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.sampling;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.IOException;
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.FirstOrderIntegrator;
+import org.apache.commons.math.ode.SecondOrderIntegrator;
+import org.apache.commons.math.ode.nonstiff.EmbeddedRungeKuttaIntegrator;
+
/** This abstract class represents an interpolator over the last step
* during an ODE integration.
*
@@ -91,7 +96,7 @@
* the end of the step
* @param forward integration direction indicator
*/
- protected AbstractStepInterpolator(double[] y, boolean forward) {
+ protected AbstractStepInterpolator(final double[] y, final boolean forward) {
previousTime = Double.NaN;
currentTime = Double.NaN;
@@ -123,7 +128,7 @@
* @param interpolator interpolator to copy from.
*/
- protected AbstractStepInterpolator(AbstractStepInterpolator interpolator) {
+ protected AbstractStepInterpolator(final AbstractStepInterpolator interpolator) {
previousTime = interpolator.previousTime;
currentTime = interpolator.currentTime;
@@ -148,7 +153,7 @@
* the end of the step
* @param forward integration direction indicator
*/
- protected void reinitialize(double[] y, boolean forward) {
+ protected void reinitialize(final double[] y, final boolean forward) {
previousTime = Double.NaN;
currentTime = Double.NaN;
@@ -202,7 +207,7 @@
/** Store the current step time.
* @param t current time
*/
- public void storeTime(double t) {
+ public void storeTime(final double t) {
currentTime = t;
h = currentTime - previousTime;
@@ -253,18 +258,18 @@
* @throws DerivativeException if this call induces an automatic
* step finalization that throws one
*/
- public void setInterpolatedTime(double time)
- throws DerivativeException {
- interpolatedTime = time;
- double oneMinusThetaH = currentTime - interpolatedTime;
- computeInterpolatedState((h - oneMinusThetaH) / h, oneMinusThetaH);
+ public void setInterpolatedTime(final double time)
+ throws DerivativeException {
+ interpolatedTime = time;
+ final double oneMinusThetaH = currentTime - interpolatedTime;
+ computeInterpolatedState((h - oneMinusThetaH) / h, oneMinusThetaH);
}
/** Check if the natural integration direction is forward.
* <p>This method provides the integration direction as specified by the
* integrator itself, it avoid some nasty problems in degenerated
* cases like null steps due to cancellation at step initialization,
- * step control or switching function triggering.</p>
+ * step control or discrete events triggering.</p>
* @return true if the integration variable (time) increases during
* integration
*/
@@ -375,7 +380,7 @@
* @param out stream where to save the state
* @exception IOException in case of write error
*/
- protected void writeBaseExternal(ObjectOutput out)
+ protected void writeBaseExternal(final ObjectOutput out)
throws IOException {
out.writeInt(currentState.length);
@@ -411,10 +416,10 @@
* @return interpolated time be set later by the caller
* @exception IOException in case of read error
*/
- protected double readBaseExternal(ObjectInput in)
+ protected double readBaseExternal(final ObjectInput in)
throws IOException {
- int dimension = in.readInt();
+ final int dimension = in.readInt();
previousTime = in.readDouble();
currentTime = in.readDouble();
h = in.readDouble();
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepHandler.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DummyStepHandler.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepHandler.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepHandler.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DummyStepHandler.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DummyStepHandler.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepHandler.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.sampling;
import java.io.Serializable;
@@ -80,7 +80,7 @@
* copy.
* @param isLast true if the step is the last one
*/
- public void handleStep(StepInterpolator interpolator, boolean isLast) {
+ public void handleStep(final StepInterpolator interpolator, final boolean isLast) {
}
/** The only instance. */
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepHandler.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DummyStepInterpolator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DummyStepInterpolator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DummyStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java Mon Jun 23 01:01:38 2008
@@ -15,12 +15,15 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.sampling;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.IOException;
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.nonstiff.EmbeddedRungeKuttaIntegrator;
+
/** This class is a step interpolator that does nothing.
*
* <p>This class is used when the {@link StepHandler "step handler"}
@@ -57,7 +60,7 @@
* the end of the step
* @param forward integration direction indicator
*/
- protected DummyStepInterpolator(double[] y, boolean forward) {
+ public DummyStepInterpolator(final double[] y, final boolean forward) {
super(y, forward);
}
@@ -66,7 +69,7 @@
* copy: its arrays are separated from the original arrays of the
* instance
*/
- public DummyStepInterpolator(DummyStepInterpolator interpolator) {
+ public DummyStepInterpolator(final DummyStepInterpolator interpolator) {
super(interpolator);
}
@@ -87,7 +90,7 @@
* @throws DerivativeException this exception is propagated to the caller if the
* underlying user function triggers one
*/
- protected void computeInterpolatedState(double theta, double oneMinusThetaH)
+ protected void computeInterpolatedState(final double theta, final double oneMinusThetaH)
throws DerivativeException {
System.arraycopy(currentState, 0, interpolatedState, 0, currentState.length);
}
@@ -96,7 +99,7 @@
* @param out output channel
* @exception IOException if the instance cannot be written
*/
- public void writeExternal(ObjectOutput out)
+ public void writeExternal(final ObjectOutput out)
throws IOException {
// save the state of the base class
writeBaseExternal(out);
@@ -106,11 +109,11 @@
* @param in input channel
* @exception IOException if the instance cannot be read
*/
- public void readExternal(ObjectInput in)
+ public void readExternal(final ObjectInput in)
throws IOException {
// read the base class
- double t = readBaseExternal(in);
+ final double t = readBaseExternal(in);
try {
// we can now set the interpolated time and state
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/FixedStepHandler.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/FixedStepHandler.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/FixedStepHandler.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.sampling;
/**
* This interface represents a handler that should be called after
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepHandler.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/StepHandler.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepHandler.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepHandler.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/StepHandler.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/StepHandler.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepHandler.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,14 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.sampling;
+
+import java.io.Serializable;
+
+import org.apache.commons.math.ode.ContinuousOutputModel;
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.FirstOrderIntegrator;
+import org.apache.commons.math.ode.SecondOrderIntegrator;
/**
* This interface represents a handler that should be called after
@@ -37,7 +44,7 @@
* @since 1.2
*/
-public interface StepHandler {
+public interface StepHandler extends Serializable {
/** Determines whether this handler needs dense output.
* <p>This method allows the integrator to avoid performing extra
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/StepHandler.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision