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/01/20 22:31:35 UTC

svn commit: r1061526 - in /commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode: ./ nonstiff/

Author: luc
Date: Thu Jan 20 21:31:34 2011
New Revision: 1061526

URL: http://svn.apache.org/viewvc?rev=1061526&view=rev
Log:
limit visibility of event states list to AbstractIntegrator class only

Modified:
    commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/AbstractIntegrator.java
    commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.java
    commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java
    commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java
    commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java
    commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java

Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/AbstractIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/AbstractIntegrator.java?rev=1061526&r1=1061525&r2=1061526&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/AbstractIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/AbstractIntegrator.java Thu Jan 20 21:31:34 2011
@@ -60,7 +60,7 @@ public abstract class AbstractIntegrator
     protected boolean resetOccurred;
 
     /** Events states. */
-    protected Collection<EventState> eventsStates;
+    private Collection<EventState> eventsStates;
 
     /** Initialization indicator of events states. */
     protected boolean statesInitialized;
@@ -139,10 +139,14 @@ public abstract class AbstractIntegrator
         eventsStates.clear();
     }
 
-    /** Check if one of the step handlers requires dense output.
-     * @return true if one of the step handlers requires dense output
+    /** Check if dense output is needed.
+     * @return true if there is at least one event handler or if
+     * one of the step handlers requires dense output
      */
     protected boolean requiresDenseOutput() {
+        if (!eventsStates.isEmpty()) {
+            return true;
+        }
         for (StepHandler handler : stepHandlers) {
             if (handler.requiresDenseOutput()) {
                 return true;
@@ -207,7 +211,6 @@ public abstract class AbstractIntegrator
 
     /** Accept a step, triggering events and step handlers.
      * @param interpolator step interpolator
-     * @param handlers step handlers
      * @param y state vector at step end time, must be reset if an event
      * asks for resetting or if an events stops integration during the step
      * @param yDot placeholder array where to put the time derivative of the state vector
@@ -216,9 +219,7 @@ public abstract class AbstractIntegrator
      * @exception IntegratorException if the value of one event state cannot be evaluated
      */
     protected double acceptStep(final AbstractStepInterpolator interpolator,
-                                final Collection<StepHandler> handlers,
-                                final double[] y,
-                                final double[] yDot, final double tEnd)
+                                final double[] y, final double[] yDot, final double tEnd)
         throws IntegratorException {
 
         try {

Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.java?rev=1061526&r1=1061525&r2=1061526&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.java Thu Jan 20 21:31:34 2011
@@ -272,7 +272,7 @@ public class AdamsBashforthIntegrator ex
 
             // discrete events handling
             interpolator.storeTime(stepEnd);
-            stepStart = acceptStep(interpolator, stepHandlers, y, yDot, t);
+            stepStart = acceptStep(interpolator, y, yDot, t);
             scaled    = predictedScaled;
             nordsieck = nordsieckTmp;
             interpolator.reinitialize(stepEnd, stepSize, scaled, nordsieck);

Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java?rev=1061526&r1=1061525&r2=1061526&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java Thu Jan 20 21:31:34 2011
@@ -291,7 +291,7 @@ public class AdamsMoultonIntegrator exte
             interpolator.storeTime(stepStart);
             interpolator.shift();
             interpolator.storeTime(stepEnd);
-            stepStart = acceptStep(interpolator, stepHandlers, y, yDot, t);
+            stepStart = acceptStep(interpolator, y, yDot, t);
             scaled    = correctedScaled;
             nordsieck = nordsieckTmp;
 

Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java?rev=1061526&r1=1061525&r2=1061526&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java Thu Jan 20 21:31:34 2011
@@ -210,7 +210,7 @@ public abstract class EmbeddedRungeKutta
 
     // set up an interpolator sharing the integrator arrays
     AbstractStepInterpolator interpolator;
-    if (requiresDenseOutput() || (! eventsStates.isEmpty())) {
+    if (requiresDenseOutput()) {
       final RungeKuttaStepInterpolator rki = (RungeKuttaStepInterpolator) prototype.copy();
       rki.reinitialize(this, yTmp, yDotK, forward);
       interpolator = rki;
@@ -301,7 +301,7 @@ public abstract class EmbeddedRungeKutta
       interpolator.storeTime(stepStart + stepSize);
       System.arraycopy(yTmp, 0, y, 0, y0.length);
       System.arraycopy(yDotK[stages - 1], 0, yDotTmp, 0, y0.length);
-      stepStart = acceptStep(interpolator, stepHandlers, y, yDotTmp, t);
+      stepStart = acceptStep(interpolator, y, yDotTmp, t);
 
       if (!isLastStep) {
 

Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java?rev=1061526&r1=1061525&r2=1061526&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java Thu Jan 20 21:31:34 2011
@@ -145,9 +145,6 @@ public class GraggBulirschStoerIntegrato
     /** second order control factor. */
     private double orderControl2;
 
-    /** dense outpute required. */
-    private boolean denseOutput;
-
     /** use interpolation error in stepsize control. */
     private boolean useInterpolationError;
 
@@ -170,7 +167,6 @@ public class GraggBulirschStoerIntegrato
                                       final double scalRelativeTolerance) {
     super(METHOD_NAME, minStep, maxStep,
           scalAbsoluteTolerance, scalRelativeTolerance);
-    denseOutput = requiresDenseOutput() || (! eventsStates.isEmpty());
     setStabilityCheck(true, -1, -1, -1);
     setStepsizeControl(-1, -1, -1, -1);
     setOrderControl(-1, -1, -1);
@@ -193,7 +189,6 @@ public class GraggBulirschStoerIntegrato
                                       final double[] vecRelativeTolerance) {
     super(METHOD_NAME, minStep, maxStep,
           vecAbsoluteTolerance, vecRelativeTolerance);
-    denseOutput = requiresDenseOutput() || (! eventsStates.isEmpty());
     setStabilityCheck(true, -1, -1, -1);
     setStepsizeControl(-1, -1, -1, -1);
     setOrderControl(-1, -1, -1);
@@ -339,7 +334,6 @@ public class GraggBulirschStoerIntegrato
   public void addStepHandler (final StepHandler handler) {
 
     super.addStepHandler(handler);
-    denseOutput = requiresDenseOutput() || (! eventsStates.isEmpty());
 
     // reinitialize the arrays
     initializeArrays();
@@ -353,7 +347,6 @@ public class GraggBulirschStoerIntegrato
                               final double convergence,
                               final int maxIterationCount) {
     super.addEventHandler(function, maxCheckInterval, convergence, maxIterationCount);
-    denseOutput = requiresDenseOutput() || (! eventsStates.isEmpty());
 
     // reinitialize the arrays
     initializeArrays();
@@ -374,7 +367,7 @@ public class GraggBulirschStoerIntegrato
       optimalStep     = new double[size];
     }
 
-    if (denseOutput) {
+    if (requiresDenseOutput()) {
       // step size sequence: 2, 6, 10, 14, ...
       for (int k = 0; k < size; ++k) {
         sequence[k] = 4 * k + 2;
@@ -596,6 +589,7 @@ public class GraggBulirschStoerIntegrato
 
     double[] yDot1      = new double[y0.length];
     double[][] yMidDots = null;
+    final boolean denseOutput = requiresDenseOutput();
     if (denseOutput) {
       yMidDots = new double[1 + 2 * sequence.length][];
       for (int j = 0; j < yMidDots.length; ++j) {
@@ -619,7 +613,7 @@ public class GraggBulirschStoerIntegrato
                                        (int) FastMath.floor(0.5 - 0.6 * log10R)));
     // set up an interpolator sharing the integrator arrays
     AbstractStepInterpolator interpolator = null;
-    if (denseOutput || (! eventsStates.isEmpty())) {
+    if (denseOutput) {
       interpolator = new GraggBulirschStoerStepInterpolator(y, yDot0,
                                                             y1, yDot1,
                                                             yMidDots, forward);
@@ -884,7 +878,7 @@ public class GraggBulirschStoerIntegrato
 
         // Discrete events handling
         interpolator.storeTime(stepStart + stepSize);
-        stepStart = acceptStep(interpolator, stepHandlers, y1, yDot1, t);
+        stepStart = acceptStep(interpolator, y1, yDot1, t);
 
         // prepare next step
         interpolator.storeTime(stepStart);

Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java?rev=1061526&r1=1061525&r2=1061526&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java Thu Jan 20 21:31:34 2011
@@ -116,7 +116,7 @@ public abstract class RungeKuttaIntegrat
 
     // set up an interpolator sharing the integrator arrays
     AbstractStepInterpolator interpolator;
-    if (requiresDenseOutput() || (! eventsStates.isEmpty())) {
+    if (requiresDenseOutput()) {
       final RungeKuttaStepInterpolator rki = (RungeKuttaStepInterpolator) prototype.copy();
       rki.reinitialize(this, yTmp, yDotK, forward);
       interpolator = rki;
@@ -170,7 +170,7 @@ public abstract class RungeKuttaIntegrat
       interpolator.storeTime(stepStart + stepSize);
       System.arraycopy(yTmp, 0, y, 0, y0.length);
       System.arraycopy(yDotK[stages - 1], 0, yDotTmp, 0, y0.length);
-      stepStart = acceptStep(interpolator, stepHandlers, y, yDotTmp, t);
+      stepStart = acceptStep(interpolator, y, yDotTmp, t);
 
       if (!isLastStep) {