commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject [1/2] [math] Removed use of deprecated class.
Date Fri, 25 Dec 2015 11:13:16 GMT
Repository: commons-math
Updated Branches:
  refs/heads/master bf803b119 -> 030b9a723


Removed use of deprecated class.

Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/b72d8677
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/b72d8677
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/b72d8677

Branch: refs/heads/master
Commit: b72d8677bfa9aa177b9b973fc76322080f5de470
Parents: bf803b1
Author: Luc Maisonobe <luc@apache.org>
Authored: Fri Dec 25 12:11:55 2015 +0100
Committer: Luc Maisonobe <luc@apache.org>
Committed: Fri Dec 25 12:11:55 2015 +0100

----------------------------------------------------------------------
 .../commons/math4/ode/AbstractIntegrator.java     | 18 ++++++++----------
 .../commons/math4/ode/MultistepIntegrator.java    |  2 +-
 .../nonstiff/AdamsBashforthIntegratorTest.java    |  1 +
 .../ode/nonstiff/AdamsMoultonIntegratorTest.java  |  1 +
 4 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/b72d8677/src/main/java/org/apache/commons/math4/ode/AbstractIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/AbstractIntegrator.java b/src/main/java/org/apache/commons/math4/ode/AbstractIntegrator.java
index e9326d9..4227917 100644
--- a/src/main/java/org/apache/commons/math4/ode/AbstractIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/ode/AbstractIntegrator.java
@@ -38,7 +38,7 @@ import org.apache.commons.math4.ode.events.EventState;
 import org.apache.commons.math4.ode.sampling.AbstractStepInterpolator;
 import org.apache.commons.math4.ode.sampling.StepHandler;
 import org.apache.commons.math4.util.FastMath;
-import org.apache.commons.math4.util.Incrementor;
+import org.apache.commons.math4.util.IntegerSequence;
 import org.apache.commons.math4.util.Precision;
 
 /**
@@ -72,7 +72,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator
{
     private final String name;
 
     /** Counter for number of evaluations. */
-    private Incrementor evaluations;
+    private IntegerSequence.Incrementor evaluations;
 
     /** Differential equations to integrate. */
     private transient ExpandableStatefulODE expandable;
@@ -87,9 +87,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator
{
         stepSize  = Double.NaN;
         eventsStates = new ArrayList<EventState>();
         statesInitialized = false;
-        evaluations = new Incrementor();
-        setMaxEvaluations(-1);
-        evaluations.resetCount();
+        evaluations = IntegerSequence.Incrementor.create().withMaximalCount(Integer.MAX_VALUE);
     }
 
     /** Build an instance with a null name.
@@ -175,7 +173,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator
{
     /** {@inheritDoc} */
     @Override
     public void setMaxEvaluations(int maxEvaluations) {
-        evaluations.setMaximalCount((maxEvaluations < 0) ? Integer.MAX_VALUE : maxEvaluations);
+        evaluations = evaluations.withMaximalCount((maxEvaluations < 0) ? Integer.MAX_VALUE
: maxEvaluations);
     }
 
     /** {@inheritDoc} */
@@ -197,7 +195,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator
{
      */
     protected void initIntegration(final double t0, final double[] y0, final double t) {
 
-        evaluations.resetCount();
+        evaluations = evaluations.withStart(0);
 
         for (final EventState state : eventsStates) {
             state.setExpandable(expandable);
@@ -229,9 +227,9 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator
{
 
     /** Get the evaluations counter.
      * @return evaluations counter
-     * @since 3.2
+     * @since 3.6
      */
-    protected Incrementor getEvaluationsCounter() {
+    protected IntegerSequence.Incrementor getCounter() {
         return evaluations;
     }
 
@@ -298,7 +296,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator
{
      */
     public void computeDerivatives(final double t, final double[] y, final double[] yDot)
         throws MaxCountExceededException, DimensionMismatchException, NullPointerException
{
-        evaluations.incrementCount();
+        evaluations.increment();
         expandable.computeDerivatives(t, y, yDot);
     }
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b72d8677/src/main/java/org/apache/commons/math4/ode/MultistepIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/MultistepIntegrator.java b/src/main/java/org/apache/commons/math4/ode/MultistepIntegrator.java
index 6f0400c..b415dd1 100644
--- a/src/main/java/org/apache/commons/math4/ode/MultistepIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/ode/MultistepIntegrator.java
@@ -252,7 +252,7 @@ public abstract class MultistepIntegrator extends AdaptiveStepsizeIntegrator
{
             // this is the expected nominal interruption of the start integrator
 
             // count the evaluations used by the starter
-            getEvaluationsCounter().incrementCount(starter.getEvaluations());
+            getCounter().increment(starter.getEvaluations());
 
         }
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b72d8677/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthIntegratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthIntegratorTest.java
b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthIntegratorTest.java
index 0f4cdce..f9b965c 100644
--- a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthIntegratorTest.java
+++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthIntegratorTest.java
@@ -175,6 +175,7 @@ public class AdamsBashforthIntegratorTest {
 
         public void integrate(ExpandableStatefulODE equations, double t) {
             double tStart = equations.getTime() + 0.01 * (t - equations.getTime());
+            getCounter().increment(nbSteps);
             for (int i = 0; i < nbSteps; ++i) {
                 double tK = ((nbSteps - 1 - (i + 1)) * equations.getTime() + (i + 1) * tStart)
/ (nbSteps - 1);
                 interpolator.setPreviousTime(interpolator.getCurrentTime());

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b72d8677/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonIntegratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonIntegratorTest.java
b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonIntegratorTest.java
index 0abfe9d..3e03651 100644
--- a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonIntegratorTest.java
+++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonIntegratorTest.java
@@ -188,6 +188,7 @@ public class AdamsMoultonIntegratorTest {
 
         public void integrate(ExpandableStatefulODE equations, double t) {
             double tStart = equations.getTime() + 0.01 * (t - equations.getTime());
+            getCounter().increment(nbSteps);
             for (int i = 0; i < nbSteps; ++i) {
                 double tK = ((nbSteps - 1 - (i + 1)) * equations.getTime() + (i + 1) * tStart)
/ (nbSteps - 1);
                 interpolator.setPreviousTime(interpolator.getCurrentTime());


Mime
View raw message