You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2022/10/13 12:42:39 UTC

[commons-math] 05/23: Use diamond operator

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git

commit a8d392580d3ceb89456ca450003a422f148e6555
Author: aherbert <ah...@apache.org>
AuthorDate: Thu Oct 13 11:36:34 2022 +0100

    Use diamond operator
---
 .../commons/math4/examples/kmeans/image/StandAlone.java  | 16 ++++++++--------
 .../legacy/distribution/EnumeratedDistribution.java      |  2 +-
 .../math4/legacy/ml/clustering/FuzzyKMeansClusterer.java |  4 ++--
 .../legacy/ml/clustering/KMeansPlusPlusClusterer.java    |  2 +-
 .../org/apache/commons/math4/legacy/stat/Frequency.java  |  2 +-
 .../analysis/integration/gauss/BaseRuleFactoryTest.java  |  2 +-
 .../AbstractLeastSquaresOptimizerAbstractTest.java       |  2 +-
 .../legacy/fitting/leastsquares/EvaluationTest.java      |  6 +++---
 .../math4/legacy/genetics/CycleCrossoverTest.java        | 10 +++++-----
 .../math4/legacy/genetics/FitnessCachingTest.java        |  2 +-
 .../legacy/genetics/GeneticAlgorithmTestBinary.java      |  2 +-
 .../genetics/GeneticAlgorithmTestPermutations.java       |  2 +-
 .../math4/legacy/genetics/NPointCrossoverTest.java       |  8 ++++----
 .../math4/legacy/genetics/OrderedCrossoverTest.java      |  8 ++++----
 .../math4/legacy/genetics/UniformCrossoverTest.java      | 12 ++++++------
 .../math4/legacy/linear/OpenIntToDoubleHashMapTest.java  |  2 +-
 .../commons/math4/legacy/linear/OpenIntToFieldTest.java  |  2 +-
 .../math4/legacy/ml/clustering/DBSCANClustererTest.java  |  4 ++--
 .../legacy/ml/clustering/FuzzyKMeansClustererTest.java   |  2 +-
 .../ml/clustering/MultiKMeansPlusPlusClustererTest.java  |  2 +-
 .../math4/legacy/ode/ContinuousOutputFieldModelTest.java |  4 ++--
 .../scalar/MultivariateFunctionPenaltyAdapterTest.java   |  2 +-
 .../apache/commons/math4/legacy/stat/FrequencyTest.java  |  4 ++--
 .../math4/userguide/ClusterAlgorithmComparison.java      | 14 +++++++-------
 .../userguide/LowDiscrepancyGeneratorComparison.java     | 10 +++++-----
 .../math4/userguide/filter/CannonballExample.java        | 12 ++++++------
 .../math4/userguide/filter/ConstantVoltageExample.java   | 10 +++++-----
 .../math4/userguide/genetics/HelloWorldExample.java      |  6 +++---
 .../math4/userguide/genetics/ImageEvolutionExample.java  |  4 ++--
 .../math4/userguide/genetics/PolygonChromosome.java      |  2 +-
 .../math4/userguide/genetics/RandomPolygonMutation.java  |  2 +-
 31 files changed, 81 insertions(+), 81 deletions(-)

