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 2011/11/28 11:56:31 UTC
svn commit: r1207066 - in /commons/proper/math/trunk/src:
main/java/org/apache/commons/math/ode/sampling/
test/java/org/apache/commons/math/ode/sampling/
Author: luc
Date: Mon Nov 28 10:56:30 2011
New Revision: 1207066
URL: http://svn.apache.org/viewvc?rev=1207066&view=rev
Log:
Added the initi method also to FixedStepHandler.
Jira: MATH-714
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/StepNormalizer.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerOutputTestBase.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerTest.java
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java?rev=1207066&r1=1207065&r2=1207066&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java Mon Nov 28 10:56:30 2011
@@ -39,6 +39,18 @@ package org.apache.commons.math.ode.samp
public interface FixedStepHandler {
+ /** Initialize step handler at the start of an ODE integration.
+ * <p>
+ * This method is called once at the start of the integration. It
+ * may be used by the step handler to initialize some internal data
+ * if needed.
+ * </p>
+ * @param t0 start value of the independent <i>time</i> variable
+ * @param y0 array containing the start value of the state vector
+ * @param t target time for the integration
+ */
+ void init(double t0, double[] y0, double t);
+
/**
* Handle the last accepted step
* @param t time of the current step
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/StepNormalizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/StepNormalizer.java?rev=1207066&r1=1207065&r2=1207066&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/StepNormalizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/StepNormalizer.java Mon Nov 28 10:56:30 2011
@@ -174,11 +174,16 @@ public class StepNormalizer implements S
/** {@inheritDoc} */
public void init(double t0, double[] y0, double t) {
+
firstTime = Double.NaN;
lastTime = Double.NaN;
lastState = null;
lastDerivatives = null;
forward = true;
+
+ // initialize the underlying handler
+ handler.init(t0, y0, t);
+
}
/**
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerOutputTestBase.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerOutputTestBase.java?rev=1207066&r1=1207065&r2=1207066&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerOutputTestBase.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerOutputTestBase.java Mon Nov 28 10:56:30 2011
@@ -12,8 +12,8 @@ import org.junit.Test;
/** Base class for step normalizer output tests. */
public abstract class StepNormalizerOutputTestBase
- implements FirstOrderDifferentialEquations, FixedStepHandler
-{
+ implements FirstOrderDifferentialEquations, FixedStepHandler {
+
/** The normalized output time values. */
private List<Double> output;
@@ -212,7 +212,12 @@ public abstract class StepNormalizerOutp
}
/** {@inheritDoc} */
+ public void init(double t0, double[] y0, double t) {
+ }
+
+ /** {@inheritDoc} */
public void handleStep(double t, double[] y, double[] yDot, boolean isLast) {
output.add(t);
}
+
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerTest.java?rev=1207066&r1=1207065&r2=1207066&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerTest.java Mon Nov 28 10:56:30 2011
@@ -41,7 +41,9 @@ public class StepNormalizerTest {
setLastSeen(false);
integ.addStepHandler(new StepNormalizer(range / 10.0,
new FixedStepHandler() {
- private boolean firstCall = true;
+ private boolean firstCall = true;
+ public void init(double t0, double[] y0, double t) {
+ }
public void handleStep(double t,
double[] y,
double[] yDot,
@@ -69,7 +71,9 @@ public class StepNormalizerTest {
setLastSeen(false);
integ.addStepHandler(new StepNormalizer(range / 10.5,
new FixedStepHandler() {
- public void handleStep(double t,
+ public void init(double t0, double[] y0, double t) {
+ }
+ public void handleStep(double t,
double[] y,
double[] yDot,
boolean isLast) {