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 2015/12/25 15:05:26 UTC

[1/4] [math] Removed unused imports.

Repository: commons-math
Updated Branches:
  refs/heads/MATH_3_X b448d5f55 -> ee504b64a


Removed unused imports.


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

Branch: refs/heads/MATH_3_X
Commit: e690ac325d771d11c5e233a88e458467bdd9bc42
Parents: b448d5f
Author: Luc Maisonobe <lu...@apache.org>
Authored: Fri Dec 25 14:54:14 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Fri Dec 25 14:54:14 2015 +0100

----------------------------------------------------------------------
 .../analysis/interpolation/BicubicInterpolatingFunctionTest.java  | 1 -
 .../org/apache/commons/math3/fitting/SimpleCurveFitterTest.java   | 3 ---
 2 files changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/e690ac32/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicInterpolatingFunctionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicInterpolatingFunctionTest.java b/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicInterpolatingFunctionTest.java
index 6d56ed8..3ca0af5 100644
--- a/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicInterpolatingFunctionTest.java
+++ b/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicInterpolatingFunctionTest.java
@@ -27,7 +27,6 @@ import org.apache.commons.math3.util.FastMath;
 import org.apache.commons.math3.util.Precision;
 import org.junit.Assert;
 import org.junit.Test;
-import org.junit.Ignore;
 
 /**
  * Test case for the bicubic function.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/e690ac32/src/test/java/org/apache/commons/math3/fitting/SimpleCurveFitterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/fitting/SimpleCurveFitterTest.java b/src/test/java/org/apache/commons/math3/fitting/SimpleCurveFitterTest.java
index e16d661..218ad1d 100644
--- a/src/test/java/org/apache/commons/math3/fitting/SimpleCurveFitterTest.java
+++ b/src/test/java/org/apache/commons/math3/fitting/SimpleCurveFitterTest.java
@@ -23,9 +23,6 @@ import org.apache.commons.math3.analysis.ParametricUnivariateFunction;
 import org.apache.commons.math3.analysis.polynomials.PolynomialFunction;
 import org.apache.commons.math3.distribution.RealDistribution;
 import org.apache.commons.math3.distribution.UniformRealDistribution;
-import org.apache.commons.math3.exception.ConvergenceException;
-import org.apache.commons.math3.util.FastMath;
-import org.junit.Assert;
 import org.junit.Test;
 
 /**


[2/4] [math] Avoid deprecation warnings in tests.

Posted by lu...@apache.org.
Avoid deprecation warnings in tests.


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

Branch: refs/heads/MATH_3_X
Commit: 6b4bf610b3f2150848ad7a656976bd2d0e240819
Parents: e690ac3
Author: Luc Maisonobe <lu...@apache.org>
Authored: Fri Dec 25 14:57:14 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Fri Dec 25 14:57:14 2015 +0100

----------------------------------------------------------------------
 .../BicubicSplineInterpolatingFunctionTest.java |  3 +++
 .../BicubicSplineInterpolatorTest.java          |  2 ++
 .../MicrosphereInterpolatorTest.java            |  3 +++
 ...PolynomialBicubicSplineInterpolatorTest.java |  2 ++
 ...TricubicSplineInterpolatingFunctionTest.java |  2 ++
 .../TricubicSplineInterpolatorTest.java         |  2 ++
 .../commons/math3/util/ArithmeticUtilsTest.java | 22 ++++++++++++--------
 .../commons/math3/util/IncrementorTest.java     |  2 ++
 8 files changed, 29 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/6b4bf610/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolatingFunctionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolatingFunctionTest.java b/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolatingFunctionTest.java
index 24aa0f4..c01b0fc 100644
--- a/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolatingFunctionTest.java
+++ b/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolatingFunctionTest.java
@@ -30,7 +30,10 @@ import org.junit.Ignore;
 /**
  * Test case for the bicubic function.
  *
+ * @deprecated as of 3.4 replaced by
+ * {@link org.apache.commons.math3.analysis.interpolation.PiecewiseBicubicSplineInterpolatingFunction}
  */