diff --git a/commons-math-examples/examples-kmeans/image/src/main/java/org/apache/commons/math4/examples/kmeans/image/StandAlone.java b/commons-math-examples/examples-kmeans/image/src/main/java/org/apache/commons/math4/examples/kmeans/image/StandAlone.java
index f0081e7ad..4a3678ba0 100644
--- a/commons-math-examples/examples-kmeans/image/src/main/java/org/apache/commons/math4/examples/kmeans/image/StandAlone.java
+++ b/commons-math-examples/examples-kmeans/image/src/main/java/org/apache/commons/math4/examples/kmeans/image/StandAlone.java
@@ -72,16 +72,16 @@ public final class StandAlone implements Callable<Void> {
         final DistanceMeasure distance = new EuclideanDistance();
 
         cluster(image,
-                new ElkanKMeansPlusPlusClusterer<ImageData.PixelClusterable>(numClusters,
-                                                                             maxIter,
-                                                                             distance,
-                                                                             rng),
+                new ElkanKMeansPlusPlusClusterer<>(numClusters,
+                                                   maxIter,
+                                                   distance,
+                                                   rng),
                 "elkan");
         cluster(image,
-                new KMeansPlusPlusClusterer<ImageData.PixelClusterable>(numClusters,
-                                                                        maxIter,
-                                                                        distance,
-                                                                        rng),
+                new KMeansPlusPlusClusterer<>(numClusters,
+                                              maxIter,
+                                              distance,
+                                              rng),
                 "kmeans");
 
         return null;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedDistribution.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedDistribution.java
index 45bdade54..9d406dc14 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedDistribution.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedDistribution.java
@@ -189,7 +189,7 @@ public class EnumeratedDistribution<T> {
          * @param rng Random number generator.
          */
         Sampler(UniformRandomProvider rng) {
-            sampler = new DiscreteProbabilityCollectionSampler<T>(rng, singletons, probabilities);
+            sampler = new DiscreteProbabilityCollectionSampler<>(rng, singletons, probabilities);
         }
 
         /**
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ml/clustering/FuzzyKMeansClusterer.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ml/clustering/FuzzyKMeansClusterer.java
index 973a07ce8..0299ac0b2 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ml/clustering/FuzzyKMeansClusterer.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ml/clustering/FuzzyKMeansClusterer.java
@@ -289,7 +289,7 @@ public class FuzzyKMeansClusterer<T extends Clusterable> extends Clusterer<T> {
         // there is at least one point
         final int pointDimension = points.get(0).getPoint().length;
         for (int i = 0; i < k; i++) {
-            clusters.add(new CentroidCluster<T>(new DoublePoint(new double[pointDimension])));
+            clusters.add(new CentroidCluster<>(new DoublePoint(new double[pointDimension])));
         }
 
         int iteration = 0;
@@ -327,7 +327,7 @@ public class FuzzyKMeansClusterer<T extends Clusterable> extends Clusterer<T> {
                 i++;
             }
             MathArrays.scaleInPlace(1.0 / sum, arr);
-            newClusters.add(new CentroidCluster<T>(new DoublePoint(arr)));
+            newClusters.add(new CentroidCluster<>(new DoublePoint(arr)));
             j++;
         }
         clusters.clear();
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ml/clustering/KMeansPlusPlusClusterer.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ml/clustering/KMeansPlusPlusClusterer.java
index c7b2caafe..7126c47f0 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ml/clustering/KMeansPlusPlusClusterer.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ml/clustering/KMeansPlusPlusClusterer.java
@@ -319,7 +319,7 @@ public class KMeansPlusPlusClusterer<T extends Clusterable> extends Clusterer<T>
 
         final T firstPoint = pointList.get(firstPointIndex);
 
-        resultSet.add(new CentroidCluster<T>(firstPoint));
+        resultSet.add(new CentroidCluster<>(firstPoint));
 
         // Must mark it as taken
         taken[firstPointIndex] = true;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/Frequency.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/Frequency.java
index 06633c33f..c6da2a7e9 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/Frequency.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/Frequency.java
@@ -208,7 +208,7 @@ public class Frequency<T extends Comparable<T>> {
         }
         Comparator<? super T> c = freqTable.comparator();
         if (c == null) {
-            c = new NaturalComparator<T>();
+            c = new NaturalComparator<>();
         }
         long result = 0;
 
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/BaseRuleFactoryTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/BaseRuleFactoryTest.java
index 42948ead2..699bdbdb2 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/BaseRuleFactoryTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/BaseRuleFactoryTest.java
@@ -47,7 +47,7 @@ public class BaseRuleFactoryTest {
 
         final ThreadPoolExecutor exec
             = new ThreadPoolExecutor(3, numTasks, 1, TimeUnit.SECONDS,
-                                     new ArrayBlockingQueue<Runnable>(2));
+                                     new ArrayBlockingQueue<>(2));
 
         final List<Future<Pair<double[], double[]>>> results
             = new ArrayList<>();
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
index 00fc3bb88..afb479c92 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
@@ -125,7 +125,7 @@ public abstract class AbstractLeastSquaresOptimizerAbstractTest {
                 .model(new MultivariateJacobianFunction() {
                     @Override
                     public Pair<RealVector, RealMatrix> value(final RealVector point) {
-                        return new Pair<RealVector, RealMatrix>(
+                        return new Pair<>(
                                 new ArrayRealVector(
                                         new double[]{
                                                 JdkMath.pow(point.getEntry(0), 4)
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationTest.java
index 4836ac75c..145320dc9 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationTest.java
@@ -73,7 +73,7 @@ public class EvaluationTest {
                 .model(new MultivariateJacobianFunction() {
                     @Override
                     public Pair<RealVector, RealMatrix> value(RealVector point) {
-                        return new Pair<RealVector, RealMatrix>(
+                        return new Pair<>(
                                 new ArrayRealVector(new double[]{1, 2}),
                                 MatrixUtils.createRealIdentityMatrix(2)
                         );
@@ -98,7 +98,7 @@ public class EvaluationTest {
                 .model(new MultivariateJacobianFunction() {
                     @Override
                     public Pair<RealVector, RealMatrix> value(RealVector point) {
-                        return new Pair<RealVector, RealMatrix>(
+                        return new Pair<>(
                                 new ArrayRealVector(2),
                                 MatrixUtils.createRealDiagonalMatrix(new double[]{1, 1e-2})
                         );
@@ -139,7 +139,7 @@ public class EvaluationTest {
                         Assert.assertArrayEquals(
                                 point.toArray(), actualPoint.toArray(), Precision.EPSILON);
                         //return values
-                        return new Pair<RealVector, RealMatrix>(
+                        return new Pair<>(
                                 new ArrayRealVector(new double[]{3, 4}),
                                 MatrixUtils.createRealMatrix(new double[][]{{5, 6}, {7, 8}})
                         );
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/CycleCrossoverTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/CycleCrossoverTest.java
index 91b3880e9..35bd9e9e4 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/CycleCrossoverTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/CycleCrossoverTest.java
@@ -31,7 +31,7 @@ public class CycleCrossoverTest {
         final DummyListChromosome p1c = new DummyListChromosome(p1);
         final DummyListChromosome p2c = new DummyListChromosome(p2);
 
-        final CrossoverPolicy cp = new CycleCrossover<Integer>();
+        final CrossoverPolicy cp = new CycleCrossover<>();
         final ChromosomePair pair = cp.crossover(p1c, p2c);
 
         final Integer[] c1 = ((DummyListChromosome) pair.getFirst()).getRepresentation().toArray(new Integer[p1.length]);
@@ -52,7 +52,7 @@ public class CycleCrossoverTest {
         final DummyListChromosome p1c = new DummyListChromosome(p1);
         final DummyListChromosome p2c = new DummyListChromosome(p2);
 
-        final CrossoverPolicy cp = new CycleCrossover<Integer>();
+        final CrossoverPolicy cp = new CycleCrossover<>();
         final ChromosomePair pair = cp.crossover(p1c, p2c);
 
         final Integer[] c1 = ((DummyListChromosome) pair.getFirst()).getRepresentation().toArray(new Integer[p1.length]);
@@ -113,7 +113,7 @@ public class CycleCrossoverTest {
         final BinaryChromosome p1c = new DummyBinaryChromosome(p1);
         final BinaryChromosome p2c = new DummyBinaryChromosome(p2);
 
-        final CrossoverPolicy cp = new CycleCrossover<Integer>();
+        final CrossoverPolicy cp = new CycleCrossover<>();
         cp.crossover(p1c, p2c);
     }
 
@@ -129,7 +129,7 @@ public class CycleCrossoverTest {
             }
         };
 
-        final CrossoverPolicy cp = new CycleCrossover<Integer>();
+        final CrossoverPolicy cp = new CycleCrossover<>();
         cp.crossover(p1c, p2c);
     }
 
@@ -145,7 +145,7 @@ public class CycleCrossoverTest {
             }
         };
 
-        final CrossoverPolicy cp = new CycleCrossover<Integer>();
+        final CrossoverPolicy cp = new CycleCrossover<>();
         cp.crossover(p1c, p2c);
     }
 }
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/FitnessCachingTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/FitnessCachingTest.java
index 13dd488ea..69df3ca97 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/FitnessCachingTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/FitnessCachingTest.java
@@ -44,7 +44,7 @@ public class FitnessCachingTest {
     public void testFitnessCaching() {
         // initialize a new genetic algorithm
         GeneticAlgorithm ga = new GeneticAlgorithm(
-                new OnePointCrossover<Integer>(),
+                new OnePointCrossover<>(),
                 CROSSOVER_RATE, // all selected chromosomes will be recombined (=crosssover)
                 new BinaryMutation(),
                 MUTATION_RATE, // no mutation
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/GeneticAlgorithmTestBinary.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/GeneticAlgorithmTestBinary.java
index 5465cd09a..63e93f7d3 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/GeneticAlgorithmTestBinary.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/GeneticAlgorithmTestBinary.java
@@ -43,7 +43,7 @@ public class GeneticAlgorithmTestBinary {
 
         // initialize a new genetic algorithm
         GeneticAlgorithm ga = new GeneticAlgorithm(
-                new OnePointCrossover<Integer>(),
+                new OnePointCrossover<>(),
                 CROSSOVER_RATE, // all selected chromosomes will be recombined (=crossover)
                 new BinaryMutation(),
                 MUTATION_RATE,
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/GeneticAlgorithmTestPermutations.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/GeneticAlgorithmTestPermutations.java
index 2097c41ad..eef810139 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/GeneticAlgorithmTestPermutations.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/GeneticAlgorithmTestPermutations.java
@@ -55,7 +55,7 @@ public class GeneticAlgorithmTestPermutations {
 
         // initialize a new genetic algorithm
         GeneticAlgorithm ga = new GeneticAlgorithm(
-                new OnePointCrossover<Integer>(),
+                new OnePointCrossover<>(),
                 CROSSOVER_RATE,
                 new RandomKeyMutation(),
                 MUTATION_RATE,
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/NPointCrossoverTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/NPointCrossoverTest.java
index d1a2c734b..b33f2a063 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/NPointCrossoverTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/NPointCrossoverTest.java
@@ -34,7 +34,7 @@ public class NPointCrossoverTest {
         final BinaryChromosome p1c = new DummyBinaryChromosome(p1);
         final BinaryChromosome p2c = new DummyBinaryChromosome(p2);
 
-        final CrossoverPolicy cp = new NPointCrossover<Integer>(1);
+        final CrossoverPolicy cp = new NPointCrossover<>(1);
         cp.crossover(p1c,p2c);
     }
 
@@ -46,7 +46,7 @@ public class NPointCrossoverTest {
         final BinaryChromosome p1c = new DummyBinaryChromosome(p1);
         final BinaryChromosome p2c = new DummyBinaryChromosome(p2);
 
-        final CrossoverPolicy cp = new NPointCrossover<Integer>(15);
+        final CrossoverPolicy cp = new NPointCrossover<>(15);
         cp.crossover(p1c,p2c);
     }
 
@@ -62,7 +62,7 @@ public class NPointCrossoverTest {
             }
         };
 
-        final CrossoverPolicy cp = new NPointCrossover<Integer>(1);
+        final CrossoverPolicy cp = new NPointCrossover<>(1);
         cp.crossover(p1c,p2c);
     }
 
@@ -78,7 +78,7 @@ public class NPointCrossoverTest {
             }
         };
 
-        final CrossoverPolicy cp = new NPointCrossover<Integer>(1);
+        final CrossoverPolicy cp = new NPointCrossover<>(1);
         cp.crossover(p1c,p2c);
     }
 
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/OrderedCrossoverTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/OrderedCrossoverTest.java
index e55cdc102..428d567bd 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/OrderedCrossoverTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/OrderedCrossoverTest.java
@@ -34,7 +34,7 @@ public class OrderedCrossoverTest {
         final DummyListChromosome p1c = new DummyListChromosome(p1);
         final DummyListChromosome p2c = new DummyListChromosome(p2);
 
-        final CrossoverPolicy cp = new OrderedCrossover<Integer>();
+        final CrossoverPolicy cp = new OrderedCrossover<>();
 
         for (int i = 0; i < 20; i++) {
             final Set<Integer> parentSet1 = new HashSet<>(Arrays.asList(p1));
@@ -66,7 +66,7 @@ public class OrderedCrossoverTest {
         final BinaryChromosome p1c = new DummyBinaryChromosome(p1);
         final BinaryChromosome p2c = new DummyBinaryChromosome(p2);
 
-        final CrossoverPolicy cp = new OrderedCrossover<Integer>();
+        final CrossoverPolicy cp = new OrderedCrossover<>();
         cp.crossover(p1c, p2c);
     }
 
@@ -82,7 +82,7 @@ public class OrderedCrossoverTest {
             }
         };
 
-        final CrossoverPolicy cp = new OrderedCrossover<Integer>();
+        final CrossoverPolicy cp = new OrderedCrossover<>();
         cp.crossover(p1c, p2c);
     }
 
@@ -98,7 +98,7 @@ public class OrderedCrossoverTest {
             }
         };
 
-        final CrossoverPolicy cp = new OrderedCrossover<Integer>();
+        final CrossoverPolicy cp = new OrderedCrossover<>();
         cp.crossover(p1c, p2c);
     }
 }
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/UniformCrossoverTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/UniformCrossoverTest.java
index 0a9331925..493c9340f 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/UniformCrossoverTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/UniformCrossoverTest.java
@@ -42,12 +42,12 @@ public class UniformCrossoverTest {
 
     @Test(expected = OutOfRangeException.class)
     public void testRatioTooLow() {
-        new UniformCrossover<Integer>(-0.5d);
+        new UniformCrossover<>(-0.5d);
     }
 
     @Test(expected = OutOfRangeException.class)
     public void testRatioTooHigh() {
-        new UniformCrossover<Integer>(1.5d);
+        new UniformCrossover<>(1.5d);
     }
 
     @Test
@@ -62,7 +62,7 @@ public class UniformCrossoverTest {
         final DummyBinaryChromosome p1c = new DummyBinaryChromosome(p1);
         final DummyBinaryChromosome p2c = new DummyBinaryChromosome(p2);
 
-        final CrossoverPolicy cp = new UniformCrossover<Integer>(ratio);
+        final CrossoverPolicy cp = new UniformCrossover<>(ratio);
 
         // make a number of rounds
         for (int i = 0; i < 20; i++) {
@@ -113,7 +113,7 @@ public class UniformCrossoverTest {
         final BinaryChromosome p1c = new DummyBinaryChromosome(p1);
         final BinaryChromosome p2c = new DummyBinaryChromosome(p2);
 
-        final CrossoverPolicy cp = new UniformCrossover<Integer>(0.5d);
+        final CrossoverPolicy cp = new UniformCrossover<>(0.5d);
         cp.crossover(p1c, p2c);
     }
 
@@ -130,7 +130,7 @@ public class UniformCrossoverTest {
             }
         };
 
-        final CrossoverPolicy cp = new UniformCrossover<Integer>(0.5d);
+        final CrossoverPolicy cp = new UniformCrossover<>(0.5d);
         cp.crossover(p1c, p2c);
     }
 
@@ -147,7 +147,7 @@ public class UniformCrossoverTest {
             }
         };
 
-        final CrossoverPolicy cp = new UniformCrossover<Integer>(0.5d);
+        final CrossoverPolicy cp = new UniformCrossover<>(0.5d);
         cp.crossover(p1c, p2c);
     }
 }
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToDoubleHashMapTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToDoubleHashMapTest.java
index 26a7203bc..e5d90ee7a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToDoubleHashMapTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToDoubleHashMapTest.java
@@ -93,7 +93,7 @@ public class OpenIntToDoubleHashMapTest {
     }
 
     private void assertPutAndGet(OpenIntToDoubleHashMap map) {
-        assertPutAndGet(map, 0, new HashSet<Integer>());
+        assertPutAndGet(map, 0, new HashSet<>());
     }
 
     private void assertPutAndGet(OpenIntToDoubleHashMap map, int mapSize,
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToFieldTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToFieldTest.java
index 8083ee671..9c4b8a2a8 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToFieldTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToFieldTest.java
@@ -96,7 +96,7 @@ public class OpenIntToFieldTest {
     }
 
     private void assertPutAndGet(OpenIntToFieldHashMap<Dfp> map) {
-        assertPutAndGet(map, 0, new HashSet<Integer>());
+        assertPutAndGet(map, 0, new HashSet<>());
     }
 
     private void assertPutAndGet(OpenIntToFieldHashMap<Dfp> map, int mapSize,
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/clustering/DBSCANClustererTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/clustering/DBSCANClustererTest.java
index aed92b496..af33b9abf 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/clustering/DBSCANClustererTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/clustering/DBSCANClustererTest.java
@@ -172,12 +172,12 @@ public class DBSCANClustererTest {
 
     @Test(expected = MathIllegalArgumentException.class)
     public void testNegativeEps() {
-        new DBSCANClusterer<DoublePoint>(-2.0, 5);
+        new DBSCANClusterer<>(-2.0, 5);
     }
 
     @Test(expected = MathIllegalArgumentException.class)
     public void testNegativeMinPts() {
-        new DBSCANClusterer<DoublePoint>(2.0, -5);
+        new DBSCANClusterer<>(2.0, -5);
     }
 
     @Test(expected = NullArgumentException.class)
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/clustering/FuzzyKMeansClustererTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/clustering/FuzzyKMeansClustererTest.java
index 1abd4b1dd..63e73d616 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/clustering/FuzzyKMeansClustererTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/clustering/FuzzyKMeansClustererTest.java
@@ -80,7 +80,7 @@ public class FuzzyKMeansClustererTest {
 
     @Test(expected = MathIllegalArgumentException.class)
     public void testTooSmallFuzzynessFactor() {
-        new FuzzyKMeansClusterer<DoublePoint>(3, 1.0);
+        new FuzzyKMeansClusterer<>(3, 1.0);
     }
 
     @Test(expected = NullArgumentException.class)
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/clustering/MultiKMeansPlusPlusClustererTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/clustering/MultiKMeansPlusPlusClustererTest.java
index 93884cc99..7ae8dd589 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/clustering/MultiKMeansPlusPlusClustererTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/clustering/MultiKMeansPlusPlusClustererTest.java
@@ -30,7 +30,7 @@ public class MultiKMeansPlusPlusClustererTest {
     public void dimension2() {
         MultiKMeansPlusPlusClusterer<DoublePoint> transformer =
             new MultiKMeansPlusPlusClusterer<>(
-                    new KMeansPlusPlusClusterer<DoublePoint>(3, 10), 5);
+                    new KMeansPlusPlusClusterer<>(3, 10), 5);
 
         DoublePoint[] points = new DoublePoint[] {
 
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/ContinuousOutputFieldModelTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/ContinuousOutputFieldModelTest.java
index e3e6e4236..7dfabba76 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/ContinuousOutputFieldModelTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/ContinuousOutputFieldModelTest.java
@@ -45,7 +45,7 @@ public class ContinuousOutputFieldModelTest {
         double minStep = 0;
         double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal();
         FirstOrderFieldIntegrator<T> integ = new DormandPrince54FieldIntegrator<>(field, minStep, maxStep, 1.0e-8, 1.0e-8);
-        integ.addStepHandler(new ContinuousOutputFieldModel<T>());
+        integ.addStepHandler(new ContinuousOutputFieldModel<>());
         integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime());
         ContinuousOutputFieldModel<T> cm = (ContinuousOutputFieldModel<T>) integ.getStepHandlers().iterator().next();
         cm.getInterpolatedState(pb.getInitialState().getTime().multiply(2).subtract(pb.getFinalTime()));
@@ -145,7 +145,7 @@ public class ContinuousOutputFieldModelTest {
         // merge the two half circles
         ContinuousOutputFieldModel<T> cm = new ContinuousOutputFieldModel<>();
         cm.append(cm2);
-        cm.append(new ContinuousOutputFieldModel<T>());
+        cm.append(new ContinuousOutputFieldModel<>());
         cm.append(cm1);
 
         // check circle
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/MultivariateFunctionPenaltyAdapterTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/MultivariateFunctionPenaltyAdapterTest.java
index af3da6828..889aba907 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/MultivariateFunctionPenaltyAdapterTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/MultivariateFunctionPenaltyAdapterTest.java
@@ -133,7 +133,7 @@ public class MultivariateFunctionPenaltyAdapterTest {
                                                        biQuadratic.getUpper(),
                                                        1000.0, new double[] { 100.0, 100.0 });
 
-        SimplexOptimizer optimizer = new SimplexOptimizer(new SimplePointChecker<PointValuePair>(1.0e-10, 1.0e-20));
+        SimplexOptimizer optimizer = new SimplexOptimizer(new SimplePointChecker<>(1.0e-10, 1.0e-20));
 
         final PointValuePair optimum
             = optimizer.optimize(new MaxEval(400),
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/FrequencyTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/FrequencyTest.java
index b89b8066e..6b957db7e 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/FrequencyTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/FrequencyTest.java
@@ -260,10 +260,10 @@ public final class FrequencyTest {
         Assert.assertEquals(1, f.getCount(ONE_LONG));
         Assert.assertEquals(0, f.getCount(TWO_LONG));
 
-        Frequency<Long> g = new Frequency<Long>();
+        Frequency<Long> g = new Frequency<>();
         g.addValue(TWO_LONG);
 
-        Frequency<Long> h = new Frequency<Long>();
+        Frequency<Long> h = new Frequency<>();
         h.addValue(THREE_LONG);
 
         List<Frequency<Long>> coll = new ArrayList<>();
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java b/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
index 1cfc832f1..19232994b 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
@@ -182,7 +182,7 @@ public class ClusterAlgorithmComparison {
                                               double maxY) {
         double rangeX = maxX - minX;
         double rangeY = maxY - minY;
-        List<DoublePoint> points = new ArrayList<DoublePoint>();
+        List<DoublePoint> points = new ArrayList<>();
         for (Vector2D p : input) {
             double[] arr = p.toArray();
             arr[0] = (arr[0] - minX) / rangeX * 2 - 1;
@@ -212,18 +212,18 @@ public class ClusterAlgorithmComparison {
             datasets.add(normalize(makeBlobs(nSamples, 3, 1.0, -10, 10, true, rng), -12, 12, -12, 12));
             datasets.add(normalize(makeRandom(nSamples), -1, 1, -1, 1));
 
-            List<Pair<String, Clusterer<DoublePoint>>> algorithms = new ArrayList<Pair<String, Clusterer<DoublePoint>>>();
+            List<Pair<String, Clusterer<DoublePoint>>> algorithms = new ArrayList<>();
             
             algorithms.add(new Pair<String, Clusterer<DoublePoint>>("KMeans\n(k=2)",
-                                                                    new KMeansPlusPlusClusterer<DoublePoint>(2)));
+                                                                    new KMeansPlusPlusClusterer<>(2)));
             algorithms.add(new Pair<String, Clusterer<DoublePoint>>("KMeans\n(k=3)",
-                                                                    new KMeansPlusPlusClusterer<DoublePoint>(3)));
+                                                                    new KMeansPlusPlusClusterer<>(3)));
             algorithms.add(new Pair<String, Clusterer<DoublePoint>>("FuzzyKMeans\n(k=3, fuzzy=2)",
-                                                                    new FuzzyKMeansClusterer<DoublePoint>(3, 2)));
+                                                                    new FuzzyKMeansClusterer<>(3, 2)));
             algorithms.add(new Pair<String, Clusterer<DoublePoint>>("FuzzyKMeans\n(k=3, fuzzy=10)",
-                                                                    new FuzzyKMeansClusterer<DoublePoint>(3, 10)));
+                                                                    new FuzzyKMeansClusterer<>(3, 10)));
             algorithms.add(new Pair<String, Clusterer<DoublePoint>>("DBSCAN\n(eps=.1, min=3)",
-                                                                    new DBSCANClusterer<DoublePoint>(0.1, 3)));
+                                                                    new DBSCANClusterer<>(0.1, 3)));
             
             GridBagConstraints c = new GridBagConstraints();
             c.fill = GridBagConstraints.VERTICAL;
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/LowDiscrepancyGeneratorComparison.java b/src/userguide/java/org/apache/commons/math4/userguide/LowDiscrepancyGeneratorComparison.java
index 9404d5bf6..b94a8e922 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/LowDiscrepancyGeneratorComparison.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/LowDiscrepancyGeneratorComparison.java
@@ -129,9 +129,9 @@ public class LowDiscrepancyGeneratorComparison {
             int[] datasets = new int[] { 256, 1000, 2500, 1000 };
             List<Pair<String, RandomVectorGenerator>> generators = new ArrayList<Pair<String, RandomVectorGenerator>>();
 
-            generators.add(new Pair<String, RandomVectorGenerator>("Uncorrelated\nUniform(JDK)",
-                                                                   new UncorrelatedRandomVectorGenerator(2, new UniformRandomGenerator(RandomSource.create(RandomSource.JDK)))));
-            generators.add(new Pair<String, RandomVectorGenerator>("Independent\nRandom(MT)", new RandomVectorGenerator() {
+            generators.add(new Pair<>("Uncorrelated\nUniform(JDK)",
+                                      new UncorrelatedRandomVectorGenerator(2, new UniformRandomGenerator(RandomSource.create(RandomSource.JDK)))));
+            generators.add(new Pair<>("Independent\nRandom(MT)", new RandomVectorGenerator() {
 
                 final UniformRandomProvider[] rngs = new UniformRandomProvider[] {
                     RandomSource.create(RandomSource.MT, 123456789),
@@ -146,8 +146,8 @@ public class LowDiscrepancyGeneratorComparison {
                 }
                 
             }));            
-            generators.add(new Pair<String, RandomVectorGenerator>("HaltonSequence", new HaltonSequenceGenerator(2)));            
-            generators.add(new Pair<String, RandomVectorGenerator>("SobolSequence", new SobolSequenceGenerator(2)));            
+            generators.add(new Pair<>("HaltonSequence", new HaltonSequenceGenerator(2)));            
+            generators.add(new Pair<>("SobolSequence", new SobolSequenceGenerator(2)));            
             
             GridBagConstraints c = new GridBagConstraints();
             c.fill = GridBagConstraints.VERTICAL;
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/filter/CannonballExample.java b/src/userguide/java/org/apache/commons/math4/userguide/filter/CannonballExample.java
index 61cea880b..66e40603f 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/filter/CannonballExample.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/filter/CannonballExample.java
@@ -214,12 +214,12 @@ public class CannonballExample {
         final MeasurementModel mm = new DefaultMeasurementModel(H, R);
         final KalmanFilter filter = new KalmanFilter(pm, mm);
 
-        final List<Number> realX = new ArrayList<Number>();
-        final List<Number> realY = new ArrayList<Number>();
-        final List<Number> measuredX = new ArrayList<Number>();
-        final List<Number> measuredY = new ArrayList<Number>();
-        final List<Number> kalmanX = new ArrayList<Number>();
-        final List<Number> kalmanY = new ArrayList<Number>();
+        final List<Number> realX = new ArrayList<>();
+        final List<Number> realY = new ArrayList<>();
+        final List<Number> measuredX = new ArrayList<>();
+        final List<Number> measuredY = new ArrayList<>();
+        final List<Number> kalmanX = new ArrayList<>();
+        final List<Number> kalmanY = new ArrayList<>();
         
         for (int i = 0; i < iterations; i++) {
 
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/filter/ConstantVoltageExample.java b/src/userguide/java/org/apache/commons/math4/userguide/filter/ConstantVoltageExample.java
index b290bcbb8..cce49b8d5 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/filter/ConstantVoltageExample.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/filter/ConstantVoltageExample.java
@@ -122,12 +122,12 @@ public class ConstantVoltageExample {
         final MeasurementModel mm = new DefaultMeasurementModel(H, R);
         final KalmanFilter filter = new KalmanFilter(pm, mm);
 
-        final List<Number> xAxis = new ArrayList<Number>();
-        final List<Number> realVoltageSeries = new ArrayList<Number>();
-        final List<Number> measuredVoltageSeries = new ArrayList<Number>();
-        final List<Number> kalmanVoltageSeries = new ArrayList<Number>();
+        final List<Number> xAxis = new ArrayList<>();
+        final List<Number> realVoltageSeries = new ArrayList<>();
+        final List<Number> measuredVoltageSeries = new ArrayList<>();
+        final List<Number> kalmanVoltageSeries = new ArrayList<>();
 
-        final List<Number> covSeries = new ArrayList<Number>();
+        final List<Number> covSeries = new ArrayList<>();
         
         for (int i = 0; i < 300; i++) {
             xAxis.add(i);
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/genetics/HelloWorldExample.java b/src/userguide/java/org/apache/commons/math4/userguide/genetics/HelloWorldExample.java
index b9f9ed919..f0cee4e52 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/genetics/HelloWorldExample.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/genetics/HelloWorldExample.java
@@ -51,7 +51,7 @@ public class HelloWorldExample {
         long startTime = System.currentTimeMillis();
 
         // initialize a new genetic algorithm
-        GeneticAlgorithm ga = new GeneticAlgorithm(new OnePointCrossover<Character>(), CROSSOVER_RATE,
+        GeneticAlgorithm ga = new GeneticAlgorithm(new OnePointCrossover<>(), CROSSOVER_RATE,
                                                    new RandomCharacterMutation(), MUTATION_RATE,
                                                    new TournamentSelection(TOURNAMENT_ARITY));
 
@@ -104,7 +104,7 @@ public class HelloWorldExample {
     }
     
     private static Population getInitialPopulation() {
-        List<Chromosome> popList = new LinkedList<Chromosome>();
+        List<Chromosome> popList = new LinkedList<>();
 
         for (int i = 0; i < POPULATION_SIZE; i++) {
             popList.add(new StringChromosome(randomRepresentation(DIMENSION)));
@@ -176,7 +176,7 @@ public class HelloWorldExample {
             
             int mutationIndex = GeneticAlgorithm.getRandomGenerator().nextInt(characters.size());
 
-            List<Character> mutatedChromosome = new ArrayList<Character>(characters);
+            List<Character> mutatedChromosome = new ArrayList<>(characters);
             char newValue = (char) (32 + GeneticAlgorithm.getRandomGenerator().nextInt(127 - 32));
             mutatedChromosome.set(mutationIndex, newValue);
 
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/genetics/ImageEvolutionExample.java b/src/userguide/java/org/apache/commons/math4/userguide/genetics/ImageEvolutionExample.java
index b56e0d731..9b2e6355f 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/genetics/ImageEvolutionExample.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/genetics/ImageEvolutionExample.java
@@ -135,7 +135,7 @@ public class ImageEvolutionExample {
             });
 
             // initialize a new genetic algorithm
-            ga = new GeneticAlgorithm(new UniformCrossover<Polygon>(0.5), 1.0,
+            ga = new GeneticAlgorithm(new UniformCrossover<>(0.5), 1.0,
                                       new RandomPolygonMutation(MUTATION_RATE, MUTATION_CHANGE), 1.0,
                                       new TournamentSelection(TOURNAMENT_ARITY));
 
@@ -218,7 +218,7 @@ public class ImageEvolutionExample {
     }
 
     private static Population getInitialPopulation() {
-        List<Chromosome> popList = new LinkedList<Chromosome>();
+        List<Chromosome> popList = new LinkedList<>();
         for (int i = 0; i < POPULATION_SIZE; i++) {
             popList.add(PolygonChromosome.randomChromosome(POLYGON_LENGTH, POLYGON_COUNT));
         }
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/genetics/PolygonChromosome.java b/src/userguide/java/org/apache/commons/math4/userguide/genetics/PolygonChromosome.java
index 6aa3c7140..8e27c3371 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/genetics/PolygonChromosome.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/genetics/PolygonChromosome.java
@@ -125,7 +125,7 @@ public class PolygonChromosome extends AbstractListChromosome<Polygon> {
     }
     
     public static Chromosome randomChromosome(int polygonLength, int polygonCount) {
-        List<Polygon> list = new ArrayList<Polygon>(polygonCount);
+        List<Polygon> list = new ArrayList<>(polygonCount);
         for (int j = 0; j < polygonCount; j++) {
             list.add(Polygon.randomPolygon(polygonLength));
         }
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/genetics/RandomPolygonMutation.java b/src/userguide/java/org/apache/commons/math4/userguide/genetics/RandomPolygonMutation.java
index 9b6835a32..cd4983f0c 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/genetics/RandomPolygonMutation.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/genetics/RandomPolygonMutation.java
@@ -40,7 +40,7 @@ public class RandomPolygonMutation implements MutationPolicy {
         PolygonChromosome polygons = (PolygonChromosome) chromosome;
         List<Polygon> repr = polygons.getPolygonRepresentation();
 
-        List<Polygon> newRepr = new ArrayList<Polygon>(repr.size());
+        List<Polygon> newRepr = new ArrayList<>(repr.size());
         for (Polygon p : repr) {
             newRepr.add(p.mutate(mutationRate, mutationAmount));
         }