+@Deprecated
 public final class BicubicSplineInterpolatingFunctionTest {
     /**
      * Test preconditions.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/6b4bf610/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolatorTest.java b/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolatorTest.java
index 3a3852f..df3beb8 100644
--- a/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolatorTest.java
+++ b/src/test/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolatorTest.java
@@ -28,7 +28,9 @@ import org.junit.Test;
 /**
  * Test case for the bicubic interpolator.
  *
+ * @deprecated as of 3.4 replaced by {@link org.apache.commons.math3.analysis.interpolation.PiecewiseBicubicSplineInterpolator}
  */
+@Deprecated
 public final class BicubicSplineInterpolatorTest {
     /**
      * Test preconditions.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/6b4bf610/src/test/java/org/apache/commons/math3/analysis/interpolation/MicrosphereInterpolatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/analysis/interpolation/MicrosphereInterpolatorTest.java b/src/test/java/org/apache/commons/math3/analysis/interpolation/MicrosphereInterpolatorTest.java
index d894d14..90a6faa 100644
--- a/src/test/java/org/apache/commons/math3/analysis/interpolation/MicrosphereInterpolatorTest.java
+++ b/src/test/java/org/apache/commons/math3/analysis/interpolation/MicrosphereInterpolatorTest.java
@@ -24,7 +24,10 @@ import org.junit.Test;
 /**
  * Test case for the "microsphere projection" interpolator.
  *
+ * @deprecated Code will be removed in 4.0.  Use {@link InterpolatingMicrosphere}
+ * and {@link MicrosphereProjectionInterpolator} instead.
  */
+@Deprecated
 public final class MicrosphereInterpolatorTest {
     /**
      * Test of interpolator for a plane.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/6b4bf610/src/test/java/org/apache/commons/math3/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolatorTest.java b/src/test/java/org/apache/commons/math3/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolatorTest.java
index 1977b11..35aa2ff 100644
--- a/src/test/java/org/apache/commons/math3/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolatorTest.java
+++ b/src/test/java/org/apache/commons/math3/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolatorTest.java
@@ -26,7 +26,9 @@ import org.junit.Test;
 /**
  * Test case for the smoothing bicubic interpolator.
  *
+ * @deprecated To be removed in 4.0 (see MATH-1166).
  */
+@Deprecated
 public final class SmoothingPolynomialBicubicSplineInterpolatorTest {
     /**
      * Test preconditions.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/6b4bf610/src/test/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolatingFunctionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolatingFunctionTest.java b/src/test/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolatingFunctionTest.java
index c6ee8af..5712087 100644
--- a/src/test/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolatingFunctionTest.java
+++ b/src/test/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolatingFunctionTest.java
@@ -26,7 +26,9 @@ import org.junit.Test;
 /**
  * Test case for the bicubic function.
  *
+ * @deprecated To be removed in 4.0 (see MATH-1166).
  */
+@Deprecated
 public final class TricubicSplineInterpolatingFunctionTest {
     /**
      * Test preconditions.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/6b4bf610/src/test/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolatorTest.java b/src/test/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolatorTest.java
index a747cca..f8468a9 100644
--- a/src/test/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolatorTest.java
+++ b/src/test/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolatorTest.java
@@ -27,7 +27,9 @@ import org.junit.Ignore;
 /**
  * Test case for the tricubic interpolator.
  *
+ * @deprecated To be removed in 4.0 (see MATH-1166).
  */
+@Deprecated
 public final class TricubicSplineInterpolatorTest {
     /**
      * Test preconditions.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/6b4bf610/src/test/java/org/apache/commons/math3/util/ArithmeticUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/util/ArithmeticUtilsTest.java b/src/test/java/org/apache/commons/math3/util/ArithmeticUtilsTest.java
index ecf0187..37bceda 100644
--- a/src/test/java/org/apache/commons/math3/util/ArithmeticUtilsTest.java
+++ b/src/test/java/org/apache/commons/math3/util/ArithmeticUtilsTest.java
@@ -412,15 +412,6 @@ public class ArithmeticUtilsTest {
             // expected behavior
         }
 
-        Assert.assertEquals(1801088541l, ArithmeticUtils.pow(21l, 7l));
-        Assert.assertEquals(1l, ArithmeticUtils.pow(21l, 0l));
-        try {
-            ArithmeticUtils.pow(21l, -7l);
-            Assert.fail("Expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException e) {
-            // expected behavior
-        }
-
         BigInteger twentyOne = BigInteger.valueOf(21l);
         Assert.assertEquals(BigInteger.valueOf(1801088541l), ArithmeticUtils.pow(twentyOne, 7));
         Assert.assertEquals(BigInteger.ONE, ArithmeticUtils.pow(twentyOne, 0));
@@ -459,6 +450,19 @@ public class ArithmeticUtilsTest {
 
     }
 
+    @Test
+    @Deprecated
+    public void testPowDeprecated() {
+        Assert.assertEquals(1801088541l, ArithmeticUtils.pow(21l, 7l));
+        Assert.assertEquals(1l, ArithmeticUtils.pow(21l, 0l));
+        try {
+            ArithmeticUtils.pow(21l, -7l);
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException e) {
+            // expected behavior
+        }
+    }
+
     @Test(expected=MathArithmeticException.class)
     public void testPowIntOverflow() {
         ArithmeticUtils.pow(21, 8);

http://git-wip-us.apache.org/repos/asf/commons-math/blob/6b4bf610/src/test/java/org/apache/commons/math3/util/IncrementorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/util/IncrementorTest.java b/src/test/java/org/apache/commons/math3/util/IncrementorTest.java
index 382b0fc..8d52f04 100644
--- a/src/test/java/org/apache/commons/math3/util/IncrementorTest.java
+++ b/src/test/java/org/apache/commons/math3/util/IncrementorTest.java
@@ -20,7 +20,9 @@ import org.junit.Test;
 
 /**
  * Test for {@link Incrementor}.
+ * @deprecated as of 3.6, Incrementor is deprecated
  */
+@Deprecated
 public class IncrementorTest {
     @Test
     public void testConstructor1() {


[3/4] [math] Fixed compiler warnings.

Posted by lu...@apache.org.
Fixed compiler warnings.


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

Branch: refs/heads/MATH_3_X
Commit: 6814a35ce6ce23001bc261dcb0f2f1c46306b7da
Parents: 6b4bf61
Author: Luc Maisonobe <lu...@apache.org>
Authored: Fri Dec 25 14:58:28 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Fri Dec 25 14:58:28 2015 +0100

----------------------------------------------------------------------
 .../interpolation/PiecewiseBicubicSplineInterpolatorTest.java      | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/6814a35c/src/test/java/org/apache/commons/math3/analysis/interpolation/PiecewiseBicubicSplineInterpolatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/analysis/interpolation/PiecewiseBicubicSplineInterpolatorTest.java b/src/test/java/org/apache/commons/math3/analysis/interpolation/PiecewiseBicubicSplineInterpolatorTest.java
index 367971b..08e1b69 100644
--- a/src/test/java/org/apache/commons/math3/analysis/interpolation/PiecewiseBicubicSplineInterpolatorTest.java
+++ b/src/test/java/org/apache/commons/math3/analysis/interpolation/PiecewiseBicubicSplineInterpolatorTest.java
@@ -18,7 +18,6 @@ package org.apache.commons.math3.analysis.interpolation;
 
 import org.apache.commons.math3.exception.DimensionMismatchException;
 import org.apache.commons.math3.exception.InsufficientDataException;
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
 import org.apache.commons.math3.exception.NonMonotonicSequenceException;
 import org.apache.commons.math3.exception.NullArgumentException;
 import org.apache.commons.math3.analysis.BivariateFunction;
@@ -41,7 +40,6 @@ public final class PiecewiseBicubicSplineInterpolatorTest {
         double[] yval = new double[] { -4, -3, -1, 2.5, 3.5 };
         double[][] zval = new double[xval.length][yval.length];
 
-        @SuppressWarnings( "unused" )
         BivariateGridInterpolator interpolator = new PiecewiseBicubicSplineInterpolator();
 
         try {


[4/4] [math] Replaced deprecated Incrementor with IntegerSequence.Incrementor where possible.

Posted by lu...@apache.org.
Replaced deprecated Incrementor with IntegerSequence.Incrementor where possible.


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

Branch: refs/heads/MATH_3_X
Commit: ee504b64afb1f7a0341c57aa7bd3c798e444c8c0
Parents: 6814a35
Author: Luc Maisonobe <lu...@apache.org>
Authored: Fri Dec 25 14:59:41 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Fri Dec 25 14:59:41 2015 +0100

----------------------------------------------------------------------
 .../BaseAbstractUnivariateIntegrator.java       | 41 +++++++++-----
 .../IterativeLegendreGaussIntegrator.java       |  4 +-
 .../integration/LegendreGaussIntegrator.java    |  4 +-
 .../integration/MidPointIntegrator.java         |  4 +-
 .../analysis/integration/RombergIntegrator.java |  8 +--
 .../analysis/integration/SimpsonIntegrator.java |  6 +--
 .../integration/TrapezoidIntegrator.java        |  6 +--
 .../solvers/BaseAbstractUnivariateSolver.java   | 14 ++---
 .../commons/math3/ode/AbstractIntegrator.java   | 19 +------
 .../math3/optim/univariate/BracketFinder.java   | 10 ++--
 .../apache/commons/math3/util/Incrementor.java  | 57 ++++++++++++++++++++
 .../commons/math3/util/IterationManager.java    | 32 +++++++++--
 12 files changed, 142 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/ee504b64/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java b/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java
index 23c25b0..b2ca165 100644
--- a/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java
@@ -24,7 +24,7 @@ import org.apache.commons.math3.exception.NotStrictlyPositiveException;
 import org.apache.commons.math3.exception.NullArgumentException;
 import org.apache.commons.math3.exception.NumberIsTooSmallException;
 import org.apache.commons.math3.exception.TooManyEvaluationsException;
-import org.apache.commons.math3.util.Incrementor;
+import org.apache.commons.math3.util.IntegerSequence;
 import org.apache.commons.math3.util.MathUtils;
 
 /**
@@ -46,8 +46,14 @@ public abstract class BaseAbstractUnivariateIntegrator implements UnivariateInte
     /** Default maximal iteration count. */
     public static final int DEFAULT_MAX_ITERATIONS_COUNT = Integer.MAX_VALUE;
 
+    /** The iteration count.
+     * @deprecated as of 3.6, this field has been replaced with {@link #incrementCount()}
+     */
+    @Deprecated
+    protected org.apache.commons.math3.util.Incrementor iterations;
+
     /** The iteration count. */
-    protected final Incrementor iterations;
+    private IntegerSequence.Incrementor count;
 
     /** Maximum absolute error. */
     private final double absoluteAccuracy;
@@ -59,7 +65,7 @@ public abstract class BaseAbstractUnivariateIntegrator implements UnivariateInte
     private final int minimalIterationCount;
 
     /** The functions evaluation count. */
-    private final Incrementor evaluations;
+    private IntegerSequence.Incrementor evaluations;
 
     /** Function to integrate. */
     private UnivariateFunction function;
@@ -123,11 +129,15 @@ public abstract class BaseAbstractUnivariateIntegrator implements UnivariateInte
             throw new NumberIsTooSmallException(maximalIterationCount, minimalIterationCount, false);
         }
         this.minimalIterationCount = minimalIterationCount;
-        this.iterations            = new Incrementor();
-        iterations.setMaximalCount(maximalIterationCount);
+        this.count                 = IntegerSequence.Incrementor.create().withMaximalCount(maximalIterationCount);
+
+        @SuppressWarnings("deprecation")
+        org.apache.commons.math3.util.Incrementor wrapped =
+                        org.apache.commons.math3.util.Incrementor.wrap(count);
+        this.iterations = wrapped;
 
         // prepare evaluations counter, but do not set it yet
-        evaluations = new Incrementor();
+        evaluations = IntegerSequence.Incrementor.create();
 
     }
 
@@ -175,7 +185,7 @@ public abstract class BaseAbstractUnivariateIntegrator implements UnivariateInte
 
     /** {@inheritDoc} */
     public int getMaximalIterationCount() {
-        return iterations.getMaximalCount();
+        return count.getMaximalCount();
     }
 
     /** {@inheritDoc} */
@@ -185,7 +195,15 @@ public abstract class BaseAbstractUnivariateIntegrator implements UnivariateInte
 
     /** {@inheritDoc} */
     public int getIterations() {
-        return iterations.getCount();
+        return count.getCount();
+    }
+
+    /** Increment the number of iterations.
+     * @exception MaxCountExceededException if the number of iterations
+     * exceeds the allowed maximum number
+     */
+    protected void incrementCount() throws MaxCountExceededException {
+        count.increment();
     }
 
     /**
@@ -212,7 +230,7 @@ public abstract class BaseAbstractUnivariateIntegrator implements UnivariateInte
     protected double computeObjectiveValue(final double point)
         throws TooManyEvaluationsException {
         try {
-            evaluations.incrementCount();
+            evaluations.increment();
         } catch (MaxCountExceededException e) {
             throw new TooManyEvaluationsException(e.getMax());
         }
@@ -244,9 +262,8 @@ public abstract class BaseAbstractUnivariateIntegrator implements UnivariateInte
         min = lower;
         max = upper;
         function = f;
-        evaluations.setMaximalCount(maxEval);
-        evaluations.resetCount();
-        iterations.resetCount();
+        evaluations = evaluations.withMaximalCount(maxEval).withStart(0);
+        count       = count.withStart(0);
 
     }
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ee504b64/src/main/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegrator.java b/src/main/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegrator.java
index 86be02c..d08cf08 100644
--- a/src/main/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegrator.java
@@ -133,7 +133,7 @@ public class IterativeLegendreGaussIntegrator
                              getRelativeAccuracy() * (FastMath.abs(oldt) + FastMath.abs(t)) * 0.5);
 
             // check convergence
-            if (iterations.getCount() + 1 >= getMinimalIterationCount() &&
+            if (getIterations() + 1 >= getMinimalIterationCount() &&
                 delta <= limit) {
                 return t;
             }
@@ -142,7 +142,7 @@ public class IterativeLegendreGaussIntegrator
             final double ratio = FastMath.min(4, FastMath.pow(delta / limit, 0.5 / numberOfPoints));
             n = FastMath.max((int) (ratio * n), n + 1);
             oldt = t;
-            iterations.incrementCount();
+            incrementCount();;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ee504b64/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java b/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java
index 08f4794..bfb24a1 100644
--- a/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java
@@ -220,7 +220,7 @@ public class LegendreGaussIntegrator extends BaseAbstractUnivariateIntegrator {
                              getRelativeAccuracy() * (FastMath.abs(oldt) + FastMath.abs(t)) * 0.5);
 
             // check convergence
-            if ((iterations.getCount() + 1 >= getMinimalIterationCount()) && (delta <= limit)) {
+            if ((getIterations() + 1 >= getMinimalIterationCount()) && (delta <= limit)) {
                 return t;
             }
 
@@ -228,7 +228,7 @@ public class LegendreGaussIntegrator extends BaseAbstractUnivariateIntegrator {
             double ratio = FastMath.min(4, FastMath.pow(delta / limit, 0.5 / abscissas.length));
             n = FastMath.max((int) (ratio * n), n + 1);
             oldt = t;
-            iterations.incrementCount();
+            incrementCount();
 
         }
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ee504b64/src/main/java/org/apache/commons/math3/analysis/integration/MidPointIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/analysis/integration/MidPointIntegrator.java b/src/main/java/org/apache/commons/math3/analysis/integration/MidPointIntegrator.java
index aaea286..766a917 100644
--- a/src/main/java/org/apache/commons/math3/analysis/integration/MidPointIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/integration/MidPointIntegrator.java
@@ -150,8 +150,8 @@ public class MidPointIntegrator extends BaseAbstractUnivariateIntegrator {
         double oldt = diff * computeObjectiveValue(midPoint);
 
         while (true) {
-            iterations.incrementCount();
-            final int i = iterations.getCount();
+            incrementCount();
+            final int i = getIterations();
             final double t = stage(i, oldt, min, diff);
             if (i >= getMinimalIterationCount()) {
                 final double delta = FastMath.abs(t - oldt);

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ee504b64/src/main/java/org/apache/commons/math3/analysis/integration/RombergIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/analysis/integration/RombergIntegrator.java b/src/main/java/org/apache/commons/math3/analysis/integration/RombergIntegrator.java
index 430cd6e..125d251 100644
--- a/src/main/java/org/apache/commons/math3/analysis/integration/RombergIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/integration/RombergIntegrator.java
@@ -101,17 +101,17 @@ public class RombergIntegrator extends BaseAbstractUnivariateIntegrator {
     protected double doIntegrate()
         throws TooManyEvaluationsException, MaxCountExceededException {
 
-        final int m = iterations.getMaximalCount() + 1;
+        final int m = getMaximalIterationCount() + 1;
         double previousRow[] = new double[m];
         double currentRow[]  = new double[m];
 
         TrapezoidIntegrator qtrap = new TrapezoidIntegrator();
         currentRow[0] = qtrap.stage(this, 0);
-        iterations.incrementCount();
+        incrementCount();
         double olds = currentRow[0];
         while (true) {
 
-            final int i = iterations.getCount();
+            final int i = getIterations();
 
             // switch rows
             final double[] tmpRow = previousRow;
@@ -119,7 +119,7 @@ public class RombergIntegrator extends BaseAbstractUnivariateIntegrator {
             currentRow = tmpRow;
 
             currentRow[0] = qtrap.stage(this, i);
-            iterations.incrementCount();
+            incrementCount();
             for (int j = 1; j <= i; j++) {
                 // Richardson extrapolation coefficient
                 final double r = (1L << (2 * j)) - 1;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ee504b64/src/main/java/org/apache/commons/math3/analysis/integration/SimpsonIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/analysis/integration/SimpsonIntegrator.java b/src/main/java/org/apache/commons/math3/analysis/integration/SimpsonIntegrator.java
index b13ff5f..527bb82 100644
--- a/src/main/java/org/apache/commons/math3/analysis/integration/SimpsonIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/integration/SimpsonIntegrator.java
@@ -109,10 +109,10 @@ public class SimpsonIntegrator extends BaseAbstractUnivariateIntegrator {
         double olds = 0;
         double oldt = qtrap.stage(this, 0);
         while (true) {
-            final double t = qtrap.stage(this, iterations.getCount());
-            iterations.incrementCount();
+            final double t = qtrap.stage(this, getIterations());
+            incrementCount();
             final double s = (4 * t - oldt) / 3.0;
-            if (iterations.getCount() >= getMinimalIterationCount()) {
+            if (getIterations() >= getMinimalIterationCount()) {
                 final double delta = FastMath.abs(s - olds);
                 final double rLimit =
                     getRelativeAccuracy() * (FastMath.abs(olds) + FastMath.abs(s)) * 0.5;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ee504b64/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java b/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java
index d22d12d..8a737f1 100644
--- a/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java
@@ -147,9 +147,9 @@ public class TrapezoidIntegrator extends BaseAbstractUnivariateIntegrator {
         throws MathIllegalArgumentException, TooManyEvaluationsException, MaxCountExceededException {
 
         double oldt = stage(this, 0);
-        iterations.incrementCount();
+        incrementCount();
         while (true) {
-            final int i = iterations.getCount();
+            final int i = getIterations();
             final double t = stage(this, i);
             if (i >= getMinimalIterationCount()) {
                 final double delta = FastMath.abs(t - oldt);
@@ -160,7 +160,7 @@ public class TrapezoidIntegrator extends BaseAbstractUnivariateIntegrator {
                 }
             }
             oldt = t;
-            iterations.incrementCount();
+            incrementCount();
         }
 
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ee504b64/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java b/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java
index 4fb9ecf..12b30c6 100644
--- a/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java
+++ b/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java
@@ -23,7 +23,7 @@ import org.apache.commons.math3.exception.NoBracketingException;
 import org.apache.commons.math3.exception.TooManyEvaluationsException;
 import org.apache.commons.math3.exception.NumberIsTooLargeException;
 import org.apache.commons.math3.exception.NullArgumentException;
-import org.apache.commons.math3.util.Incrementor;
+import org.apache.commons.math3.util.IntegerSequence;
 import org.apache.commons.math3.util.MathUtils;
 
 /**
@@ -51,7 +51,7 @@ public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFuncti
     /** Relative accuracy. */
     private final double relativeAccuracy;
     /** Evaluations counter. */
-    private final Incrementor evaluations = new Incrementor();
+    private IntegerSequence.Incrementor evaluations;
     /** Lower end of search interval. */
     private double searchMin;
     /** Higher end of search interval. */
@@ -95,9 +95,10 @@ public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFuncti
     protected BaseAbstractUnivariateSolver(final double relativeAccuracy,
                                            final double absoluteAccuracy,
                                            final double functionValueAccuracy) {
-        this.absoluteAccuracy = absoluteAccuracy;
-        this.relativeAccuracy = relativeAccuracy;
+        this.absoluteAccuracy      = absoluteAccuracy;
+        this.relativeAccuracy      = relativeAccuracy;
         this.functionValueAccuracy = functionValueAccuracy;
+        this.evaluations           = IntegerSequence.Incrementor.create();
     }
 
     /** {@inheritDoc} */
@@ -184,8 +185,7 @@ public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFuncti
         searchMax = max;
         searchStart = startValue;
         function = f;
-        evaluations.setMaximalCount(maxEval);
-        evaluations.resetCount();
+        evaluations = evaluations.withMaximalCount(maxEval).withStart(0);
     }
 
     /** {@inheritDoc} */
@@ -310,7 +310,7 @@ public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFuncti
     protected void incrementEvaluationCount()
         throws TooManyEvaluationsException {
         try {
-            evaluations.incrementCount();
+            evaluations.increment();
         } catch (MaxCountExceededException e) {
             throw new TooManyEvaluationsException(e.getMax());
         }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ee504b64/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java b/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java
index 835689b..e080722 100644
--- a/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java
@@ -219,24 +219,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
      */
     @Deprecated
     protected org.apache.commons.math3.util.Incrementor getEvaluationsCounter() {
-        final org.apache.commons.math3.util.Incrementor incrementor =
-            new org.apache.commons.math3.util.Incrementor() {
-
-            {
-                // set up matching values at initialization
-                super.setMaximalCount(evaluations.getMaximalCount());
-                super.incrementCount(evaluations.getCount());
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public void incrementCount() {
-                super.incrementCount();
-                evaluations.increment();
-            }
-
-        };
-        return incrementor;
+        return org.apache.commons.math3.util.Incrementor.wrap(evaluations);
     }
 
     /** Get the evaluations counter.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ee504b64/src/main/java/org/apache/commons/math3/optim/univariate/BracketFinder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/optim/univariate/BracketFinder.java b/src/main/java/org/apache/commons/math3/optim/univariate/BracketFinder.java
index 414a1bb..6d42c0d 100644
--- a/src/main/java/org/apache/commons/math3/optim/univariate/BracketFinder.java
+++ b/src/main/java/org/apache/commons/math3/optim/univariate/BracketFinder.java
@@ -17,7 +17,7 @@
 package org.apache.commons.math3.optim.univariate;
 
 import org.apache.commons.math3.util.FastMath;
-import org.apache.commons.math3.util.Incrementor;
+import org.apache.commons.math3.util.IntegerSequence;
 import org.apache.commons.math3.exception.NotStrictlyPositiveException;
 import org.apache.commons.math3.exception.TooManyEvaluationsException;
 import org.apache.commons.math3.exception.MaxCountExceededException;
@@ -45,7 +45,7 @@ public class BracketFinder {
     /**
      * Counter for function evaluations.
      */
-    private final Incrementor evaluations = new Incrementor();
+    private IntegerSequence.Incrementor evaluations;
     /**
      * Lower bound of the bracket.
      */
@@ -96,7 +96,7 @@ public class BracketFinder {
         }
 
         this.growLimit = growLimit;
-        evaluations.setMaximalCount(maxEvaluations);
+        evaluations = IntegerSequence.Incrementor.create().withMaximalCount(maxEvaluations);
     }
 
     /**
@@ -113,7 +113,7 @@ public class BracketFinder {
                        GoalType goal,
                        double xA,
                        double xB) {
-        evaluations.resetCount();
+        evaluations = evaluations.withStart(0);
         final boolean isMinim = goal == GoalType.MINIMIZE;
 
         double fA = eval(func, xA);
@@ -281,7 +281,7 @@ public class BracketFinder {
      */
     private double eval(UnivariateFunction f, double x) {
         try {
-            evaluations.incrementCount();
+            evaluations.increment();
         } catch (MaxCountExceededException e) {
             throw new TooManyEvaluationsException(e.getMax());
         }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ee504b64/src/main/java/org/apache/commons/math3/util/Incrementor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/util/Incrementor.java b/src/main/java/org/apache/commons/math3/util/Incrementor.java
index 3d11954..70995c5 100644
--- a/src/main/java/org/apache/commons/math3/util/Incrementor.java
+++ b/src/main/java/org/apache/commons/math3/util/Incrementor.java
@@ -178,4 +178,61 @@ public class Incrementor {
          */
         void trigger(int maximalCount) throws MaxCountExceededException;
     }
+
+    /** Create an instance that delegates everything to a {@link IntegerSequence.Incrementor}.
+     * <p>
+     * This factory method is intended only as a temporary hack for internal use in
+     * Apache Commons Math 3.X series, when {@code Incrementor} is required in
+     * interface (as a return value or in protected fields). It should <em>not</em>
+     * be used in other cases. The {@link IntegerSequence.Incrementor} class should
+     * be used instead of {@code Incrementor}.
+     * </p>
+     * <p>
+     * All methods are mirrored to the underlying {@link IntegerSequence.Incrementor},
+     * as long as neither {@link #setMaximalCount(int)} nor {@link #resetCount()} are called.
+     * If one of these two methods is called, the created instance becomes independent
+     * of the {@link IntegerSequence.Incrementor} used at creation. The rationale is that
+     * {@link IntegerSequence.Incrementor} cannot change their maximal count and cannot be reset.
+     * </p>
+     * @param incrementor wrapped {@link IntegerSequence.Incrementor}
+     * @return an incrementor wrapping an {@link IntegerSequence.Incrementor}
+     * @since 3.6
+     */
+    public static Incrementor wrap(final IntegerSequence.Incrementor incrementor) {
+        return new Incrementor() {
+
+            /** Underlying incrementor. */
+            private IntegerSequence.Incrementor delegate;
+
+            {
+                // set up matching values at initialization
+                delegate = incrementor;
+                super.setMaximalCount(delegate.getMaximalCount());
+                super.incrementCount(delegate.getCount());
+            }
+
+            /** {@inheritDoc} */
+            @Override
+            public void setMaximalCount(int max) {
+                super.setMaximalCount(max);
+                delegate = delegate.withMaximalCount(max);
+            }
+
+            /** {@inheritDoc} */
+            @Override
+            public void resetCount() {
+                super.resetCount();
+                delegate = delegate.withStart(0);
+            }
+
+            /** {@inheritDoc} */
+            @Override
+            public void incrementCount() {
+                super.incrementCount();
+                delegate.increment();
+            }
+
+        };
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ee504b64/src/main/java/org/apache/commons/math3/util/IterationManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/util/IterationManager.java b/src/main/java/org/apache/commons/math3/util/IterationManager.java
index 1a80d3a..ffda23e 100644
--- a/src/main/java/org/apache/commons/math3/util/IterationManager.java
+++ b/src/main/java/org/apache/commons/math3/util/IterationManager.java
@@ -31,7 +31,7 @@ import org.apache.commons.math3.exception.MaxCountExceededException;
 public class IterationManager {
 
     /** Keeps a count of the number of iterations. */
-    private final Incrementor iterations;
+    private IntegerSequence.Incrementor iterations;
 
     /** The collection of all listeners attached to this iterative algorithm. */
     private final Collection<IterationListener> listeners;
@@ -42,7 +42,7 @@ public class IterationManager {
      * @param maxIterations the maximum number of iterations
      */
     public IterationManager(final int maxIterations) {
-        this.iterations = new Incrementor(maxIterations);
+        this.iterations = IntegerSequence.Incrementor.create().withMaximalCount(maxIterations);
         this.listeners = new CopyOnWriteArrayList<IterationListener>();
     }
 
@@ -54,10 +54,32 @@ public class IterationManager {
      * iterations has been reached
      * @throws org.apache.commons.math3.exception.NullArgumentException if {@code callBack} is {@code null}
      * @since 3.1
+     * @deprecated as of 3.6, replaced with {@link #IterationManager(int,
+     * org.apache.commons.math3.util.IntegerSequence.Incrementor.MaxCountExceededCallback)}
      */
+    @Deprecated
     public IterationManager(final int maxIterations,
                             final Incrementor.MaxCountExceededCallback callBack) {
-        this.iterations = new Incrementor(maxIterations, callBack);
+        this(maxIterations, new IntegerSequence.Incrementor.MaxCountExceededCallback() {
+            @Override
+            public void trigger(final int maximalCount) throws MaxCountExceededException {
+                callBack.trigger(maximalCount);
+            }
+        });
+    }
+
+    /**
+     * Creates a new instance of this class.
+     *
+     * @param maxIterations the maximum number of iterations
+     * @param callBack the function to be called when the maximum number of
+     * iterations has been reached
+     * @throws org.apache.commons.math3.exception.NullArgumentException if {@code callBack} is {@code null}
+     * @since 3.6
+     */
+    public IterationManager(final int maxIterations,
+                            final IntegerSequence.Incrementor.MaxCountExceededCallback callBack) {
+        this.iterations = IntegerSequence.Incrementor.create().withMaximalCount(maxIterations).withCallback(callBack);
         this.listeners = new CopyOnWriteArrayList<IterationListener>();
     }
 
@@ -147,7 +169,7 @@ public class IterationManager {
      */
     public void incrementIterationCount()
         throws MaxCountExceededException {
-        iterations.incrementCount();
+        iterations.increment();
     }
 
     /**
@@ -167,6 +189,6 @@ public class IterationManager {
      * initial phase.
      */
     public void resetIterationCount() {
-        iterations.resetCount();
+        iterations = iterations.withStart(0);
     }
 }