From 91b2f42940e733beb1579e8d3cc1f16321f96989 Mon Sep 17 00:00:00 2001 From: Gilles Date: Tue, 19 Apr 2016 12:48:47 +0200 Subject: [PATCH 1/9] Revert "Standard Maven directory layout" This reverts commit 5bbd826e2f4332b0de439d2b4693347f4f2f8f9c. The corresponding changes have been ported into branch "develop". --- pom.xml | 4 ++-- src/{ => main}/assembly/bin.xml | 0 src/{ => main}/assembly/src.xml | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/{ => main}/assembly/bin.xml (100%) rename src/{ => main}/assembly/src.xml (100%) diff --git a/pom.xml b/pom.xml index 8f633af34a..145c0d6dd2 100644 --- a/pom.xml +++ b/pom.xml @@ -439,8 +439,8 @@ maven-assembly-plugin - src/assembly/src.xml - src/assembly/bin.xml + src/main/assembly/src.xml + src/main/assembly/bin.xml gnu diff --git a/src/assembly/bin.xml b/src/main/assembly/bin.xml similarity index 100% rename from src/assembly/bin.xml rename to src/main/assembly/bin.xml diff --git a/src/assembly/src.xml b/src/main/assembly/src.xml similarity index 100% rename from src/assembly/src.xml rename to src/main/assembly/src.xml From 02dd98a04570a1beba88566281efcabc8ff6f73d Mon Sep 17 00:00:00 2001 From: Dave Brosius Date: Sun, 29 May 2016 17:27:37 -0400 Subject: [PATCH 2/9] avoid allocating distribution bounds if there are no successes --- .../stat/interval/ClopperPearsonInterval.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/commons/math4/stat/interval/ClopperPearsonInterval.java b/src/main/java/org/apache/commons/math4/stat/interval/ClopperPearsonInterval.java index bf5d6ad6a4..ed0904c337 100644 --- a/src/main/java/org/apache/commons/math4/stat/interval/ClopperPearsonInterval.java +++ b/src/main/java/org/apache/commons/math4/stat/interval/ClopperPearsonInterval.java @@ -35,19 +35,19 @@ public ConfidenceInterval createInterval(int numberOfTrials, int numberOfSuccess IntervalUtils.checkParameters(numberOfTrials, numberOfSuccesses, confidenceLevel); double lowerBound = 0; double upperBound = 0; - final double alpha = (1.0 - confidenceLevel) / 2.0; - - final FDistribution distributionLowerBound = new FDistribution(2 * (numberOfTrials - numberOfSuccesses + 1), - 2 * numberOfSuccesses); + if (numberOfSuccesses > 0) { + final double alpha = (1.0 - confidenceLevel) / 2.0; + + final FDistribution distributionLowerBound = new FDistribution(2 * (numberOfTrials - numberOfSuccesses + 1), + 2 * numberOfSuccesses); final double fValueLowerBound = distributionLowerBound.inverseCumulativeProbability(1 - alpha); lowerBound = numberOfSuccesses / (numberOfSuccesses + (numberOfTrials - numberOfSuccesses + 1) * fValueLowerBound); - } - final FDistribution distributionUpperBound = new FDistribution(2 * (numberOfSuccesses + 1), - 2 * (numberOfTrials - numberOfSuccesses)); - if (numberOfSuccesses > 0) { + + final FDistribution distributionUpperBound = new FDistribution(2 * (numberOfSuccesses + 1), + 2 * (numberOfTrials - numberOfSuccesses)); final double fValueUpperBound = distributionUpperBound.inverseCumulativeProbability(1 - alpha); upperBound = (numberOfSuccesses + 1) * fValueUpperBound / (numberOfTrials - numberOfSuccesses + (numberOfSuccesses + 1) * fValueUpperBound); From 7c12a85bf8f8566d692557d526556fa3ef81824a Mon Sep 17 00:00:00 2001 From: Dave Brosius Date: Sun, 29 May 2016 17:32:40 -0400 Subject: [PATCH 3/9] remove useless local initialization before assignment --- .../math4/distribution/AbstractIntegerDistribution.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java b/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java index 95d6f074ce..4c42c01430 100644 --- a/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java @@ -209,8 +209,7 @@ public int[] sample(int sampleSize) { */ private double checkedCumulativeProbability(int argument) throws MathInternalError { - double result = Double.NaN; - result = cumulativeProbability(argument); + double result = cumulativeProbability(argument); if (Double.isNaN(result)) { throw new MathInternalError(LocalizedFormats .DISCRETE_CUMULATIVE_PROBABILITY_RETURNED_NAN, argument); From 292b6ab0811f5b21db8cc15929e41a2175d142c4 Mon Sep 17 00:00:00 2001 From: Dave Brosius Date: Sun, 29 May 2016 17:36:04 -0400 Subject: [PATCH 4/9] use StringBuilder correctly --- .../stat/descriptive/MultivariateSummaryStatistics.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatistics.java b/src/main/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatistics.java index eb1642c4cc..39083d0d1c 100644 --- a/src/main/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatistics.java +++ b/src/main/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatistics.java @@ -319,8 +319,8 @@ public String toString() { final String separator = ", "; final String suffix = System.getProperty("line.separator"); StringBuilder outBuffer = new StringBuilder(); - outBuffer.append("MultivariateSummaryStatistics:" + suffix); - outBuffer.append("n: " + getN() + suffix); + outBuffer.append("MultivariateSummaryStatistics:").append(suffix); + outBuffer.append("n: ").append(getN()).append(suffix); append(outBuffer, getMin(), "min: ", separator, suffix); append(outBuffer, getMax(), "max: ", separator, suffix); append(outBuffer, getMean(), "mean: ", separator, suffix); @@ -328,7 +328,7 @@ public String toString() { append(outBuffer, getSumSq(), "sum of squares: ", separator, suffix); append(outBuffer, getSumLog(), "sum of logarithms: ", separator, suffix); append(outBuffer, getStandardDeviation(), "standard deviation: ", separator, suffix); - outBuffer.append("covariance: " + getCovariance().toString() + suffix); + outBuffer.append("covariance: ").append(getCovariance()).append(suffix); return outBuffer.toString(); } From 803e1a6f4bfcc0ce77cd9b63cf70d264aa8a90ad Mon Sep 17 00:00:00 2001 From: Dave Brosius Date: Sun, 29 May 2016 17:45:02 -0400 Subject: [PATCH 5/9] no need for Double allocation just to get hashCode --- src/main/java/org/apache/commons/math4/util/MathUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/math4/util/MathUtils.java b/src/main/java/org/apache/commons/math4/util/MathUtils.java index 7f10455200..fc3e3fe477 100644 --- a/src/main/java/org/apache/commons/math4/util/MathUtils.java +++ b/src/main/java/org/apache/commons/math4/util/MathUtils.java @@ -61,7 +61,7 @@ private MathUtils() {} * @return the hash code */ public static int hash(double value) { - return new Double(value).hashCode(); + return Double.hashCode(value); } /** From ffc1caada54272e273ca26c17e54f2f91245884f Mon Sep 17 00:00:00 2001 From: Dave Brosius Date: Mon, 30 May 2016 13:25:18 -0400 Subject: [PATCH 6/9] Revert "no need for Double allocation just to get hashCode" a java 8 method This reverts commit 803e1a6f4bfcc0ce77cd9b63cf70d264aa8a90ad. --- src/main/java/org/apache/commons/math4/util/MathUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/math4/util/MathUtils.java b/src/main/java/org/apache/commons/math4/util/MathUtils.java index fc3e3fe477..7f10455200 100644 --- a/src/main/java/org/apache/commons/math4/util/MathUtils.java +++ b/src/main/java/org/apache/commons/math4/util/MathUtils.java @@ -61,7 +61,7 @@ private MathUtils() {} * @return the hash code */ public static int hash(double value) { - return Double.hashCode(value); + return new Double(value).hashCode(); } /** From 598edc12736945d27fb7dbd77cb81ac8e51f491a Mon Sep 17 00:00:00 2001 From: Gilles Date: Tue, 31 May 2016 03:20:13 +0200 Subject: [PATCH 7/9] Reverting changes on "master" as per Commons Math policy. The corresponding changes have been ported into branch "develop". --- .../AbstractIntegerDistribution.java | 3 ++- .../MultivariateSummaryStatistics.java | 6 +++--- .../stat/interval/ClopperPearsonInterval.java | 16 ++++++++-------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java b/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java index 4c42c01430..95d6f074ce 100644 --- a/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java @@ -209,7 +209,8 @@ public int[] sample(int sampleSize) { */ private double checkedCumulativeProbability(int argument) throws MathInternalError { - double result = cumulativeProbability(argument); + double result = Double.NaN; + result = cumulativeProbability(argument); if (Double.isNaN(result)) { throw new MathInternalError(LocalizedFormats .DISCRETE_CUMULATIVE_PROBABILITY_RETURNED_NAN, argument); diff --git a/src/main/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatistics.java b/src/main/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatistics.java index 39083d0d1c..eb1642c4cc 100644 --- a/src/main/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatistics.java +++ b/src/main/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatistics.java @@ -319,8 +319,8 @@ public String toString() { final String separator = ", "; final String suffix = System.getProperty("line.separator"); StringBuilder outBuffer = new StringBuilder(); - outBuffer.append("MultivariateSummaryStatistics:").append(suffix); - outBuffer.append("n: ").append(getN()).append(suffix); + outBuffer.append("MultivariateSummaryStatistics:" + suffix); + outBuffer.append("n: " + getN() + suffix); append(outBuffer, getMin(), "min: ", separator, suffix); append(outBuffer, getMax(), "max: ", separator, suffix); append(outBuffer, getMean(), "mean: ", separator, suffix); @@ -328,7 +328,7 @@ public String toString() { append(outBuffer, getSumSq(), "sum of squares: ", separator, suffix); append(outBuffer, getSumLog(), "sum of logarithms: ", separator, suffix); append(outBuffer, getStandardDeviation(), "standard deviation: ", separator, suffix); - outBuffer.append("covariance: ").append(getCovariance()).append(suffix); + outBuffer.append("covariance: " + getCovariance().toString() + suffix); return outBuffer.toString(); } diff --git a/src/main/java/org/apache/commons/math4/stat/interval/ClopperPearsonInterval.java b/src/main/java/org/apache/commons/math4/stat/interval/ClopperPearsonInterval.java index ed0904c337..bf5d6ad6a4 100644 --- a/src/main/java/org/apache/commons/math4/stat/interval/ClopperPearsonInterval.java +++ b/src/main/java/org/apache/commons/math4/stat/interval/ClopperPearsonInterval.java @@ -35,19 +35,19 @@ public ConfidenceInterval createInterval(int numberOfTrials, int numberOfSuccess IntervalUtils.checkParameters(numberOfTrials, numberOfSuccesses, confidenceLevel); double lowerBound = 0; double upperBound = 0; - - if (numberOfSuccesses > 0) { - final double alpha = (1.0 - confidenceLevel) / 2.0; + final double alpha = (1.0 - confidenceLevel) / 2.0; - final FDistribution distributionLowerBound = new FDistribution(2 * (numberOfTrials - numberOfSuccesses + 1), - 2 * numberOfSuccesses); + final FDistribution distributionLowerBound = new FDistribution(2 * (numberOfTrials - numberOfSuccesses + 1), + 2 * numberOfSuccesses); + if (numberOfSuccesses > 0) { final double fValueLowerBound = distributionLowerBound.inverseCumulativeProbability(1 - alpha); lowerBound = numberOfSuccesses / (numberOfSuccesses + (numberOfTrials - numberOfSuccesses + 1) * fValueLowerBound); + } - - final FDistribution distributionUpperBound = new FDistribution(2 * (numberOfSuccesses + 1), - 2 * (numberOfTrials - numberOfSuccesses)); + final FDistribution distributionUpperBound = new FDistribution(2 * (numberOfSuccesses + 1), + 2 * (numberOfTrials - numberOfSuccesses)); + if (numberOfSuccesses > 0) { final double fValueUpperBound = distributionUpperBound.inverseCumulativeProbability(1 - alpha); upperBound = (numberOfSuccesses + 1) * fValueUpperBound / (numberOfTrials - numberOfSuccesses + (numberOfSuccesses + 1) * fValueUpperBound); From 8b5f4535ec5a3983e655e5fc66a90fce657d4344 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 19 Sep 2016 23:40:15 -0700 Subject: [PATCH 8/9] Remove redundant type arguments. --- .../analysis/differentiation/DSCompiler.java | 10 +- .../differentiation/SparseGradient.java | 4 +- .../integration/gauss/BaseRuleFactory.java | 8 +- .../gauss/GaussIntegratorFactory.java | 2 +- .../integration/gauss/HermiteRuleFactory.java | 4 +- .../LegendreHighPrecisionRuleFactory.java | 4 +- .../gauss/LegendreRuleFactory.java | 4 +- .../FieldHermiteInterpolator.java | 6 +- .../interpolation/HermiteInterpolator.java | 6 +- .../InterpolatingMicrosphere.java | 6 +- .../polynomials/PolynomialsUtils.java | 12 +- .../apache/commons/math4/complex/Complex.java | 2 +- .../distribution/EnumeratedDistribution.java | 6 +- .../EnumeratedIntegerDistribution.java | 10 +- .../EnumeratedRealDistribution.java | 10 +- ...MixtureMultivariateNormalDistribution.java | 4 +- .../MixtureMultivariateRealDistribution.java | 6 +- ...eNormalMixtureExpectationMaximization.java | 4 +- .../math4/exception/util/ArgUtils.java | 2 +- .../exception/util/ExceptionContext.java | 12 +- .../math4/fitting/GaussianCurveFitter.java | 2 +- .../math4/fitting/HarmonicCurveFitter.java | 2 +- .../math4/fitting/WeightedObservedPoints.java | 4 +- .../leastsquares/GaussNewtonOptimizer.java | 2 +- .../leastsquares/LeastSquaresFactory.java | 2 +- .../genetics/AbstractListChromosome.java | 2 +- .../math4/genetics/BinaryChromosome.java | 2 +- .../math4/genetics/BinaryMutation.java | 2 +- .../math4/genetics/CycleCrossover.java | 8 +- .../math4/genetics/ListPopulation.java | 2 +- .../math4/genetics/NPointCrossover.java | 4 +- .../math4/genetics/OnePointCrossover.java | 4 +- .../math4/genetics/OrderedCrossover.java | 8 +- .../commons/math4/genetics/RandomKey.java | 16 +- .../math4/genetics/RandomKeyMutation.java | 2 +- .../math4/genetics/TournamentSelection.java | 2 +- .../math4/genetics/UniformCrossover.java | 4 +- .../geometry/enclosing/WelzlEncloser.java | 4 +- .../geometry/euclidean/oned/IntervalsSet.java | 22 +- .../euclidean/oned/SubOrientedPoint.java | 6 +- .../euclidean/threed/FieldRotation.java | 40 ++-- .../euclidean/threed/FieldVector3D.java | 42 ++-- .../euclidean/threed/OutlineExtractor.java | 2 +- .../euclidean/threed/PolyhedronsSet.java | 4 +- .../euclidean/threed/SphereGenerator.java | 10 +- .../geometry/euclidean/threed/SubLine.java | 2 +- .../geometry/euclidean/threed/SubPlane.java | 12 +- .../euclidean/twod/DiskGenerator.java | 8 +- .../geometry/euclidean/twod/NestedLoops.java | 8 +- .../geometry/euclidean/twod/PolygonsSet.java | 18 +- .../geometry/euclidean/twod/SubLine.java | 14 +- .../twod/hull/AklToussaintHeuristic.java | 4 +- .../euclidean/twod/hull/ConvexHull2D.java | 2 +- .../euclidean/twod/hull/MonotoneChain.java | 8 +- .../geometry/partitioning/AbstractRegion.java | 26 +- .../partitioning/AbstractSubHyperplane.java | 8 +- .../math4/geometry/partitioning/BSPTree.java | 34 +-- .../partitioning/BoundaryBuilder.java | 12 +- .../partitioning/BoundaryProjector.java | 4 +- .../partitioning/Characterization.java | 4 +- .../math4/geometry/partitioning/NodesSet.java | 2 +- .../geometry/partitioning/RegionFactory.java | 14 +- .../geometry/spherical/oned/ArcsSet.java | 36 +-- .../spherical/oned/SubLimitAngle.java | 4 +- .../geometry/spherical/twod/EdgesBuilder.java | 6 +- .../spherical/twod/PropertiesComputer.java | 2 +- .../spherical/twod/SphericalPolygonsSet.java | 30 +-- .../geometry/spherical/twod/SubCircle.java | 4 +- .../math4/geometry/spherical/twod/Vertex.java | 2 +- .../math4/linear/AbstractFieldMatrix.java | 16 +- .../math4/linear/AbstractRealMatrix.java | 2 +- .../math4/linear/Array2DRowFieldMatrix.java | 10 +- .../math4/linear/ArrayFieldVector.java | 40 ++-- .../math4/linear/BlockFieldMatrix.java | 32 +-- .../math4/linear/FieldLUDecomposition.java | 16 +- .../commons/math4/linear/MatrixUtils.java | 8 +- .../math4/linear/RealMatrixFormat.java | 6 +- .../math4/linear/RealVectorFormat.java | 2 +- .../math4/linear/SparseFieldMatrix.java | 12 +- .../math4/linear/SparseFieldVector.java | 32 +-- .../commons/math4/ml/clustering/Cluster.java | 2 +- .../math4/ml/clustering/DBSCANClusterer.java | 12 +- .../ml/clustering/FuzzyKMeansClusterer.java | 6 +- .../clustering/KMeansPlusPlusClusterer.java | 6 +- .../commons/math4/ml/neuralnet/MapUtils.java | 6 +- .../commons/math4/ml/neuralnet/Network.java | 14 +- .../commons/math4/ml/neuralnet/Neuron.java | 2 +- .../neuralnet/sofm/KohonenUpdateAction.java | 4 +- .../ml/neuralnet/twod/NeuronSquareMesh2D.java | 2 +- .../neuralnet/twod/util/LocationFinder.java | 2 +- .../math4/ode/AbstractFieldIntegrator.java | 14 +- .../commons/math4/ode/AbstractIntegrator.java | 8 +- .../math4/ode/AbstractParameterizable.java | 4 +- .../math4/ode/ContinuousOutputFieldModel.java | 2 +- .../math4/ode/ContinuousOutputModel.java | 2 +- .../math4/ode/ExpandableStatefulODE.java | 4 +- .../math4/ode/FieldEquationsMapper.java | 4 +- .../commons/math4/ode/FieldExpandableODE.java | 6 +- .../commons/math4/ode/JacobianMatrices.java | 2 +- .../math4/ode/MultistepFieldIntegrator.java | 4 +- .../math4/ode/ParameterJacobianWrapper.java | 2 +- .../math4/ode/ParameterizedWrapper.java | 2 +- .../AdamsBashforthFieldIntegrator.java | 2 +- .../nonstiff/AdamsFieldStepInterpolator.java | 6 +- .../nonstiff/AdamsMoultonFieldIntegrator.java | 4 +- .../AdamsNordsieckFieldTransformer.java | 22 +- .../nonstiff/AdamsNordsieckTransformer.java | 10 +- .../ClassicalRungeKuttaFieldIntegrator.java | 2 +- ...ssicalRungeKuttaFieldStepInterpolator.java | 4 +- .../DormandPrince54FieldIntegrator.java | 2 +- .../DormandPrince54FieldStepInterpolator.java | 4 +- .../DormandPrince853FieldIntegrator.java | 2 +- ...DormandPrince853FieldStepInterpolator.java | 4 +- .../EmbeddedRungeKuttaFieldIntegrator.java | 2 +- .../ode/nonstiff/EulerFieldIntegrator.java | 2 +- .../nonstiff/EulerFieldStepInterpolator.java | 4 +- .../ode/nonstiff/GillFieldIntegrator.java | 2 +- .../nonstiff/GillFieldStepInterpolator.java | 4 +- .../nonstiff/HighamHall54FieldIntegrator.java | 2 +- .../HighamHall54FieldStepInterpolator.java | 4 +- .../ode/nonstiff/LutherFieldIntegrator.java | 2 +- .../nonstiff/LutherFieldStepInterpolator.java | 4 +- .../ode/nonstiff/MidpointFieldIntegrator.java | 2 +- .../MidpointFieldStepInterpolator.java | 4 +- .../nonstiff/RungeKuttaFieldIntegrator.java | 2 +- .../ThreeEighthesFieldIntegrator.java | 2 +- .../ThreeEighthesFieldStepInterpolator.java | 4 +- .../optim/linear/LinearConstraintSet.java | 2 +- .../math4/optim/linear/SimplexSolver.java | 2 +- .../math4/optim/linear/SimplexTableau.java | 8 +- .../MultiStartMultivariateOptimizer.java | 2 +- .../scalar/noderiv/CMAESOptimizer.java | 8 +- .../commons/math4/primes/SmallPrimes.java | 2 +- .../math4/random/EmpiricalDistribution.java | 2 +- .../apache/commons/math4/stat/Frequency.java | 6 +- .../stat/correlation/KendallsCorrelation.java | 2 +- .../descriptive/rank/PSquarePercentile.java | 2 +- .../stat/inference/KolmogorovSmirnovTest.java | 4 +- .../math4/stat/inference/OneWayAnova.java | 2 +- .../math4/stat/ranking/NaturalRanking.java | 6 +- .../math4/util/CombinatoricsUtils.java | 2 +- .../commons/math4/util/IterationManager.java | 4 +- .../apache/commons/math4/util/MathArrays.java | 4 +- .../org/apache/commons/math4/util/Pair.java | 2 +- .../commons/math4/util/TransformerMap.java | 2 +- .../differentiation/DSCompilerTest.java | 4 +- .../gauss/BaseRuleFactoryTest.java | 4 +- .../gauss/GaussIntegratorTest.java | 6 +- .../gauss/HermiteParametricTest.java | 2 +- .../LegendreHighPrecisionParametricTest.java | 2 +- .../gauss/LegendreParametricTest.java | 2 +- .../FieldHermiteInterpolatorTest.java | 20 +- ...ieldBracketingNthOrderBrentSolverTest.java | 8 +- .../EnumeratedRealDistributionTest.java | 4 +- ...ateNormalMixtureModelDistributionTest.java | 4 +- .../RealDistributionAbstractTest.java | 2 +- ...malMixtureExpectationMaximizationTest.java | 6 +- .../math4/exception/util/ArgUtilsTest.java | 2 +- .../fitting/HarmonicCurveFitterTest.java | 2 +- .../fitting/leastsquares/CircleProblem.java | 2 +- .../fitting/leastsquares/CircleVectorial.java | 2 +- .../fitting/leastsquares/EvaluationTest.java | 4 +- .../EvaluationTestValidation.java | 2 +- .../LevenbergMarquardtOptimizerTest.java | 4 +- .../StatisticalReferenceDataset.java | 2 +- .../leastsquares/StraightLineProblem.java | 2 +- .../math4/genetics/ChromosomeTest.java | 2 +- .../math4/genetics/FitnessCachingTest.java | 2 +- .../genetics/GeneticAlgorithmTestBinary.java | 2 +- .../GeneticAlgorithmTestPermutations.java | 4 +- .../math4/genetics/ListPopulationTest.java | 14 +- .../math4/genetics/NPointCrossoverTest.java | 2 +- .../math4/genetics/OnePointCrossoverTest.java | 2 +- .../math4/genetics/OrderedCrossoverTest.java | 4 +- .../math4/genetics/UniformCrossoverTest.java | 4 +- .../enclosing/WelzlEncloser2DTest.java | 12 +- .../enclosing/WelzlEncloser3DTest.java | 14 +- .../euclidean/oned/IntervalsSetTest.java | 2 +- .../euclidean/threed/FieldRotationDSTest.java | 118 ++++----- .../threed/FieldRotationDfpTest.java | 116 ++++----- .../euclidean/threed/FieldVector3DTest.java | 48 ++-- .../geometry/euclidean/threed/PLYParser.java | 2 +- .../euclidean/threed/PolyhedronsSetTest.java | 6 +- .../euclidean/threed/SphereGeneratorTest.java | 2 +- .../euclidean/twod/DiskGeneratorTest.java | 2 +- .../euclidean/twod/PolygonsSetTest.java | 52 ++-- .../ConvexHullGenerator2DAbstractTest.java | 24 +- .../twod/hull/MonotoneChainTest.java | 2 +- .../geometry/partitioning/RegionParser.java | 2 +- .../geometry/spherical/oned/ArcsSetTest.java | 14 +- .../twod/SphericalPolygonsSetTest.java | 14 +- .../spherical/twod/SubCircleTest.java | 2 +- .../math4/linear/ArrayFieldVectorTest.java | 96 ++++---- .../math4/linear/BlockFieldMatrixTest.java | 226 +++++++++--------- .../linear/FieldLUDecompositionTest.java | 62 ++--- .../math4/linear/FieldLUSolverTest.java | 18 +- .../math4/linear/FieldMatrixImplTest.java | 212 ++++++++-------- .../commons/math4/linear/MatrixUtilsTest.java | 16 +- .../math4/linear/SparseFieldMatrixTest.java | 26 +- .../math4/linear/SparseFieldVectorTest.java | 40 ++-- .../UnmodifiableRealVectorAbstractTest.java | 2 +- .../ml/clustering/DBSCANClustererTest.java | 10 +- .../clustering/FuzzyKMeansClustererTest.java | 16 +- .../KMeansPlusPlusClustererTest.java | 10 +- .../MultiKMeansPlusPlusClustererTest.java | 2 +- .../evaluation/SumOfClusterVariancesTest.java | 8 +- .../math4/ml/neuralnet/MapUtilsTest.java | 6 +- .../ml/neuralnet/oned/NeuronStringTest.java | 2 +- .../sofm/KohonenTrainingTaskTest.java | 4 +- .../sofm/TravellingSalesmanSolver.java | 8 +- .../twod/NeuronSquareMesh2DTest.java | 8 +- .../ode/ContinuousOutputFieldModelTest.java | 44 ++-- .../math4/ode/FieldExpandableODETest.java | 46 ++-- .../commons/math4/ode/TestFieldProblem4.java | 6 +- .../math4/ode/TestFieldProblemAbstract.java | 2 +- .../ode/events/OverlappingEventsTest.java | 4 +- ...EmbeddedRungeKuttaFieldIntegratorTest.java | 64 ++--- ...AbstractRungeKuttaFieldIntegratorTest.java | 80 +++---- .../AdamsBashforthFieldIntegratorTest.java | 4 +- .../AdamsFieldIntegratorAbstractTest.java | 44 ++-- .../AdamsMoultonFieldIntegratorTest.java | 4 +- ...calRungKuttaFieldStepInterpolatorTest.java | 4 +- ...lassicalRungeKuttaFieldIntegratorTest.java | 2 +- .../DormandPrince54FieldIntegratorTest.java | 4 +- ...mandPrince54FieldStepInterpolatorTest.java | 4 +- .../DormandPrince853FieldIntegratorTest.java | 4 +- ...andPrince853FieldStepInterpolatorTest.java | 4 +- ...RungeKuttaFieldIntegratorAbstractTest.java | 64 ++--- .../nonstiff/EulerFieldIntegratorTest.java | 2 +- .../EulerFieldStepInterpolatorTest.java | 4 +- .../ode/nonstiff/GillFieldIntegratorTest.java | 2 +- .../GillFieldStepInterpolatorTest.java | 4 +- .../HighamHall54FieldIntegratorTest.java | 4 +- ...HighamHall54FieldStepInterpolatorTest.java | 4 +- .../nonstiff/LutherFieldIntegratorTest.java | 2 +- .../LutherFieldStepInterpolatorTest.java | 4 +- .../nonstiff/MidpointFieldIntegratorTest.java | 2 +- .../MidpointFieldStepInterpolatorTest.java | 4 +- ...RungeKuttaFieldIntegratorAbstractTest.java | 80 +++---- ...uttaFieldStepInterpolatorAbstractTest.java | 12 +- .../ThreeEighthesFieldIntegratorTest.java | 2 +- ...hreeEighthesFieldStepInterpolatorTest.java | 4 +- .../sampling/DummyFieldStepInterpolator.java | 2 +- .../sampling/StepInterpolatorTestUtils.java | 2 +- .../StepNormalizerOutputTestBase.java | 2 +- .../math4/optim/SimplePointCheckerTest.java | 4 +- .../math4/optim/linear/SimplexSolverTest.java | 62 ++--- .../optim/linear/SimplexTableauTest.java | 4 +- .../scalar/gradient/CircleScalar.java | 2 +- .../commons/math4/primes/PrimesTest.java | 2 +- .../random/EmpiricalDistributionTest.java | 2 +- .../math4/random/RandomDataGeneratorTest.java | 12 +- .../SynchronizedRandomGeneratorTest.java | 2 +- .../commons/math4/stat/FrequencyTest.java | 2 +- .../stat/data/CertifiedDataAbstractTest.java | 2 +- .../AggregateSummaryStatisticsTest.java | 8 +- .../stat/descriptive/ListUnivariateImpl.java | 2 +- .../descriptive/ListUnivariateImplTest.java | 6 +- .../MixedListUnivariateImplTest.java | 8 +- .../UnivariateStatisticAbstractTest.java | 2 +- .../rank/PSquarePercentileTest.java | 4 +- .../math4/stat/inference/OneWayAnovaTest.java | 20 +- .../math4/stat/inference/TestUtilsTest.java | 2 +- .../math4/util/ArithmeticUtilsTest.java | 2 +- .../math4/util/CombinatoricsUtilsTest.java | 2 +- .../util/FastMathStrictComparisonTest.java | 2 +- .../math4/util/IntegerSequenceTest.java | 16 +- .../util/OpenIntToDoubleHashMapTest.java | 8 +- .../math4/util/OpenIntToFieldTest.java | 26 +- .../apache/commons/math4/util/PairTest.java | 24 +- 270 files changed, 1552 insertions(+), 1554 deletions(-) diff --git a/src/main/java/org/apache/commons/math4/analysis/differentiation/DSCompiler.java b/src/main/java/org/apache/commons/math4/analysis/differentiation/DSCompiler.java index 7515a18983..3b1bc738d4 100644 --- a/src/main/java/org/apache/commons/math4/analysis/differentiation/DSCompiler.java +++ b/src/main/java/org/apache/commons/math4/analysis/differentiation/DSCompiler.java @@ -126,7 +126,7 @@ public class DSCompiler { /** Array of all compilers created so far. */ private static AtomicReference compilers = - new AtomicReference(null); + new AtomicReference<>(null); /** Number of free parameters. */ private final int parameters; @@ -358,14 +358,14 @@ private static int[][][] compileMultiplicationIndirection(final int parameters, for (int i = 0; i < dSize; ++i) { final int[][] dRow = derivativeCompiler.multIndirection[i]; - List row = new ArrayList(dRow.length * 2); + List row = new ArrayList<>(dRow.length * 2); for (int j = 0; j < dRow.length; ++j) { row.add(new int[] { dRow[j][0], lowerIndirection[dRow[j][1]], vSize + dRow[j][2] }); row.add(new int[] { dRow[j][0], vSize + dRow[j][1], lowerIndirection[dRow[j][2]] }); } // combine terms with similar derivation orders - final List combined = new ArrayList(row.size()); + final List combined = new ArrayList<>(row.size()); for (int j = 0; j < row.size(); ++j) { final int[] termJ = row.get(j); if (termJ[0] > 0) { @@ -428,7 +428,7 @@ private static int[][][] compileCompositionIndirection(final int parameters, fin // with respect to the parameter this compiler handles and the // underlying one did not handle for (int i = 0; i < dSize; ++i) { - List row = new ArrayList(); + List row = new ArrayList<>(); for (int[] term : derivativeCompiler.compIndirection[i]) { // handle term p * f_k(g(x)) * g_l1(x) * g_l2(x) * ... * g_lp(x) @@ -475,7 +475,7 @@ private static int[][][] compileCompositionIndirection(final int parameters, fin } // combine terms with similar derivation orders - final List combined = new ArrayList(row.size()); + final List combined = new ArrayList<>(row.size()); for (int j = 0; j < row.size(); ++j) { final int[] termJ = row.get(j); if (termJ[0] > 0) { diff --git a/src/main/java/org/apache/commons/math4/analysis/differentiation/SparseGradient.java b/src/main/java/org/apache/commons/math4/analysis/differentiation/SparseGradient.java index 130c33505b..643a975f7d 100644 --- a/src/main/java/org/apache/commons/math4/analysis/differentiation/SparseGradient.java +++ b/src/main/java/org/apache/commons/math4/analysis/differentiation/SparseGradient.java @@ -61,7 +61,7 @@ public class SparseGradient implements RealFieldElement, Seriali */ private SparseGradient(final double value, final Map derivatives) { this.value = value; - this.derivatives = new HashMap(); + this.derivatives = new HashMap<>(); if (derivatives != null) { this.derivatives.putAll(derivatives); } @@ -77,7 +77,7 @@ private SparseGradient(final double value, final Map derivative private SparseGradient(final double value, final double scale, final Map derivatives) { this.value = value; - this.derivatives = new HashMap(); + this.derivatives = new HashMap<>(); if (derivatives != null) { for (final Map.Entry entry : derivatives.entrySet()) { this.derivatives.put(entry.getKey(), scale * entry.getValue()); diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactory.java index 0b3623800e..bd05c5e686 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactory.java @@ -37,10 +37,10 @@ public abstract class BaseRuleFactory { /** List of points and weights, indexed by the order of the rule. */ private final Map> pointsAndWeights - = new TreeMap>(); + = new TreeMap<>(); /** Cache for double-precision rules. */ private final Map> pointsAndWeightsDouble - = new TreeMap>(); + = new TreeMap<>(); /** * Gets a copy of the quadrature rule with the given number of integration @@ -75,7 +75,7 @@ public Pair getRule(int numberOfPoints) } // Return a copy. - return new Pair(cached.getFirst().clone(), + return new Pair<>(cached.getFirst().clone(), cached.getSecond().clone()); } @@ -149,6 +149,6 @@ private static Pair convertToDouble(Pair< wD[i] = wT[i].doubleValue(); } - return new Pair(pD, wD); + return new Pair<>(pD, wD); } } diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java index d15d6abe31..d392277ab4 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java @@ -162,6 +162,6 @@ private static Pair transform(Pair rule, weights[i] *= scale; } - return new Pair(points, weights); + return new Pair<>(points, weights); } } diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java index 5c1d0a2693..e65f5bdeb3 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java @@ -63,7 +63,7 @@ protected Pair computeRule(int numberOfPoints) if (numberOfPoints == 1) { // Break recursion. - return new Pair(new Double[] { 0d }, + return new Pair<>(new Double[] { 0d }, new Double[] { SQRT_PI }); } @@ -172,6 +172,6 @@ protected Pair computeRule(int numberOfPoints) weights[iMax] = w; } - return new Pair(points, weights); + return new Pair<>(points, weights); } } diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java index e4108a239b..1790c725a4 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java @@ -66,7 +66,7 @@ protected Pair computeRule(int numberOfPoints) if (numberOfPoints == 1) { // Break recursion. - return new Pair(new BigDecimal[] { BigDecimal.ZERO }, + return new Pair<>(new BigDecimal[] { BigDecimal.ZERO }, new BigDecimal[] { two }); } @@ -210,6 +210,6 @@ protected Pair computeRule(int numberOfPoints) weights[iMax] = tmp2; } - return new Pair(points, weights); + return new Pair<>(points, weights); } } diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java index 113ab3823f..29684bffa0 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java @@ -37,7 +37,7 @@ protected Pair computeRule(int numberOfPoints) if (numberOfPoints == 1) { // Break recursion. - return new Pair(new Double[] { 0d }, + return new Pair<>(new Double[] { 0d }, new Double[] { 2d }); } @@ -135,6 +135,6 @@ protected Pair computeRule(int numberOfPoints) weights[iMax] = w; } - return new Pair(points, weights); + return new Pair<>(points, weights); } } diff --git a/src/main/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolator.java b/src/main/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolator.java index e5e660f7a2..3241ddf383 100644 --- a/src/main/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolator.java +++ b/src/main/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolator.java @@ -61,9 +61,9 @@ public class FieldHermiteInterpolator> { /** Create an empty interpolator. */ public FieldHermiteInterpolator() { - this.abscissae = new ArrayList(); - this.topDiagonal = new ArrayList(); - this.bottomDiagonal = new ArrayList(); + this.abscissae = new ArrayList<>(); + this.topDiagonal = new ArrayList<>(); + this.bottomDiagonal = new ArrayList<>(); } /** Add a sample point. diff --git a/src/main/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolator.java b/src/main/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolator.java index 3aeb135034..5a30815060 100644 --- a/src/main/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolator.java +++ b/src/main/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolator.java @@ -59,9 +59,9 @@ public class HermiteInterpolator implements UnivariateDifferentiableVectorFuncti /** Create an empty interpolator. */ public HermiteInterpolator() { - this.abscissae = new ArrayList(); - this.topDiagonal = new ArrayList(); - this.bottomDiagonal = new ArrayList(); + this.abscissae = new ArrayList<>(); + this.topDiagonal = new ArrayList<>(); + this.bottomDiagonal = new ArrayList<>(); } /** Add a sample point. diff --git a/src/main/java/org/apache/commons/math4/analysis/interpolation/InterpolatingMicrosphere.java b/src/main/java/org/apache/commons/math4/analysis/interpolation/InterpolatingMicrosphere.java index c8929cf0ef..4887d80da1 100644 --- a/src/main/java/org/apache/commons/math4/analysis/interpolation/InterpolatingMicrosphere.java +++ b/src/main/java/org/apache/commons/math4/analysis/interpolation/InterpolatingMicrosphere.java @@ -93,8 +93,8 @@ protected InterpolatingMicrosphere(int dimension, this.maxDarkFraction = maxDarkFraction; this.darkThreshold = darkThreshold; this.background = background; - microsphere = new ArrayList(size); - microsphereData = new ArrayList(size); + microsphere = new ArrayList<>(size); + microsphereData = new ArrayList<>(size); } /** @@ -150,7 +150,7 @@ protected InterpolatingMicrosphere(InterpolatingMicrosphere other) { microsphere = other.microsphere; // Field must be copied. - microsphereData = new ArrayList(size); + microsphereData = new ArrayList<>(size); for (FacetData fd : other.microsphereData) { microsphereData.add(new FacetData(fd.illumination(), fd.sample())); } diff --git a/src/main/java/org/apache/commons/math4/analysis/polynomials/PolynomialsUtils.java b/src/main/java/org/apache/commons/math4/analysis/polynomials/PolynomialsUtils.java index c4069792a9..92e9e6d9a6 100644 --- a/src/main/java/org/apache/commons/math4/analysis/polynomials/PolynomialsUtils.java +++ b/src/main/java/org/apache/commons/math4/analysis/polynomials/PolynomialsUtils.java @@ -51,34 +51,34 @@ public class PolynomialsUtils { // initialize recurrence for Chebyshev polynomials // T0(X) = 1, T1(X) = 0 + 1 * X - CHEBYSHEV_COEFFICIENTS = new ArrayList(); + CHEBYSHEV_COEFFICIENTS = new ArrayList<>(); CHEBYSHEV_COEFFICIENTS.add(BigFraction.ONE); CHEBYSHEV_COEFFICIENTS.add(BigFraction.ZERO); CHEBYSHEV_COEFFICIENTS.add(BigFraction.ONE); // initialize recurrence for Hermite polynomials // H0(X) = 1, H1(X) = 0 + 2 * X - HERMITE_COEFFICIENTS = new ArrayList(); + HERMITE_COEFFICIENTS = new ArrayList<>(); HERMITE_COEFFICIENTS.add(BigFraction.ONE); HERMITE_COEFFICIENTS.add(BigFraction.ZERO); HERMITE_COEFFICIENTS.add(BigFraction.TWO); // initialize recurrence for Laguerre polynomials // L0(X) = 1, L1(X) = 1 - 1 * X - LAGUERRE_COEFFICIENTS = new ArrayList(); + LAGUERRE_COEFFICIENTS = new ArrayList<>(); LAGUERRE_COEFFICIENTS.add(BigFraction.ONE); LAGUERRE_COEFFICIENTS.add(BigFraction.ONE); LAGUERRE_COEFFICIENTS.add(BigFraction.MINUS_ONE); // initialize recurrence for Legendre polynomials // P0(X) = 1, P1(X) = 0 + 1 * X - LEGENDRE_COEFFICIENTS = new ArrayList(); + LEGENDRE_COEFFICIENTS = new ArrayList<>(); LEGENDRE_COEFFICIENTS.add(BigFraction.ONE); LEGENDRE_COEFFICIENTS.add(BigFraction.ZERO); LEGENDRE_COEFFICIENTS.add(BigFraction.ONE); // initialize map for Jacobi polynomials - JACOBI_COEFFICIENTS = new HashMap>(); + JACOBI_COEFFICIENTS = new HashMap<>(); } @@ -228,7 +228,7 @@ public static PolynomialFunction createJacobiPolynomial(final int degree, final if (!JACOBI_COEFFICIENTS.containsKey(key)) { // allocate a new list for v, w - final List list = new ArrayList(); + final List list = new ArrayList<>(); JACOBI_COEFFICIENTS.put(key, list); // Pv,w,0(x) = 1; diff --git a/src/main/java/org/apache/commons/math4/complex/Complex.java b/src/main/java/org/apache/commons/math4/complex/Complex.java index 5a073c7c28..48b17fc124 100644 --- a/src/main/java/org/apache/commons/math4/complex/Complex.java +++ b/src/main/java/org/apache/commons/math4/complex/Complex.java @@ -1209,7 +1209,7 @@ public List nthRoot(int n) throws NotPositiveException { n); } - final List result = new ArrayList(); + final List result = new ArrayList<>(); if (isNaN) { result.add(NaN); diff --git a/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java b/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java index 8e1149f0db..838e2252bb 100644 --- a/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java @@ -117,7 +117,7 @@ public EnumeratedDistribution(final RandomGenerator rng, final List(pmf.size()); + singletons = new ArrayList<>(pmf.size()); final double[] probs = new double[pmf.size()]; for (int i = 0; i < pmf.size(); i++) { @@ -191,10 +191,10 @@ public void reseedRandomGenerator(long seed) { * @return the probability mass function. */ public List> getPmf() { - final List> samples = new ArrayList>(probabilities.length); + final List> samples = new ArrayList<>(probabilities.length); for (int i = 0; i < probabilities.length; i++) { - samples.add(new Pair(singletons.get(i), probabilities[i])); + samples.add(new Pair<>(singletons.get(i), probabilities[i])); } return samples; diff --git a/src/main/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistribution.java b/src/main/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistribution.java index af641406ff..e3f271d9e7 100644 --- a/src/main/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistribution.java @@ -97,7 +97,7 @@ public EnumeratedIntegerDistribution(final RandomGenerator rng, throws DimensionMismatchException, NotPositiveException, MathArithmeticException, NotFiniteNumberException, NotANumberException { super(rng); - innerDistribution = new EnumeratedDistribution( + innerDistribution = new EnumeratedDistribution<>( rng, createDistribution(singletons, probabilities)); } @@ -111,7 +111,7 @@ public EnumeratedIntegerDistribution(final RandomGenerator rng, */ public EnumeratedIntegerDistribution(final RandomGenerator rng, final int[] data) { super(rng); - final Map dataMap = new HashMap(); + final Map dataMap = new HashMap<>(); for (int value : data) { Integer count = dataMap.get(value); if (count == null) { @@ -129,7 +129,7 @@ public EnumeratedIntegerDistribution(final RandomGenerator rng, final int[] data probabilities[index] = entry.getValue().intValue() / denom; index++; } - innerDistribution = new EnumeratedDistribution(rng, createDistribution(values, probabilities)); + innerDistribution = new EnumeratedDistribution<>(rng, createDistribution(values, probabilities)); } /** @@ -156,10 +156,10 @@ private static List> createDistribution(int[] singletons, throw new DimensionMismatchException(probabilities.length, singletons.length); } - final List> samples = new ArrayList>(singletons.length); + final List> samples = new ArrayList<>(singletons.length); for (int i = 0; i < singletons.length; i++) { - samples.add(new Pair(singletons[i], probabilities[i])); + samples.add(new Pair<>(singletons[i], probabilities[i])); } return samples; diff --git a/src/main/java/org/apache/commons/math4/distribution/EnumeratedRealDistribution.java b/src/main/java/org/apache/commons/math4/distribution/EnumeratedRealDistribution.java index 688b3fda46..b98b3ad28c 100644 --- a/src/main/java/org/apache/commons/math4/distribution/EnumeratedRealDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/EnumeratedRealDistribution.java @@ -99,7 +99,7 @@ public EnumeratedRealDistribution(final RandomGenerator rng, NotFiniteNumberException, NotANumberException { super(rng); - innerDistribution = new EnumeratedDistribution( + innerDistribution = new EnumeratedDistribution<>( rng, createDistribution(singletons, probabilities)); } @@ -113,7 +113,7 @@ public EnumeratedRealDistribution(final RandomGenerator rng, */ public EnumeratedRealDistribution(final RandomGenerator rng, final double[] data) { super(rng); - final Map dataMap = new HashMap(); + final Map dataMap = new HashMap<>(); for (double value : data) { Integer count = dataMap.get(value); if (count == null) { @@ -131,7 +131,7 @@ public EnumeratedRealDistribution(final RandomGenerator rng, final double[] data probabilities[index] = entry.getValue().intValue() / denom; index++; } - innerDistribution = new EnumeratedDistribution(rng, createDistribution(values, probabilities)); + innerDistribution = new EnumeratedDistribution<>(rng, createDistribution(values, probabilities)); } /** @@ -157,10 +157,10 @@ private static List> createDistribution(double[] singleton throw new DimensionMismatchException(probabilities.length, singletons.length); } - final List> samples = new ArrayList>(singletons.length); + final List> samples = new ArrayList<>(singletons.length); for (int i = 0; i < singletons.length; i++) { - samples.add(new Pair(singletons[i], probabilities[i])); + samples.add(new Pair<>(singletons[i], probabilities[i])); } return samples; diff --git a/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateNormalDistribution.java b/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateNormalDistribution.java index d7cd4cdb10..c06d8efc1a 100644 --- a/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateNormalDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateNormalDistribution.java @@ -99,13 +99,13 @@ private static List> createComponen double[][] means, double[][][] covariances) { final List> mvns - = new ArrayList>(weights.length); + = new ArrayList<>(weights.length); for (int i = 0; i < weights.length; i++) { final MultivariateNormalDistribution dist = new MultivariateNormalDistribution(means[i], covariances[i]); - mvns.add(new Pair(weights[i], dist)); + mvns.add(new Pair<>(weights[i], dist)); } return mvns; diff --git a/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateRealDistribution.java b/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateRealDistribution.java index ce8c7d9610..e20f0d65a6 100644 --- a/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateRealDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateRealDistribution.java @@ -93,7 +93,7 @@ public MixtureMultivariateRealDistribution(RandomGenerator rng, } // Store each distribution and its normalized weight. - distribution = new ArrayList(); + distribution = new ArrayList<>(); weight = new double[numComp]; for (int i = 0; i < numComp; i++) { final Pair comp = components.get(i); @@ -161,10 +161,10 @@ public void reseedRandomGenerator(long seed) { * @return the component distributions and associated weights. */ public List> getComponents() { - final List> list = new ArrayList>(weight.length); + final List> list = new ArrayList<>(weight.length); for (int i = 0; i < weight.length; i++) { - list.add(new Pair(weight[i], distribution.get(i))); + list.add(new Pair<>(weight[i], distribution.get(i))); } return list; diff --git a/src/main/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximization.java b/src/main/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximization.java index a0cf24818c..20cbfc2074 100644 --- a/src/main/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximization.java +++ b/src/main/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximization.java @@ -328,7 +328,7 @@ public static MixtureMultivariateNormalDistribution estimate(final double[][] da // components of mixture model to be created final List> components = - new ArrayList>(numComponents); + new ArrayList<>(numComponents); // create a component based on data in each bin for (int binIndex = 0; binIndex < numComponents; binIndex++) { @@ -364,7 +364,7 @@ public static MixtureMultivariateNormalDistribution estimate(final double[][] da final MultivariateNormalDistribution mvn = new MultivariateNormalDistribution(columnMeans, covMat); - components.add(new Pair(weight, mvn)); + components.add(new Pair<>(weight, mvn)); } return new MixtureMultivariateNormalDistribution(components); diff --git a/src/main/java/org/apache/commons/math4/exception/util/ArgUtils.java b/src/main/java/org/apache/commons/math4/exception/util/ArgUtils.java index 577b0a56af..6e447a019b 100644 --- a/src/main/java/org/apache/commons/math4/exception/util/ArgUtils.java +++ b/src/main/java/org/apache/commons/math4/exception/util/ArgUtils.java @@ -38,7 +38,7 @@ private ArgUtils() {} * {@code array}. */ public static Object[] flatten(Object[] array) { - final List list = new ArrayList(); + final List list = new ArrayList<>(); if (array != null) { for (Object o : array) { if (o instanceof Object[]) { diff --git a/src/main/java/org/apache/commons/math4/exception/util/ExceptionContext.java b/src/main/java/org/apache/commons/math4/exception/util/ExceptionContext.java index 59f91a313d..4cdde9af93 100644 --- a/src/main/java/org/apache/commons/math4/exception/util/ExceptionContext.java +++ b/src/main/java/org/apache/commons/math4/exception/util/ExceptionContext.java @@ -62,9 +62,9 @@ public class ExceptionContext implements Serializable { */ public ExceptionContext(final Throwable throwable) { this.throwable = throwable; - msgPatterns = new ArrayList(); - msgArguments = new ArrayList(); - context = new HashMap(); + msgPatterns = new ArrayList<>(); + msgArguments = new ArrayList<>(); + context = new HashMap<>(); } /** Get a reference to the exception to which the context relates. @@ -256,8 +256,8 @@ private void deSerializeMessages(ObjectInputStream in) ClassNotFoundException { // Step 1. final int len = in.readInt(); - msgPatterns = new ArrayList(len); - msgArguments = new ArrayList(len); + msgPatterns = new ArrayList<>(len); + msgArguments = new ArrayList<>(len); // Step 2. for (int i = 0; i < len; i++) { // Step 3. @@ -311,7 +311,7 @@ private void deSerializeContext(ObjectInputStream in) ClassNotFoundException { // Step 1. final int len = in.readInt(); - context = new HashMap(); + context = new HashMap<>(); for (int i = 0; i < len; i++) { // Step 2. final String key = (String) in.readObject(); diff --git a/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java b/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java index ae2b8d8dac..3c5f14a320 100644 --- a/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java +++ b/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java @@ -248,7 +248,7 @@ public double[] guess() { * @return the input observations, sorted. */ private List sortObservations(Collection unsorted) { - final List observations = new ArrayList(unsorted); + final List observations = new ArrayList<>(unsorted); final Comparator cmp = new Comparator() { /** {@inheritDoc} */ diff --git a/src/main/java/org/apache/commons/math4/fitting/HarmonicCurveFitter.java b/src/main/java/org/apache/commons/math4/fitting/HarmonicCurveFitter.java index c8a2a8e37d..fbd643f2c2 100644 --- a/src/main/java/org/apache/commons/math4/fitting/HarmonicCurveFitter.java +++ b/src/main/java/org/apache/commons/math4/fitting/HarmonicCurveFitter.java @@ -292,7 +292,7 @@ public double[] guess() { * @return the input observations, sorted. */ private List sortObservations(Collection unsorted) { - final List observations = new ArrayList(unsorted); + final List observations = new ArrayList<>(unsorted); // Since the samples are almost always already sorted, this // method is implemented as an insertion sort that reorders the diff --git a/src/main/java/org/apache/commons/math4/fitting/WeightedObservedPoints.java b/src/main/java/org/apache/commons/math4/fitting/WeightedObservedPoints.java index 520af887b6..00cef70ce0 100644 --- a/src/main/java/org/apache/commons/math4/fitting/WeightedObservedPoints.java +++ b/src/main/java/org/apache/commons/math4/fitting/WeightedObservedPoints.java @@ -32,7 +32,7 @@ public class WeightedObservedPoints implements Serializable { /** Observed points. */ private final List observations - = new ArrayList(); + = new ArrayList<>(); /** * Adds a point to the sample. @@ -100,7 +100,7 @@ public List toList() { // The copy is necessary to ensure thread-safety because of the // "clear" method (which otherwise would be able to empty the // list of points while it is being used by another thread). - return new ArrayList(observations); + return new ArrayList<>(observations); } /** diff --git a/src/main/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizer.java b/src/main/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizer.java index ec17b931c1..637382cdf2 100644 --- a/src/main/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizer.java +++ b/src/main/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizer.java @@ -294,7 +294,7 @@ private static Pair computeNormalMatrix(final RealMatrix normal.setEntry(i, j, normal.getEntry(j, i)); } } - return new Pair(normal, jTr); + return new Pair<>(normal, jTr); } } diff --git a/src/main/java/org/apache/commons/math4/fitting/leastsquares/LeastSquaresFactory.java b/src/main/java/org/apache/commons/math4/fitting/leastsquares/LeastSquaresFactory.java index a0ddace064..933278d5a4 100644 --- a/src/main/java/org/apache/commons/math4/fitting/leastsquares/LeastSquaresFactory.java +++ b/src/main/java/org/apache/commons/math4/fitting/leastsquares/LeastSquaresFactory.java @@ -332,7 +332,7 @@ public Pair value(final RealVector point) { final double[] p = point.toArray(); // Evaluate. - return new Pair(computeValue(p), + return new Pair<>(computeValue(p), computeJacobian(p)); } diff --git a/src/main/java/org/apache/commons/math4/genetics/AbstractListChromosome.java b/src/main/java/org/apache/commons/math4/genetics/AbstractListChromosome.java index 707ddd5044..e7ac9a87f5 100644 --- a/src/main/java/org/apache/commons/math4/genetics/AbstractListChromosome.java +++ b/src/main/java/org/apache/commons/math4/genetics/AbstractListChromosome.java @@ -59,7 +59,7 @@ public AbstractListChromosome(final T[] representation) throws InvalidRepresenta public AbstractListChromosome(final List representation, final boolean copyList) { checkValidity(representation); this.representation = - Collections.unmodifiableList(copyList ? new ArrayList(representation) : representation); + Collections.unmodifiableList(copyList ? new ArrayList<>(representation) : representation); } /** diff --git a/src/main/java/org/apache/commons/math4/genetics/BinaryChromosome.java b/src/main/java/org/apache/commons/math4/genetics/BinaryChromosome.java index b4aa23291d..6f1e08cb10 100644 --- a/src/main/java/org/apache/commons/math4/genetics/BinaryChromosome.java +++ b/src/main/java/org/apache/commons/math4/genetics/BinaryChromosome.java @@ -67,7 +67,7 @@ protected void checkValidity(List chromosomeRepresentation) throws Inva */ public static List randomBinaryRepresentation(int length) { // random binary list - List rList= new ArrayList (length); + List rList= new ArrayList<> (length); for (int j=0; j newRepr = new ArrayList(origChrom.getRepresentation()); + List newRepr = new ArrayList<>(origChrom.getRepresentation()); // randomly select a gene int geneIndex = GeneticAlgorithm.getRandomGenerator().nextInt(origChrom.getLength()); diff --git a/src/main/java/org/apache/commons/math4/genetics/CycleCrossover.java b/src/main/java/org/apache/commons/math4/genetics/CycleCrossover.java index 507ffdf499..0de83713a8 100644 --- a/src/main/java/org/apache/commons/math4/genetics/CycleCrossover.java +++ b/src/main/java/org/apache/commons/math4/genetics/CycleCrossover.java @@ -129,13 +129,13 @@ protected ChromosomePair mate(final AbstractListChromosome first, final Abstr final List parent1Rep = first.getRepresentation(); final List parent2Rep = second.getRepresentation(); // and of the children: do a crossover copy to simplify the later processing - final List child1Rep = new ArrayList(second.getRepresentation()); - final List child2Rep = new ArrayList(first.getRepresentation()); + final List child1Rep = new ArrayList<>(second.getRepresentation()); + final List child2Rep = new ArrayList<>(first.getRepresentation()); // the set of all visited indices so far - final Set visitedIndices = new HashSet(length); + final Set visitedIndices = new HashSet<>(length); // the indices of the current cycle - final List indices = new ArrayList(length); + final List indices = new ArrayList<>(length); // determine the starting index int idx = randomStart ? GeneticAlgorithm.getRandomGenerator().nextInt(length) : 0; diff --git a/src/main/java/org/apache/commons/math4/genetics/ListPopulation.java b/src/main/java/org/apache/commons/math4/genetics/ListPopulation.java index 1adf6ac634..0aa02396b1 100644 --- a/src/main/java/org/apache/commons/math4/genetics/ListPopulation.java +++ b/src/main/java/org/apache/commons/math4/genetics/ListPopulation.java @@ -76,7 +76,7 @@ public ListPopulation(final List chromosomes, final int populationLi chromosomes.size(), populationLimit, false); } this.populationLimit = populationLimit; - this.chromosomes = new ArrayList(populationLimit); + this.chromosomes = new ArrayList<>(populationLimit); this.chromosomes.addAll(chromosomes); } diff --git a/src/main/java/org/apache/commons/math4/genetics/NPointCrossover.java b/src/main/java/org/apache/commons/math4/genetics/NPointCrossover.java index 5c79ef1f4d..720df8af01 100644 --- a/src/main/java/org/apache/commons/math4/genetics/NPointCrossover.java +++ b/src/main/java/org/apache/commons/math4/genetics/NPointCrossover.java @@ -139,8 +139,8 @@ private ChromosomePair mate(final AbstractListChromosome first, final List parent1Rep = first.getRepresentation(); final List parent2Rep = second.getRepresentation(); // and of the children - final List child1Rep = new ArrayList(length); - final List child2Rep = new ArrayList(length); + final List child1Rep = new ArrayList<>(length); + final List child2Rep = new ArrayList<>(length); final RandomGenerator random = GeneticAlgorithm.getRandomGenerator(); diff --git a/src/main/java/org/apache/commons/math4/genetics/OnePointCrossover.java b/src/main/java/org/apache/commons/math4/genetics/OnePointCrossover.java index 0df7313c69..7308043612 100644 --- a/src/main/java/org/apache/commons/math4/genetics/OnePointCrossover.java +++ b/src/main/java/org/apache/commons/math4/genetics/OnePointCrossover.java @@ -105,8 +105,8 @@ private ChromosomePair crossover(final AbstractListChromosome first, final List parent1Rep = first.getRepresentation(); final List parent2Rep = second.getRepresentation(); // and of the children - final List child1Rep = new ArrayList(length); - final List child2Rep = new ArrayList(length); + final List child1Rep = new ArrayList<>(length); + final List child2Rep = new ArrayList<>(length); // select a crossover point at random (0 and length makes no sense) final int crossoverIndex = 1 + (GeneticAlgorithm.getRandomGenerator().nextInt(length-2)); diff --git a/src/main/java/org/apache/commons/math4/genetics/OrderedCrossover.java b/src/main/java/org/apache/commons/math4/genetics/OrderedCrossover.java index b5aecc8f83..2ceb299251 100644 --- a/src/main/java/org/apache/commons/math4/genetics/OrderedCrossover.java +++ b/src/main/java/org/apache/commons/math4/genetics/OrderedCrossover.java @@ -97,11 +97,11 @@ protected ChromosomePair mate(final AbstractListChromosome first, final Abstr final List parent1Rep = first.getRepresentation(); final List parent2Rep = second.getRepresentation(); // and of the children - final List child1 = new ArrayList(length); - final List child2 = new ArrayList(length); + final List child1 = new ArrayList<>(length); + final List child2 = new ArrayList<>(length); // sets of already inserted items for quick access - final Set child1Set = new HashSet(length); - final Set child2Set = new HashSet(length); + final Set child1Set = new HashSet<>(length); + final Set child2Set = new HashSet<>(length); final RandomGenerator random = GeneticAlgorithm.getRandomGenerator(); // choose random points, making sure that lb < ub. diff --git a/src/main/java/org/apache/commons/math4/genetics/RandomKey.java b/src/main/java/org/apache/commons/math4/genetics/RandomKey.java index 8186a5274d..ea0a40119e 100644 --- a/src/main/java/org/apache/commons/math4/genetics/RandomKey.java +++ b/src/main/java/org/apache/commons/math4/genetics/RandomKey.java @@ -72,7 +72,7 @@ public abstract class RandomKey extends AbstractListChromosome implem public RandomKey(final List representation) throws InvalidRepresentationException { super(representation); // store the sorted representation - List sortedRepr = new ArrayList (getRepresentation()); + List sortedRepr = new ArrayList<> (getRepresentation()); Collections.sort(sortedRepr); sortedRepresentation = Collections.unmodifiableList(sortedRepr); // store the permutation of [0,1,...,n-1] list for toString() and isSame() methods @@ -126,10 +126,10 @@ private static List decodeGeneric(final List sequence, List re } // do not modify the original representation - List reprCopy = new ArrayList (representation); + List reprCopy = new ArrayList<> (representation); // now find the indices in the original repr and use them for permuting - List res = new ArrayList (l); + List res = new ArrayList<> (l); for (int i=0; i chromosomeRepresentation) * @return representation of a random permutation */ public static final List randomPermutation(final int l) { - List repr = new ArrayList(l); + List repr = new ArrayList<>(l); for (int i=0; i randomPermutation(final int l) { * @return representation of an identity permutation */ public static final List identityPermutation(final int l) { - List repr = new ArrayList(l); + List repr = new ArrayList<>(l); for (int i=0; i identityPermutation(final int l) { */ public static List comparatorPermutation(final List data, final Comparator comparator) { - List sortedData = new ArrayList(data); + List sortedData = new ArrayList<>(data); Collections.sort(sortedData, comparator); return inducedPermutation(data, sortedData); @@ -264,7 +264,7 @@ public static List inducedPermutation(final List originalData, } int l = originalData.size(); - List origDataCopy = new ArrayList (originalData); + List origDataCopy = new ArrayList<> (originalData); Double[] res = new Double[l]; for (int i=0; i baseSequence(final int l) { - List baseSequence = new ArrayList (l); + List baseSequence = new ArrayList<> (l); for (int i=0; i repr = originalRk.getRepresentation(); int rInd = GeneticAlgorithm.getRandomGenerator().nextInt(repr.size()); - List newRepr = new ArrayList (repr); + List newRepr = new ArrayList<> (repr); newRepr.set(rInd, GeneticAlgorithm.getRandomGenerator().nextDouble()); return originalRk.newFixedLengthChromosome(newRepr); diff --git a/src/main/java/org/apache/commons/math4/genetics/TournamentSelection.java b/src/main/java/org/apache/commons/math4/genetics/TournamentSelection.java index 97becff404..0924033031 100644 --- a/src/main/java/org/apache/commons/math4/genetics/TournamentSelection.java +++ b/src/main/java/org/apache/commons/math4/genetics/TournamentSelection.java @@ -84,7 +84,7 @@ public Population nextGeneration() { }; // create a copy of the chromosome list - List chromosomes = new ArrayList (population.getChromosomes()); + List chromosomes = new ArrayList<> (population.getChromosomes()); for (int i=0; i first, final List parent1Rep = first.getRepresentation(); final List parent2Rep = second.getRepresentation(); // and of the children - final List child1Rep = new ArrayList(length); - final List child2Rep = new ArrayList(length); + final List child1Rep = new ArrayList<>(length); + final List child2Rep = new ArrayList<>(length); final RandomGenerator random = GeneticAlgorithm.getRandomGenerator(); diff --git a/src/main/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser.java b/src/main/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser.java index 9cd1112781..b76ff6a9d9 100644 --- a/src/main/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser.java +++ b/src/main/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser.java @@ -78,8 +78,8 @@ public EnclosingBall enclose(final Iterable

points) { private EnclosingBall pivotingBall(final Iterable

points) { final P first = points.iterator().next(); - final List

extreme = new ArrayList

(first.getSpace().getDimension() + 1); - final List

support = new ArrayList

(first.getSpace().getDimension() + 1); + final List

extreme = new ArrayList<>(first.getSpace().getDimension() + 1); + final List

support = new ArrayList<>(first.getSpace().getDimension() + 1); // start with only first point selected as a candidate support extreme.add(first); diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java index 7d944afb45..1b58cd9970 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java @@ -108,12 +108,12 @@ private static BSPTree buildTree(final double lower, final double u if (Double.isInfinite(lower) && (lower < 0)) { if (Double.isInfinite(upper) && (upper > 0)) { // the tree must cover the whole real line - return new BSPTree(Boolean.TRUE); + return new BSPTree<>(Boolean.TRUE); } // the tree must be open on the negative infinity side final SubHyperplane upperCut = new OrientedPoint(new Vector1D(upper), true, tolerance).wholeHyperplane(); - return new BSPTree(upperCut, + return new BSPTree<>(upperCut, new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null); @@ -122,7 +122,7 @@ private static BSPTree buildTree(final double lower, final double u new OrientedPoint(new Vector1D(lower), false, tolerance).wholeHyperplane(); if (Double.isInfinite(upper) && (upper > 0)) { // the tree must be open on the positive infinity side - return new BSPTree(lowerCut, + return new BSPTree<>(lowerCut, new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null); @@ -131,9 +131,9 @@ private static BSPTree buildTree(final double lower, final double u // the tree must be bounded on the two sides final SubHyperplane upperCut = new OrientedPoint(new Vector1D(upper), true, tolerance).wholeHyperplane(); - return new BSPTree(lowerCut, + return new BSPTree<>(lowerCut, new BSPTree(Boolean.FALSE), - new BSPTree(upperCut, + new BSPTree<>(upperCut, new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null), @@ -222,9 +222,9 @@ public BoundaryProjection projectToBoundary(final Point(point, finiteOrNullPoint(previous), previousOffset); + return new BoundaryProjection<>(point, finiteOrNullPoint(previous), previousOffset); } else { - return new BoundaryProjection(point, finiteOrNullPoint(a[0]), currentOffset); + return new BoundaryProjection<>(point, finiteOrNullPoint(a[0]), currentOffset); } } else if (x <= a[1]) { // the test point lies within the current interval @@ -232,16 +232,16 @@ public BoundaryProjection projectToBoundary(final Point(point, finiteOrNullPoint(a[1]), offset1); + return new BoundaryProjection<>(point, finiteOrNullPoint(a[1]), offset1); } else { - return new BoundaryProjection(point, finiteOrNullPoint(a[0]), offset0); + return new BoundaryProjection<>(point, finiteOrNullPoint(a[0]), offset0); } } previous = a[1]; } // the test point if past the last sub-interval - return new BoundaryProjection(point, finiteOrNullPoint(previous), x - previous); + return new BoundaryProjection<>(point, finiteOrNullPoint(previous), x - previous); } @@ -267,7 +267,7 @@ private Vector1D finiteOrNullPoint(final double x) { * elements */ public List asList() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (final double[] a : this) { list.add(new Interval(a[0], a[1])); } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/SubOrientedPoint.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/SubOrientedPoint.java index a80873d8a0..878c0466e9 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/SubOrientedPoint.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/SubOrientedPoint.java @@ -61,11 +61,11 @@ protected AbstractSubHyperplane buildNew(final Hyperpl public SplitSubHyperplane split(final Hyperplane hyperplane) { final double global = hyperplane.getOffset(((OrientedPoint) getHyperplane()).getLocation()); if (global < -1.0e-10) { - return new SplitSubHyperplane(null, this); + return new SplitSubHyperplane<>(null, this); } else if (global > 1.0e-10) { - return new SplitSubHyperplane(this, null); + return new SplitSubHyperplane<>(this, null); } else { - return new SplitSubHyperplane(null, null); + return new SplitSubHyperplane<>(null, null); } } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java index 2dc69337b9..be89ef41be 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java @@ -374,9 +374,9 @@ public FieldRotation(final RotationOrder order, final T alpha1, final T alpha2, public FieldRotation(final RotationOrder order, final RotationConvention convention, final T alpha1, final T alpha2, final T alpha3) { final T one = alpha1.getField().getOne(); - final FieldRotation r1 = new FieldRotation(new FieldVector3D(one, order.getA1()), alpha1, convention); - final FieldRotation r2 = new FieldRotation(new FieldVector3D(one, order.getA2()), alpha2, convention); - final FieldRotation r3 = new FieldRotation(new FieldVector3D(one, order.getA3()), alpha3, convention); + final FieldRotation r1 = new FieldRotation<>(new FieldVector3D<>(one, order.getA1()), alpha1, convention); + final FieldRotation r2 = new FieldRotation<>(new FieldVector3D<>(one, order.getA2()), alpha2, convention); + final FieldRotation r3 = new FieldRotation<>(new FieldVector3D<>(one, order.getA3()), alpha3, convention); final FieldRotation composed = r1.compose(r2.compose(r3, convention), convention); q0 = composed.q0; q1 = composed.q1; @@ -453,7 +453,7 @@ private T[] mat2quat(final T[][] ort) { * of the instance */ public FieldRotation revert() { - return new FieldRotation(q0.negate(), q1, q2, q3, false); + return new FieldRotation<>(q0.negate(), q1, q2, q3, false); } /** Get the scalar coordinate of the quaternion. @@ -509,17 +509,17 @@ public FieldVector3D getAxis(final RotationConvention convention) { final T squaredSine = q1.multiply(q1).add(q2.multiply(q2)).add(q3.multiply(q3)); if (squaredSine.getReal() == 0) { final Field field = squaredSine.getField(); - return new FieldVector3D(convention == RotationConvention.VECTOR_OPERATOR ? field.getOne(): field.getOne().negate(), + return new FieldVector3D<>(convention == RotationConvention.VECTOR_OPERATOR ? field.getOne(): field.getOne().negate(), field.getZero(), field.getZero()); } else { final double sgn = convention == RotationConvention.VECTOR_OPERATOR ? +1 : -1; if (q0.getReal() < 0) { T inverse = squaredSine.sqrt().reciprocal().multiply(sgn); - return new FieldVector3D(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse)); + return new FieldVector3D<>(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse)); } final T inverse = squaredSine.sqrt().reciprocal().negate().multiply(sgn); - return new FieldVector3D(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse)); + return new FieldVector3D<>(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse)); } } @@ -1032,7 +1032,7 @@ private T[] buildArray(final T a0, final T a1, final T a2) { */ private FieldVector3D vector(final double x, final double y, final double z) { final T zero = q0.getField().getZero(); - return new FieldVector3D(zero.add(x), zero.add(y), zero.add(z)); + return new FieldVector3D<>(zero.add(x), zero.add(y), zero.add(z)); } /** Get the 3X3 matrix corresponding to the instance @@ -1090,7 +1090,7 @@ public FieldVector3D applyTo(final FieldVector3D u) { final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z)); - return new FieldVector3D(q0.multiply(x.multiply(q0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), + return new FieldVector3D<>(q0.multiply(x.multiply(q0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), q0.multiply(y.multiply(q0).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y), q0.multiply(z.multiply(q0).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z)); @@ -1108,7 +1108,7 @@ public FieldVector3D applyTo(final Vector3D u) { final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z)); - return new FieldVector3D(q0.multiply(q0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), + return new FieldVector3D<>(q0.multiply(q0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), q0.multiply(q0.multiply(y).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y), q0.multiply(q0.multiply(z).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z)); @@ -1165,7 +1165,7 @@ public static > FieldVector3D applyTo(final Rot final T s = x.multiply(r.getQ1()).add(y.multiply(r.getQ2())).add(z.multiply(r.getQ3())); - return new FieldVector3D(x.multiply(r.getQ0()).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(r.getQ0()).add(s.multiply(r.getQ1())).multiply(2).subtract(x), + return new FieldVector3D<>(x.multiply(r.getQ0()).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(r.getQ0()).add(s.multiply(r.getQ1())).multiply(2).subtract(x), y.multiply(r.getQ0()).subtract(x.multiply(r.getQ3()).subtract(z.multiply(r.getQ1()))).multiply(r.getQ0()).add(s.multiply(r.getQ2())).multiply(2).subtract(y), z.multiply(r.getQ0()).subtract(y.multiply(r.getQ1()).subtract(x.multiply(r.getQ2()))).multiply(r.getQ0()).add(s.multiply(r.getQ3())).multiply(2).subtract(z)); @@ -1184,7 +1184,7 @@ public FieldVector3D applyInverseTo(final FieldVector3D u) { final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z)); final T m0 = q0.negate(); - return new FieldVector3D(m0.multiply(x.multiply(m0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), + return new FieldVector3D<>(m0.multiply(x.multiply(m0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), m0.multiply(y.multiply(m0).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y), m0.multiply(z.multiply(m0).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z)); @@ -1203,7 +1203,7 @@ public FieldVector3D applyInverseTo(final Vector3D u) { final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z)); final T m0 = q0.negate(); - return new FieldVector3D(m0.multiply(m0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), + return new FieldVector3D<>(m0.multiply(m0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), m0.multiply(m0.multiply(y).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y), m0.multiply(m0.multiply(z).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z)); @@ -1263,7 +1263,7 @@ public static > FieldVector3D applyInverseTo(fi final T s = x.multiply(r.getQ1()).add(y.multiply(r.getQ2())).add(z.multiply(r.getQ3())); final double m0 = -r.getQ0(); - return new FieldVector3D(x.multiply(m0).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(m0).add(s.multiply(r.getQ1())).multiply(2).subtract(x), + return new FieldVector3D<>(x.multiply(m0).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(m0).add(s.multiply(r.getQ1())).multiply(2).subtract(x), y.multiply(m0).subtract(x.multiply(r.getQ3()).subtract(z.multiply(r.getQ1()))).multiply(m0).add(s.multiply(r.getQ2())).multiply(2).subtract(y), z.multiply(m0).subtract(y.multiply(r.getQ1()).subtract(x.multiply(r.getQ2()))).multiply(m0).add(s.multiply(r.getQ3())).multiply(2).subtract(z)); @@ -1317,7 +1317,7 @@ public FieldRotation compose(final FieldRotation r, final RotationConventi * using vector operator convention */ private FieldRotation composeInternal(final FieldRotation r) { - return new FieldRotation(r.q0.multiply(q0).subtract(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))), + return new FieldRotation<>(r.q0.multiply(q0).subtract(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))), r.q1.multiply(q0).add(r.q0.multiply(q1)).add(r.q2.multiply(q3).subtract(r.q3.multiply(q2))), r.q2.multiply(q0).add(r.q0.multiply(q2)).add(r.q3.multiply(q1).subtract(r.q1.multiply(q3))), r.q3.multiply(q0).add(r.q0.multiply(q3)).add(r.q1.multiply(q2).subtract(r.q2.multiply(q1))), @@ -1372,7 +1372,7 @@ public FieldRotation compose(final Rotation r, final RotationConvention conve * using vector operator convention */ private FieldRotation composeInternal(final Rotation r) { - return new FieldRotation(q0.multiply(r.getQ0()).subtract(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))), + return new FieldRotation<>(q0.multiply(r.getQ0()).subtract(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))), q0.multiply(r.getQ1()).add(q1.multiply(r.getQ0())).add(q3.multiply(r.getQ2()).subtract(q2.multiply(r.getQ3()))), q0.multiply(r.getQ2()).add(q2.multiply(r.getQ0())).add(q1.multiply(r.getQ3()).subtract(q3.multiply(r.getQ1()))), q0.multiply(r.getQ3()).add(q3.multiply(r.getQ0())).add(q2.multiply(r.getQ1()).subtract(q1.multiply(r.getQ2()))), @@ -1391,7 +1391,7 @@ private FieldRotation composeInternal(final Rotation r) { * @return a new rotation which is the composition of r by the instance */ public static > FieldRotation applyTo(final Rotation r1, final FieldRotation rInner) { - return new FieldRotation(rInner.q0.multiply(r1.getQ0()).subtract(rInner.q1.multiply(r1.getQ1()).add(rInner.q2.multiply(r1.getQ2())).add(rInner.q3.multiply(r1.getQ3()))), + return new FieldRotation<>(rInner.q0.multiply(r1.getQ0()).subtract(rInner.q1.multiply(r1.getQ1()).add(rInner.q2.multiply(r1.getQ2())).add(rInner.q3.multiply(r1.getQ3()))), rInner.q1.multiply(r1.getQ0()).add(rInner.q0.multiply(r1.getQ1())).add(rInner.q2.multiply(r1.getQ3()).subtract(rInner.q3.multiply(r1.getQ2()))), rInner.q2.multiply(r1.getQ0()).add(rInner.q0.multiply(r1.getQ2())).add(rInner.q3.multiply(r1.getQ1()).subtract(rInner.q1.multiply(r1.getQ3()))), rInner.q3.multiply(r1.getQ0()).add(rInner.q0.multiply(r1.getQ3())).add(rInner.q1.multiply(r1.getQ2()).subtract(rInner.q2.multiply(r1.getQ1()))), @@ -1450,7 +1450,7 @@ public FieldRotation composeInverse(final FieldRotation r, final RotationC * of the instance using vector operator convention */ private FieldRotation composeInverseInternal(FieldRotation r) { - return new FieldRotation(r.q0.multiply(q0).add(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))).negate(), + return new FieldRotation<>(r.q0.multiply(q0).add(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))).negate(), r.q0.multiply(q1).add(r.q2.multiply(q3).subtract(r.q3.multiply(q2))).subtract(r.q1.multiply(q0)), r.q0.multiply(q2).add(r.q3.multiply(q1).subtract(r.q1.multiply(q3))).subtract(r.q2.multiply(q0)), r.q0.multiply(q3).add(r.q1.multiply(q2).subtract(r.q2.multiply(q1))).subtract(r.q3.multiply(q0)), @@ -1509,7 +1509,7 @@ public FieldRotation composeInverse(final Rotation r, final RotationConventio * of the instance using vector operator convention */ private FieldRotation composeInverseInternal(Rotation r) { - return new FieldRotation(q0.multiply(r.getQ0()).add(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))).negate(), + return new FieldRotation<>(q0.multiply(r.getQ0()).add(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))).negate(), q1.multiply(r.getQ0()).add(q3.multiply(r.getQ2()).subtract(q2.multiply(r.getQ3()))).subtract(q0.multiply(r.getQ1())), q2.multiply(r.getQ0()).add(q1.multiply(r.getQ3()).subtract(q3.multiply(r.getQ1()))).subtract(q0.multiply(r.getQ2())), q3.multiply(r.getQ0()).add(q2.multiply(r.getQ1()).subtract(q1.multiply(r.getQ2()))).subtract(q0.multiply(r.getQ3())), @@ -1530,7 +1530,7 @@ private FieldRotation composeInverseInternal(Rotation r) { * of the instance */ public static > FieldRotation applyInverseTo(final Rotation rOuter, final FieldRotation rInner) { - return new FieldRotation(rInner.q0.multiply(rOuter.getQ0()).add(rInner.q1.multiply(rOuter.getQ1()).add(rInner.q2.multiply(rOuter.getQ2())).add(rInner.q3.multiply(rOuter.getQ3()))).negate(), + return new FieldRotation<>(rInner.q0.multiply(rOuter.getQ0()).add(rInner.q1.multiply(rOuter.getQ1()).add(rInner.q2.multiply(rOuter.getQ2())).add(rInner.q3.multiply(rOuter.getQ3()))).negate(), rInner.q0.multiply(rOuter.getQ1()).add(rInner.q2.multiply(rOuter.getQ3()).subtract(rInner.q3.multiply(rOuter.getQ2()))).subtract(rInner.q1.multiply(rOuter.getQ0())), rInner.q0.multiply(rOuter.getQ2()).add(rInner.q3.multiply(rOuter.getQ1()).subtract(rInner.q1.multiply(rOuter.getQ3()))).subtract(rInner.q2.multiply(rOuter.getQ0())), rInner.q0.multiply(rOuter.getQ3()).add(rInner.q1.multiply(rOuter.getQ2()).subtract(rInner.q2.multiply(rOuter.getQ1()))).subtract(rInner.q3.multiply(rOuter.getQ0())), diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java index f03a1ececa..bec2d74e8d 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java @@ -408,7 +408,7 @@ public T getDelta() { * @return a new vector */ public FieldVector3D add(final FieldVector3D v) { - return new FieldVector3D(x.add(v.x), y.add(v.y), z.add(v.z)); + return new FieldVector3D<>(x.add(v.x), y.add(v.y), z.add(v.z)); } /** Add a vector to the instance. @@ -416,7 +416,7 @@ public FieldVector3D add(final FieldVector3D v) { * @return a new vector */ public FieldVector3D add(final Vector3D v) { - return new FieldVector3D(x.add(v.getX()), y.add(v.getY()), z.add(v.getZ())); + return new FieldVector3D<>(x.add(v.getX()), y.add(v.getY()), z.add(v.getZ())); } /** Add a scaled vector to the instance. @@ -425,7 +425,7 @@ public FieldVector3D add(final Vector3D v) { * @return a new vector */ public FieldVector3D add(final T factor, final FieldVector3D v) { - return new FieldVector3D(x.getField().getOne(), this, factor, v); + return new FieldVector3D<>(x.getField().getOne(), this, factor, v); } /** Add a scaled vector to the instance. @@ -434,7 +434,7 @@ public FieldVector3D add(final T factor, final FieldVector3D v) { * @return a new vector */ public FieldVector3D add(final T factor, final Vector3D v) { - return new FieldVector3D(x.add(factor.multiply(v.getX())), + return new FieldVector3D<>(x.add(factor.multiply(v.getX())), y.add(factor.multiply(v.getY())), z.add(factor.multiply(v.getZ()))); } @@ -445,7 +445,7 @@ public FieldVector3D add(final T factor, final Vector3D v) { * @return a new vector */ public FieldVector3D add(final double factor, final FieldVector3D v) { - return new FieldVector3D(1.0, this, factor, v); + return new FieldVector3D<>(1.0, this, factor, v); } /** Add a scaled vector to the instance. @@ -454,7 +454,7 @@ public FieldVector3D add(final double factor, final FieldVector3D v) { * @return a new vector */ public FieldVector3D add(final double factor, final Vector3D v) { - return new FieldVector3D(x.add(factor * v.getX()), + return new FieldVector3D<>(x.add(factor * v.getX()), y.add(factor * v.getY()), z.add(factor * v.getZ())); } @@ -464,7 +464,7 @@ public FieldVector3D add(final double factor, final Vector3D v) { * @return a new vector */ public FieldVector3D subtract(final FieldVector3D v) { - return new FieldVector3D(x.subtract(v.x), y.subtract(v.y), z.subtract(v.z)); + return new FieldVector3D<>(x.subtract(v.x), y.subtract(v.y), z.subtract(v.z)); } /** Subtract a vector from the instance. @@ -472,7 +472,7 @@ public FieldVector3D subtract(final FieldVector3D v) { * @return a new vector */ public FieldVector3D subtract(final Vector3D v) { - return new FieldVector3D(x.subtract(v.getX()), y.subtract(v.getY()), z.subtract(v.getZ())); + return new FieldVector3D<>(x.subtract(v.getX()), y.subtract(v.getY()), z.subtract(v.getZ())); } /** Subtract a scaled vector from the instance. @@ -481,7 +481,7 @@ public FieldVector3D subtract(final Vector3D v) { * @return a new vector */ public FieldVector3D subtract(final T factor, final FieldVector3D v) { - return new FieldVector3D(x.getField().getOne(), this, factor.negate(), v); + return new FieldVector3D<>(x.getField().getOne(), this, factor.negate(), v); } /** Subtract a scaled vector from the instance. @@ -490,7 +490,7 @@ public FieldVector3D subtract(final T factor, final FieldVector3D v) { * @return a new vector */ public FieldVector3D subtract(final T factor, final Vector3D v) { - return new FieldVector3D(x.subtract(factor.multiply(v.getX())), + return new FieldVector3D<>(x.subtract(factor.multiply(v.getX())), y.subtract(factor.multiply(v.getY())), z.subtract(factor.multiply(v.getZ()))); } @@ -501,7 +501,7 @@ public FieldVector3D subtract(final T factor, final Vector3D v) { * @return a new vector */ public FieldVector3D subtract(final double factor, final FieldVector3D v) { - return new FieldVector3D(1.0, this, -factor, v); + return new FieldVector3D<>(1.0, this, -factor, v); } /** Subtract a scaled vector from the instance. @@ -510,7 +510,7 @@ public FieldVector3D subtract(final double factor, final FieldVector3D v) * @return a new vector */ public FieldVector3D subtract(final double factor, final Vector3D v) { - return new FieldVector3D(x.subtract(factor * v.getX()), + return new FieldVector3D<>(x.subtract(factor * v.getX()), y.subtract(factor * v.getY()), z.subtract(factor * v.getZ())); } @@ -551,13 +551,13 @@ public FieldVector3D orthogonal() throws MathArithmeticException { if (FastMath.abs(x.getReal()) <= threshold) { final T inverse = y.multiply(y).add(z.multiply(z)).sqrt().reciprocal(); - return new FieldVector3D(inverse.getField().getZero(), inverse.multiply(z), inverse.multiply(y).negate()); + return new FieldVector3D<>(inverse.getField().getZero(), inverse.multiply(z), inverse.multiply(y).negate()); } else if (FastMath.abs(y.getReal()) <= threshold) { final T inverse = x.multiply(x).add(z.multiply(z)).sqrt().reciprocal(); - return new FieldVector3D(inverse.multiply(z).negate(), inverse.getField().getZero(), inverse.multiply(x)); + return new FieldVector3D<>(inverse.multiply(z).negate(), inverse.getField().getZero(), inverse.multiply(x)); } else { final T inverse = x.multiply(x).add(y.multiply(y)).sqrt().reciprocal(); - return new FieldVector3D(inverse.multiply(y), inverse.multiply(x).negate(), inverse.getField().getZero()); + return new FieldVector3D<>(inverse.multiply(y), inverse.multiply(x).negate(), inverse.getField().getZero()); } } @@ -655,7 +655,7 @@ public static > T angle(final Vector3D v1, final F * @return a new vector which is opposite to the instance */ public FieldVector3D negate() { - return new FieldVector3D(x.negate(), y.negate(), z.negate()); + return new FieldVector3D<>(x.negate(), y.negate(), z.negate()); } /** Multiply the instance by a scalar. @@ -663,7 +663,7 @@ public FieldVector3D negate() { * @return a new vector */ public FieldVector3D scalarMultiply(final T a) { - return new FieldVector3D(x.multiply(a), y.multiply(a), z.multiply(a)); + return new FieldVector3D<>(x.multiply(a), y.multiply(a), z.multiply(a)); } /** Multiply the instance by a scalar. @@ -671,7 +671,7 @@ public FieldVector3D scalarMultiply(final T a) { * @return a new vector */ public FieldVector3D scalarMultiply(final double a) { - return new FieldVector3D(x.multiply(a), y.multiply(a), z.multiply(a)); + return new FieldVector3D<>(x.multiply(a), y.multiply(a), z.multiply(a)); } /** @@ -779,7 +779,7 @@ public T dotProduct(final Vector3D v) { * @return the cross product this ^ v as a new Vector3D */ public FieldVector3D crossProduct(final FieldVector3D v) { - return new FieldVector3D(x.linearCombination(y, v.z, z.negate(), v.y), + return new FieldVector3D<>(x.linearCombination(y, v.z, z.negate(), v.y), y.linearCombination(z, v.x, x.negate(), v.z), z.linearCombination(x, v.y, y.negate(), v.x)); } @@ -789,7 +789,7 @@ public FieldVector3D crossProduct(final FieldVector3D v) { * @return the cross product this ^ v as a new Vector3D */ public FieldVector3D crossProduct(final Vector3D v) { - return new FieldVector3D(x.linearCombination(v.getZ(), y, -v.getY(), z), + return new FieldVector3D<>(x.linearCombination(v.getZ(), y, -v.getY(), z), y.linearCombination(v.getX(), z, -v.getZ(), x), z.linearCombination(v.getY(), x, -v.getX(), y)); } @@ -993,7 +993,7 @@ public static > FieldVector3D crossProduct(fina */ public static > FieldVector3D crossProduct(final Vector3D v1, final FieldVector3D v2) { - return new FieldVector3D(v2.x.linearCombination(v1.getY(), v2.z, -v1.getZ(), v2.y), + return new FieldVector3D<>(v2.x.linearCombination(v1.getY(), v2.z, -v1.getZ(), v2.y), v2.y.linearCombination(v1.getZ(), v2.x, -v1.getX(), v2.z), v2.z.linearCombination(v1.getX(), v2.y, -v1.getY(), v2.x)); } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java index a5018134d4..67abdd1999 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java @@ -203,7 +203,7 @@ private void addContribution(final SubHyperplane facet, final boole } // compute the projection of the facet in the outline plane - final ArrayList> edges = new ArrayList>(); + final ArrayList> edges = new ArrayList<>(); for (Vector2D[] loop : vertices) { final boolean closed = loop[0] != null; int previous = closed ? (loop.length - 1) : 1; diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java index 095d6d5c59..b99c9c224d 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java @@ -162,7 +162,7 @@ private static BSPTree buildBoundary(final double xMin, final doubl final double tolerance) { if ((xMin >= xMax - tolerance) || (yMin >= yMax - tolerance) || (zMin >= zMax - tolerance)) { // too thin box, build an empty polygons set - return new BSPTree(Boolean.FALSE); + return new BSPTree<>(Boolean.FALSE); } final Plane pxMin = new Plane(new Vector3D(xMin, 0, 0), Vector3D.MINUS_I, tolerance); final Plane pxMax = new Plane(new Vector3D(xMax, 0, 0), Vector3D.PLUS_I, tolerance); @@ -226,7 +226,7 @@ private static List> buildBoundary(final List> boundary = new ArrayList>(); + final List> boundary = new ArrayList<>(); for (final int[] facet : facets) { diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java index f28a76299b..deef1e9118 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java @@ -37,15 +37,15 @@ public class SphereGenerator implements SupportBallGenerator ballOnSupport(final List support) { if (support.size() < 1) { - return new EnclosingBall(Vector3D.ZERO, Double.NEGATIVE_INFINITY); + return new EnclosingBall<>(Vector3D.ZERO, Double.NEGATIVE_INFINITY); } else { final Vector3D vA = support.get(0); if (support.size() < 2) { - return new EnclosingBall(vA, 0, vA); + return new EnclosingBall<>(vA, 0, vA); } else { final Vector3D vB = support.get(1); if (support.size() < 3) { - return new EnclosingBall(new Vector3D(0.5, vA, 0.5, vB), + return new EnclosingBall<>(new Vector3D(0.5, vA, 0.5, vB), 0.5 * vA.distance(vB), vA, vB); } else { @@ -61,7 +61,7 @@ public EnclosingBall ballOnSupport(final List s p.toSubSpace(vC))); // convert back to 3D - return new EnclosingBall(p.toSpace(disk.getCenter()), + return new EnclosingBall<>(p.toSpace(disk.getCenter()), disk.getRadius(), vA, vB, vC); } else { @@ -118,7 +118,7 @@ public EnclosingBall ballOnSupport(final List s final BigFraction dy = c3[0].subtract(centerY); final BigFraction dz = c4[0].subtract(centerZ); final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy)).add(dz.multiply(dz)); - return new EnclosingBall(new Vector3D(centerX.doubleValue(), + return new EnclosingBall<>(new Vector3D(centerX.doubleValue(), centerY.doubleValue(), centerZ.doubleValue()), FastMath.sqrt(r2.doubleValue()), diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java index ae3dc4a5ad..61499d9e54 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java @@ -85,7 +85,7 @@ public SubLine(final Segment segment) throws MathIllegalArgumentException { public List getSegments() { final List list = remainingRegion.asList(); - final List segments = new ArrayList(list.size()); + final List segments = new ArrayList<>(list.size()); for (final Interval interval : list) { final Vector3D start = line.toSpace((Point) new Vector1D(interval.getInf())); diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java index 89885d4b26..0c89584492 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java @@ -67,11 +67,11 @@ public SplitSubHyperplane split(Hyperplane hyperplane) // the hyperplanes are parallel final double global = otherPlane.getOffset(thisPlane); if (global < -tolerance) { - return new SplitSubHyperplane(null, this); + return new SplitSubHyperplane<>(null, this); } else if (global > tolerance) { - return new SplitSubHyperplane(this, null); + return new SplitSubHyperplane<>(this, null); } else { - return new SplitSubHyperplane(null, null); + return new SplitSubHyperplane<>(null, null); } } @@ -92,15 +92,15 @@ public SplitSubHyperplane split(Hyperplane hyperplane) final BSPTree splitTree = getRemainingRegion().getTree(false).split(l2DMinus); final BSPTree plusTree = getRemainingRegion().isEmpty(splitTree.getPlus()) ? new BSPTree(Boolean.FALSE) : - new BSPTree(l2DPlus, new BSPTree(Boolean.FALSE), + new BSPTree<>(l2DPlus, new BSPTree(Boolean.FALSE), splitTree.getPlus(), null); final BSPTree minusTree = getRemainingRegion().isEmpty(splitTree.getMinus()) ? new BSPTree(Boolean.FALSE) : - new BSPTree(l2DMinus, new BSPTree(Boolean.FALSE), + new BSPTree<>(l2DMinus, new BSPTree(Boolean.FALSE), splitTree.getMinus(), null); - return new SplitSubHyperplane(new SubPlane(thisPlane.copySelf(), new PolygonsSet(plusTree, tolerance)), + return new SplitSubHyperplane<>(new SubPlane(thisPlane.copySelf(), new PolygonsSet(plusTree, tolerance)), new SubPlane(thisPlane.copySelf(), new PolygonsSet(minusTree, tolerance))); } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java index 4cc3546f6b..a19a8768ab 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java @@ -33,15 +33,15 @@ public class DiskGenerator implements SupportBallGenerator ballOnSupport(final List support) { if (support.size() < 1) { - return new EnclosingBall(Vector2D.ZERO, Double.NEGATIVE_INFINITY); + return new EnclosingBall<>(Vector2D.ZERO, Double.NEGATIVE_INFINITY); } else { final Vector2D vA = support.get(0); if (support.size() < 2) { - return new EnclosingBall(vA, 0, vA); + return new EnclosingBall<>(vA, 0, vA); } else { final Vector2D vB = support.get(1); if (support.size() < 3) { - return new EnclosingBall(new Vector2D(0.5, vA, 0.5, vB), + return new EnclosingBall<>(new Vector2D(0.5, vA, 0.5, vB), 0.5 * vA.distance(vB), vA, vB); } else { @@ -86,7 +86,7 @@ public EnclosingBall ballOnSupport(final List s final BigFraction dx = c2[0].subtract(centerX); final BigFraction dy = c3[0].subtract(centerY); final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy)); - return new EnclosingBall(new Vector2D(centerX.doubleValue(), + return new EnclosingBall<>(new Vector2D(centerX.doubleValue(), centerY.doubleValue()), FastMath.sqrt(r2.doubleValue()), vA, vB, vC); diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java index cb3a2be970..a967fb6de5 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java @@ -71,7 +71,7 @@ class NestedLoops { * @since 3.3 */ NestedLoops(final double tolerance) { - this.surrounded = new ArrayList(); + this.surrounded = new ArrayList<>(); this.tolerance = tolerance; } @@ -90,11 +90,11 @@ private NestedLoops(final Vector2D[] loop, final double tolerance) } this.loop = loop; - this.surrounded = new ArrayList(); + this.surrounded = new ArrayList<>(); this.tolerance = tolerance; // build the polygon defined by the loop - final ArrayList> edges = new ArrayList>(); + final ArrayList> edges = new ArrayList<>(); Vector2D current = loop[loop.length - 1]; for (int i = 0; i < loop.length; ++i) { final Vector2D previous = current; @@ -152,7 +152,7 @@ private void add(final NestedLoops node) throws MathIllegalArgumentException { } // we should be separate from the remaining children - RegionFactory factory = new RegionFactory(); + RegionFactory factory = new RegionFactory<>(); for (final NestedLoops child : surrounded) { if (!factory.intersection(node.polygon, child.polygon).isEmpty()) { throw new MathIllegalArgumentException(LocalizedFormats.CROSSING_BOUNDARY_LOOPS); diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java index 6dcf2cd95f..38b94f4938 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java @@ -199,7 +199,7 @@ private static BSPTree verticesToTree(final double hyperplaneThickn final int n = vertices.length; if (n == 0) { // the tree represents the whole space - return new BSPTree(Boolean.TRUE); + return new BSPTree<>(Boolean.TRUE); } // build the vertices @@ -209,7 +209,7 @@ private static BSPTree verticesToTree(final double hyperplaneThickn } // build the edges - List edges = new ArrayList(n); + List edges = new ArrayList<>(n); for (int i = 0; i < n; ++i) { // get the endpoints of the edge @@ -238,7 +238,7 @@ private static BSPTree verticesToTree(final double hyperplaneThickn } // build the tree top-down - final BSPTree tree = new BSPTree(); + final BSPTree tree = new BSPTree<>(); insertEdges(hyperplaneThickness, tree, edges); return tree; @@ -287,8 +287,8 @@ private static void insertEdges(final double hyperplaneThickness, // we have split the node by inserting an edge as a cut sub-hyperplane // distribute the remaining edges in the two sub-trees - final List plusList = new ArrayList(); - final List minusList = new ArrayList(); + final List plusList = new ArrayList<>(); + final List minusList = new ArrayList<>(); for (final Edge edge : edges) { if (edge != inserted) { final double startOffset = inserted.getLine().getOffset((Point) edge.getStart().getLocation()); @@ -365,7 +365,7 @@ private static class Vertex { this.location = location; this.incoming = null; this.outgoing = null; - this.lines = new ArrayList(); + this.lines = new ArrayList<>(); } /** Get Vertex location. @@ -640,7 +640,7 @@ public Vector2D[][] getVertices() { } // create the segment loops - final ArrayList> loops = new ArrayList>(); + final ArrayList> loops = new ArrayList<>(); for (ConnectableSegment s = getUnprocessed(segments); s != null; s = getUnprocessed(segments)) { final List loop = followLoop(s); if (loop != null) { @@ -824,7 +824,7 @@ private ConnectableSegment getUnprocessed(final List segment */ private List followLoop(final ConnectableSegment defining) { - final List loop = new ArrayList(); + final List loop = new ArrayList<>(); loop.add(defining); defining.setProcessed(true); @@ -998,7 +998,7 @@ private static class SegmentsBuilder implements BSPTreeVisitor { */ SegmentsBuilder(final double tolerance) { this.tolerance = tolerance; - this.segments = new ArrayList(); + this.segments = new ArrayList<>(); } /** {@inheritDoc} */ diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java index 4f53e6c91e..eb247605e3 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java @@ -83,7 +83,7 @@ public List getSegments() { final Line line = (Line) getHyperplane(); final List list = ((IntervalsSet) getRemainingRegion()).asList(); - final List segments = new ArrayList(list.size()); + final List segments = new ArrayList<>(list.size()); for (final Interval interval : list) { final Vector2D start = line.toSpace((Point) new Vector1D(interval.getInf())); @@ -168,11 +168,11 @@ public SplitSubHyperplane split(final Hyperplane hyper // the lines are parallel final double global = otherLine.getOffset(thisLine); if (global < -tolerance) { - return new SplitSubHyperplane(null, this); + return new SplitSubHyperplane<>(null, this); } else if (global > tolerance) { - return new SplitSubHyperplane(this, null); + return new SplitSubHyperplane<>(this, null); } else { - return new SplitSubHyperplane(null, null); + return new SplitSubHyperplane<>(null, null); } } @@ -187,13 +187,13 @@ public SplitSubHyperplane split(final Hyperplane hyper final BSPTree splitTree = getRemainingRegion().getTree(false).split(subMinus); final BSPTree plusTree = getRemainingRegion().isEmpty(splitTree.getPlus()) ? new BSPTree(Boolean.FALSE) : - new BSPTree(subPlus, new BSPTree(Boolean.FALSE), + new BSPTree<>(subPlus, new BSPTree(Boolean.FALSE), splitTree.getPlus(), null); final BSPTree minusTree = getRemainingRegion().isEmpty(splitTree.getMinus()) ? new BSPTree(Boolean.FALSE) : - new BSPTree(subMinus, new BSPTree(Boolean.FALSE), + new BSPTree<>(subMinus, new BSPTree(Boolean.FALSE), splitTree.getMinus(), null); - return new SplitSubHyperplane(new SubLine(thisLine.copySelf(), new IntervalsSet(plusTree, tolerance)), + return new SplitSubHyperplane<>(new SubLine(thisLine.copySelf(), new IntervalsSet(plusTree, tolerance)), new SubLine(thisLine.copySelf(), new IntervalsSet(minusTree, tolerance))); } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java index 2388db0509..84be4ac399 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java @@ -84,7 +84,7 @@ public static Collection reducePoints(final Collection point return points; } - final List reducedPoints = new ArrayList(quadrilateral); + final List reducedPoints = new ArrayList<>(quadrilateral); for (final Vector2D p : points) { // check all points if they are within the quadrilateral // in which case they can not be part of the convex hull @@ -103,7 +103,7 @@ public static Collection reducePoints(final Collection point * @return the quadrilateral */ private static List buildQuadrilateral(final Vector2D... points) { - List quadrilateral = new ArrayList(); + List quadrilateral = new ArrayList<>(); for (Vector2D p : points) { if (!quadrilateral.contains(p)) { quadrilateral.add(p); diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java index b973e13c30..7356da12fe 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java @@ -163,7 +163,7 @@ public Region createRegion() throws InsufficientDataException { if (vertices.length < 3) { throw new InsufficientDataException(); } - final RegionFactory factory = new RegionFactory(); + final RegionFactory factory = new RegionFactory<>(); final Segment[] segments = retrieveLineSegments(); final Line[] lineArray = new Line[segments.length]; for (int i = 0; i < segments.length; i++) { diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java index 39caa99350..5746c7f179 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java @@ -77,7 +77,7 @@ public MonotoneChain(final boolean includeCollinearPoints, final double toleranc @Override public Collection findHullVertices(final Collection points) { - final List pointsSortedByXAxis = new ArrayList(points); + final List pointsSortedByXAxis = new ArrayList<>(points); // sort the points in increasing order on the x-axis Collections.sort(pointsSortedByXAxis, new Comparator() { @@ -97,13 +97,13 @@ public int compare(final Vector2D o1, final Vector2D o2) { }); // build lower hull - final List lowerHull = new ArrayList(); + final List lowerHull = new ArrayList<>(); for (Vector2D p : pointsSortedByXAxis) { updateHull(p, lowerHull); } // build upper hull - final List upperHull = new ArrayList(); + final List upperHull = new ArrayList<>(); for (int idx = pointsSortedByXAxis.size() - 1; idx >= 0; idx--) { final Vector2D p = pointsSortedByXAxis.get(idx); updateHull(p, upperHull); @@ -111,7 +111,7 @@ public int compare(final Vector2D o1, final Vector2D o2) { // concatenate the lower and upper hulls // the last point of each list is omitted as it is repeated at the beginning of the other list - final List hullVertices = new ArrayList(lowerHull.size() + upperHull.size() - 2); + final List hullVertices = new ArrayList<>(lowerHull.size() + upperHull.size() - 2); for (int idx = 0; idx < lowerHull.size() - 1; idx++) { hullVertices.add(lowerHull.get(idx)); } diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java index 57d2c648f0..9463bb832b 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java @@ -53,7 +53,7 @@ public abstract class AbstractRegion implement * @param tolerance tolerance below which points are considered identical. */ protected AbstractRegion(final double tolerance) { - this.tree = new BSPTree(Boolean.TRUE); + this.tree = new BSPTree<>(Boolean.TRUE); this.tolerance = tolerance; } @@ -102,14 +102,14 @@ protected AbstractRegion(final Collection> boundary, final doub if (boundary.size() == 0) { // the tree represents the whole space - tree = new BSPTree(Boolean.TRUE); + tree = new BSPTree<>(Boolean.TRUE); } else { // sort the boundary elements in decreasing size order // (we don't want equal size elements to be removed, so // we use a trick to fool the TreeSet) - final TreeSet> ordered = new TreeSet>(new Comparator>() { + final TreeSet> ordered = new TreeSet<>(new Comparator>() { /** {@inheritDoc} */ @Override public int compare(final SubHyperplane o1, final SubHyperplane o2) { @@ -121,7 +121,7 @@ public int compare(final SubHyperplane o1, final SubHyperplane o2) { ordered.addAll(boundary); // build the tree top-down - tree = new BSPTree(); + tree = new BSPTree<>(); insertCuts(tree, ordered); // set up the inside/outside flags @@ -161,7 +161,7 @@ public void visitLeafNode(final BSPTree node) { public AbstractRegion(final Hyperplane[] hyperplanes, final double tolerance) { this.tolerance = tolerance; if ((hyperplanes == null) || (hyperplanes.length == 0)) { - tree = new BSPTree(Boolean.FALSE); + tree = new BSPTree<>(Boolean.FALSE); } else { // use the first hyperplane to build the right class @@ -218,8 +218,8 @@ private void insertCuts(final BSPTree node, final Collection } // distribute the remaining edges in the two sub-trees - final ArrayList> plusList = new ArrayList>(); - final ArrayList> minusList = new ArrayList>(); + final ArrayList> plusList = new ArrayList<>(); + final ArrayList> minusList = new ArrayList<>(); while (iterator.hasNext()) { final SubHyperplane other = iterator.next(); final SubHyperplane.SplitSubHyperplane split = other.split(inserted); @@ -310,7 +310,7 @@ public boolean contains(final Region region) { */ @Override public BoundaryProjection projectToBoundary(final Point point) { - final BoundaryProjector projector = new BoundaryProjector(point); + final BoundaryProjector projector = new BoundaryProjector<>(point); getTree(true).visit(projector); return projector.getProjection(); } @@ -376,7 +376,7 @@ public BSPTree getTree(final boolean includeBoundaryAttributes) { /** {@inheritDoc} */ @Override public double getBoundarySize() { - final BoundarySizeVisitor visitor = new BoundarySizeVisitor(); + final BoundarySizeVisitor visitor = new BoundarySizeVisitor<>(); getTree(true).visit(visitor); return visitor.getSize(); } @@ -485,7 +485,7 @@ private SubHyperplane recurseIntersection(final BSPTree node, final SubHyp public AbstractRegion applyTransform(final Transform transform) { // transform the tree, except for boundary attribute splitters - final Map, BSPTree> map = new HashMap, BSPTree>(); + final Map, BSPTree> map = new HashMap<>(); final BSPTree transformedTree = recurseTransform(getTree(false), transform, map); // set up the boundary attributes splitters @@ -519,7 +519,7 @@ private BSPTree recurseTransform(final BSPTree node, final Transform final BSPTree transformedNode; if (node.getCut() == null) { - transformedNode = new BSPTree(node.getAttribute()); + transformedNode = new BSPTree<>(node.getAttribute()); } else { final SubHyperplane sub = node.getCut(); @@ -531,10 +531,10 @@ private BSPTree recurseTransform(final BSPTree node, final Transform final SubHyperplane tPI = (attribute.getPlusInside() == null) ? null : ((AbstractSubHyperplane) attribute.getPlusInside()).applyTransform(transform); // we start with an empty list of splitters, it will be filled in out of recursion - attribute = new BoundaryAttribute(tPO, tPI, new NodesSet()); + attribute = new BoundaryAttribute<>(tPO, tPI, new NodesSet()); } - transformedNode = new BSPTree(tSub, + transformedNode = new BSPTree<>(tSub, recurseTransform(node.getPlus(), transform, map), recurseTransform(node.getMinus(), transform, map), attribute); diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java index 76c925c576..275269e749 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java @@ -116,7 +116,7 @@ public AbstractSubHyperplane applyTransform(final Transform transfor final Hyperplane tHyperplane = transform.apply(hyperplane); // transform the tree, except for boundary attribute splitters - final Map, BSPTree> map = new HashMap, BSPTree>(); + final Map, BSPTree> map = new HashMap<>(); final BSPTree tTree = recurseTransform(remainingRegion.getTree(false), tHyperplane, transform, map); @@ -153,7 +153,7 @@ private BSPTree recurseTransform(final BSPTree node, final BSPTree transformedNode; if (node.getCut() == null) { - transformedNode = new BSPTree(node.getAttribute()); + transformedNode = new BSPTree<>(node.getAttribute()); } else { @SuppressWarnings("unchecked") @@ -164,10 +164,10 @@ private BSPTree recurseTransform(final BSPTree node, final SubHyperplane tPI = (attribute.getPlusInside() == null) ? null : transform.apply(attribute.getPlusInside(), hyperplane, transformed); // we start with an empty list of splitters, it will be filled in out of recursion - attribute = new BoundaryAttribute(tPO, tPI, new NodesSet()); + attribute = new BoundaryAttribute<>(tPO, tPI, new NodesSet()); } - transformedNode = new BSPTree(transform.apply(node.getCut(), hyperplane, transformed), + transformedNode = new BSPTree<>(transform.apply(node.getCut(), hyperplane, transformed), recurseTransform(node.getPlus(), transformed, transform, map), recurseTransform(node.getMinus(), transformed, transform, map), attribute); diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/BSPTree.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/BSPTree.java index 16548ddbc8..0599d89233 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/BSPTree.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/BSPTree.java @@ -163,9 +163,9 @@ public boolean insertCut(final Hyperplane hyperplane) { } cut = chopped; - plus = new BSPTree(); + plus = new BSPTree<>(); plus.parent = this; - minus = new BSPTree(); + minus = new BSPTree<>(); minus.parent = this; return true; @@ -181,10 +181,10 @@ public boolean insertCut(final Hyperplane hyperplane) { public BSPTree copySelf() { if (cut == null) { - return new BSPTree(attribute); + return new BSPTree<>(attribute); } - return new BSPTree(cut.copySelf(), plus.copySelf(), minus.copySelf(), + return new BSPTree<>(cut.copySelf(), plus.copySelf(), minus.copySelf(), attribute); } @@ -340,7 +340,7 @@ public BSPTree getCell(final Point point, final double tolerance) { * than maxOffset from the point) */ public List> getCloseCuts(final Point point, final double maxOffset) { - final List> close = new ArrayList>(); + final List> close = new ArrayList<>(); recurseCloseCuts(point, maxOffset, close); return close; } @@ -554,7 +554,7 @@ public interface VanishingCutHandler { public BSPTree split(final SubHyperplane sub) { if (cut == null) { - return new BSPTree(sub, copySelf(), new BSPTree(attribute), null); + return new BSPTree<>(sub, copySelf(), new BSPTree(attribute), null); } final Hyperplane cHyperplane = cut.getHyperplane(); @@ -566,12 +566,12 @@ public BSPTree split(final SubHyperplane sub) { final BSPTree split = plus.split(sub); if (cut.split(sHyperplane).getSide() == Side.PLUS) { split.plus = - new BSPTree(cut.copySelf(), split.plus, minus.copySelf(), attribute); + new BSPTree<>(cut.copySelf(), split.plus, minus.copySelf(), attribute); split.plus.condense(); split.plus.parent = split; } else { split.minus = - new BSPTree(cut.copySelf(), split.minus, minus.copySelf(), attribute); + new BSPTree<>(cut.copySelf(), split.minus, minus.copySelf(), attribute); split.minus.condense(); split.minus.parent = split; } @@ -582,12 +582,12 @@ public BSPTree split(final SubHyperplane sub) { final BSPTree split = minus.split(sub); if (cut.split(sHyperplane).getSide() == Side.PLUS) { split.plus = - new BSPTree(cut.copySelf(), plus.copySelf(), split.plus, attribute); + new BSPTree<>(cut.copySelf(), plus.copySelf(), split.plus, attribute); split.plus.condense(); split.plus.parent = split; } else { split.minus = - new BSPTree(cut.copySelf(), plus.copySelf(), split.minus, attribute); + new BSPTree<>(cut.copySelf(), plus.copySelf(), split.minus, attribute); split.minus.condense(); split.minus.parent = split; } @@ -597,7 +597,7 @@ public BSPTree split(final SubHyperplane sub) { { final SubHyperplane.SplitSubHyperplane cutParts = cut.split(sHyperplane); final BSPTree split = - new BSPTree(sub, plus.split(subParts.getPlus()), minus.split(subParts.getMinus()), + new BSPTree<>(sub, plus.split(subParts.getPlus()), minus.split(subParts.getMinus()), null); split.plus.cut = cutParts.getPlus(); split.minus.cut = cutParts.getMinus(); @@ -612,8 +612,8 @@ public BSPTree split(final SubHyperplane sub) { } default : return cHyperplane.sameOrientationAs(sHyperplane) ? - new BSPTree(sub, plus.copySelf(), minus.copySelf(), attribute) : - new BSPTree(sub, minus.copySelf(), plus.copySelf(), attribute); + new BSPTree<>(sub, plus.copySelf(), minus.copySelf(), attribute) : + new BSPTree<>(sub, minus.copySelf(), plus.copySelf(), attribute); } } @@ -710,16 +710,16 @@ public BSPTree pruneAroundConvexCell(final Object cellAttribute, final Object internalAttributes) { // build the current cell leaf - BSPTree tree = new BSPTree(cellAttribute); + BSPTree tree = new BSPTree<>(cellAttribute); // build the pruned tree bottom-up for (BSPTree current = this; current.parent != null; current = current.parent) { final SubHyperplane parentCut = current.parent.cut.copySelf(); - final BSPTree sibling = new BSPTree(otherLeafsAttributes); + final BSPTree sibling = new BSPTree<>(otherLeafsAttributes); if (current == current.parent.plus) { - tree = new BSPTree(parentCut, tree, sibling, internalAttributes); + tree = new BSPTree<>(parentCut, tree, sibling, internalAttributes); } else { - tree = new BSPTree(parentCut, sibling, tree, internalAttributes); + tree = new BSPTree<>(parentCut, sibling, tree, internalAttributes); } } diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java index 2b35eb9a2c..a28623550f 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java @@ -44,18 +44,18 @@ public void visitInternalNode(BSPTree node) { // characterize the cut sub-hyperplane, // first with respect to the plus sub-tree - final Characterization plusChar = new Characterization(node.getPlus(), node.getCut().copySelf()); + final Characterization plusChar = new Characterization<>(node.getPlus(), node.getCut().copySelf()); if (plusChar.touchOutside()) { // plusChar.outsideTouching() corresponds to a subset of the cut sub-hyperplane // known to have outside cells on its plus side, we want to check if parts // of this subset do have inside cells on their minus side - final Characterization minusChar = new Characterization(node.getMinus(), plusChar.outsideTouching()); + final Characterization minusChar = new Characterization<>(node.getMinus(), plusChar.outsideTouching()); if (minusChar.touchInside()) { // this part belongs to the boundary, // it has the outside on its plus side and the inside on its minus side plusOutside = minusChar.insideTouching(); - splitters = new NodesSet(); + splitters = new NodesSet<>(); splitters.addAll(minusChar.getInsideSplitters()); splitters.addAll(plusChar.getOutsideSplitters()); } @@ -65,13 +65,13 @@ public void visitInternalNode(BSPTree node) { // plusChar.insideTouching() corresponds to a subset of the cut sub-hyperplane // known to have inside cells on its plus side, we want to check if parts // of this subset do have outside cells on their minus side - final Characterization minusChar = new Characterization(node.getMinus(), plusChar.insideTouching()); + final Characterization minusChar = new Characterization<>(node.getMinus(), plusChar.insideTouching()); if (minusChar.touchOutside()) { // this part belongs to the boundary, // it has the inside on its plus side and the outside on its minus side plusInside = minusChar.outsideTouching(); if (splitters == null) { - splitters = new NodesSet(); + splitters = new NodesSet<>(); } splitters.addAll(minusChar.getOutsideSplitters()); splitters.addAll(plusChar.getInsideSplitters()); @@ -86,7 +86,7 @@ public void visitInternalNode(BSPTree node) { } // set the boundary attribute at non-leaf nodes - node.setAttribute(new BoundaryAttribute(plusOutside, plusInside, splitters)); + node.setAttribute(new BoundaryAttribute<>(plusOutside, plusInside, splitters)); } diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java index afb88849a1..212f624d0c 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java @@ -130,7 +130,7 @@ public BoundaryProjection getProjection() { // fix offset sign offset = FastMath.copySign(offset, (Boolean) leaf.getAttribute() ? -1 : +1); - return new BoundaryProjection(original, projected, offset); + return new BoundaryProjection<>(original, projected, offset); } @@ -140,7 +140,7 @@ public BoundaryProjection getProjection() { */ private List> boundaryRegions(final BSPTree node) { - final List> regions = new ArrayList>(2); + final List> regions = new ArrayList<>(2); @SuppressWarnings("unchecked") final BoundaryAttribute ba = (BoundaryAttribute) node.getAttribute(); diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/Characterization.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/Characterization.java index 69df9addd2..9eae3588f1 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/Characterization.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/Characterization.java @@ -56,8 +56,8 @@ class Characterization { Characterization(final BSPTree node, final SubHyperplane sub) { outsideTouching = null; insideTouching = null; - outsideSplitters = new NodesSet(); - insideSplitters = new NodesSet(); + outsideSplitters = new NodesSet<>(); + insideSplitters = new NodesSet<>(); characterize(node, sub, new ArrayList>()); } diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java index e7588e0aa3..1d55c5ba65 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java @@ -35,7 +35,7 @@ public class NodesSet implements Iterable> { /** Simple constructor. */ public NodesSet() { - list = new ArrayList>(); + list = new ArrayList<>(); } /** Add a node if not already known. diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java index 6d49939894..3b0e7953fd 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java @@ -176,7 +176,7 @@ public Region getComplement(final Region region) { private BSPTree recurseComplement(final BSPTree node) { // transform the tree, except for boundary attribute splitters - final Map, BSPTree> map = new HashMap, BSPTree>(); + final Map, BSPTree> map = new HashMap<>(); final BSPTree transformedTree = recurseComplement(node, map); // set up the boundary attributes splitters @@ -208,7 +208,7 @@ private BSPTree recurseComplement(final BSPTree node, final BSPTree transformedNode; if (node.getCut() == null) { - transformedNode = new BSPTree(((Boolean) node.getAttribute()) ? Boolean.FALSE : Boolean.TRUE); + transformedNode = new BSPTree<>(((Boolean) node.getAttribute()) ? Boolean.FALSE : Boolean.TRUE); } else { @SuppressWarnings("unchecked") @@ -219,10 +219,10 @@ private BSPTree recurseComplement(final BSPTree node, final SubHyperplane plusInside = (attribute.getPlusOutside() == null) ? null : attribute.getPlusOutside().copySelf(); // we start with an empty list of splitters, it will be filled in out of recursion - attribute = new BoundaryAttribute(plusOutside, plusInside, new NodesSet()); + attribute = new BoundaryAttribute<>(plusOutside, plusInside, new NodesSet()); } - transformedNode = new BSPTree(node.getCut().copySelf(), + transformedNode = new BSPTree<>(node.getCut().copySelf(), recurseComplement(node.getPlus(), map), recurseComplement(node.getMinus(), map), attribute); @@ -330,7 +330,7 @@ public BSPTree fixNode(final BSPTree node) { final BSPTree cell = node.pruneAroundConvexCell(Boolean.TRUE, Boolean.FALSE, null); final Region r = region1.buildNew(cell); final Point p = r.getBarycenter(); - return new BSPTree(region1.checkPoint(p) == Location.INSIDE && + return new BSPTree<>(region1.checkPoint(p) == Location.INSIDE && region2.checkPoint(p) == Location.OUTSIDE); } @@ -376,10 +376,10 @@ private class VanishingToLeaf implements VanishingCutHandler { public BSPTree fixNode(final BSPTree node) { if (node.getPlus().getAttribute().equals(node.getMinus().getAttribute())) { // no ambiguity - return new BSPTree(node.getPlus().getAttribute()); + return new BSPTree<>(node.getPlus().getAttribute()); } else { // ambiguous node - return new BSPTree(inside); + return new BSPTree<>(inside); } } diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java index 1436ce2975..bc1e3905e2 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java @@ -132,7 +132,7 @@ private static BSPTree buildTree(final double lower, final double uppe if (Precision.equals(lower, upper, 0) || (upper - lower) >= MathUtils.TWO_PI) { // the tree must cover the whole circle - return new BSPTree(Boolean.TRUE); + return new BSPTree<>(Boolean.TRUE); } else if (lower > upper) { throw new NumberIsTooLargeException(LocalizedFormats.ENDPOINTS_NOT_AN_INTERVAL, lower, upper, true); @@ -148,9 +148,9 @@ private static BSPTree buildTree(final double lower, final double uppe // simple arc starting after 0 and ending before 2 \pi final SubHyperplane upperCut = new LimitAngle(new S1Point(normalizedUpper), true, tolerance).wholeHyperplane(); - return new BSPTree(lowerCut, + return new BSPTree<>(lowerCut, new BSPTree(Boolean.FALSE), - new BSPTree(upperCut, + new BSPTree<>(upperCut, new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null), @@ -159,8 +159,8 @@ private static BSPTree buildTree(final double lower, final double uppe // arc wrapping around 2 \pi final SubHyperplane upperCut = new LimitAngle(new S1Point(normalizedUpper - MathUtils.TWO_PI), true, tolerance).wholeHyperplane(); - return new BSPTree(lowerCut, - new BSPTree(upperCut, + return new BSPTree<>(lowerCut, + new BSPTree<>(upperCut, new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null), @@ -504,9 +504,9 @@ public BoundaryProjection projectToBoundary(final Point poin final double previousOffset = alpha - previous; final double currentOffset = a[0] - alpha; if (previousOffset < currentOffset) { - return new BoundaryProjection(point, new S1Point(previous), previousOffset); + return new BoundaryProjection<>(point, new S1Point(previous), previousOffset); } else { - return new BoundaryProjection(point, new S1Point(a[0]), currentOffset); + return new BoundaryProjection<>(point, new S1Point(a[0]), currentOffset); } } } else if (alpha <= a[1]) { @@ -515,9 +515,9 @@ public BoundaryProjection projectToBoundary(final Point poin final double offset0 = a[0] - alpha; final double offset1 = alpha - a[1]; if (offset0 < offset1) { - return new BoundaryProjection(point, new S1Point(a[1]), offset1); + return new BoundaryProjection<>(point, new S1Point(a[1]), offset1); } else { - return new BoundaryProjection(point, new S1Point(a[0]), offset0); + return new BoundaryProjection<>(point, new S1Point(a[0]), offset0); } } } @@ -527,7 +527,7 @@ public BoundaryProjection projectToBoundary(final Point poin if (Double.isNaN(previous)) { // there are no points at all in the arcs set - return new BoundaryProjection(point, null, MathUtils.TWO_PI); + return new BoundaryProjection<>(point, null, MathUtils.TWO_PI); } else { @@ -538,18 +538,18 @@ public BoundaryProjection projectToBoundary(final Point poin final double previousOffset = alpha - (previous - MathUtils.TWO_PI); final double currentOffset = first - alpha; if (previousOffset < currentOffset) { - return new BoundaryProjection(point, new S1Point(previous), previousOffset); + return new BoundaryProjection<>(point, new S1Point(previous), previousOffset); } else { - return new BoundaryProjection(point, new S1Point(first), currentOffset); + return new BoundaryProjection<>(point, new S1Point(first), currentOffset); } } else { // the test point is between last and 2\pi final double previousOffset = alpha - previous; final double currentOffset = first + MathUtils.TWO_PI - alpha; if (previousOffset < currentOffset) { - return new BoundaryProjection(point, new S1Point(previous), previousOffset); + return new BoundaryProjection<>(point, new S1Point(previous), previousOffset); } else { - return new BoundaryProjection(point, new S1Point(first), currentOffset); + return new BoundaryProjection<>(point, new S1Point(first), currentOffset); } } @@ -565,7 +565,7 @@ public BoundaryProjection projectToBoundary(final Point poin * @return a new ordered list containing {@link Arc Arc} elements */ public List asList() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (final double[] a : this) { list.add(new Arc(a[0], a[1], getTolerance())); } @@ -724,8 +724,8 @@ public Side side(final Arc arc) { */ public Split split(final Arc arc) { - final List minus = new ArrayList(); - final List plus = new ArrayList(); + final List minus = new ArrayList<>(); + final List plus = new ArrayList<>(); final double reference = FastMath.PI + arc.getInf(); final double arcLength = arc.getSup() - arc.getInf(); @@ -861,7 +861,7 @@ private ArcsSet createSplitPart(final List limits) { } // build the tree by adding all angular sectors - BSPTree tree = new BSPTree(Boolean.FALSE); + BSPTree tree = new BSPTree<>(Boolean.FALSE); for (int i = 0; i < limits.size() - 1; i += 2) { addArcLimit(tree, limits.get(i), true); addArcLimit(tree, limits.get(i + 1), false); diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/SubLimitAngle.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/SubLimitAngle.java index 31f79fd88f..37a6de8b71 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/SubLimitAngle.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/SubLimitAngle.java @@ -59,8 +59,8 @@ protected AbstractSubHyperplane buildNew(final Hyperplane split(final Hyperplane hyperplane) { final double global = hyperplane.getOffset(((LimitAngle) getHyperplane()).getLocation()); return (global < -1.0e-10) ? - new SplitSubHyperplane(null, this) : - new SplitSubHyperplane(this, null); + new SplitSubHyperplane<>(null, this) : + new SplitSubHyperplane<>(this, null); } } diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java index 002d42ce57..86f12c617b 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java @@ -55,8 +55,8 @@ class EdgesBuilder implements BSPTreeVisitor { EdgesBuilder(final BSPTree root, final double tolerance) { this.root = root; this.tolerance = tolerance; - this.edgeToNode = new IdentityHashMap>(); - this.nodeToEdgesList = new IdentityHashMap, List>(); + this.edgeToNode = new IdentityHashMap<>(); + this.nodeToEdgesList = new IdentityHashMap<>(); } /** {@inheritDoc} */ @@ -165,7 +165,7 @@ public List getEdges() throws MathIllegalStateException { previous.setNextEdge(getFollowingEdge(previous)); } - return new ArrayList(edgeToNode.keySet()); + return new ArrayList<>(edgeToNode.keySet()); } diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java index eadc2231e0..b7bcbf03b0 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java @@ -50,7 +50,7 @@ class PropertiesComputer implements BSPTreeVisitor { this.tolerance = tolerance; this.summedArea = 0; this.summedBarycenter = Vector3D.ZERO; - this.convexCellsInsidePoints = new ArrayList(); + this.convexCellsInsidePoints = new ArrayList<>(); } /** {@inheritDoc} */ diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java index e84bf581af..6d4d980a52 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java @@ -59,7 +59,7 @@ public SphericalPolygonsSet(final double tolerance) { * @param tolerance below which points are consider to be identical */ public SphericalPolygonsSet(final Vector3D pole, final double tolerance) { - super(new BSPTree(new Circle(pole, tolerance).wholeHyperplane(), + super(new BSPTree<>(new Circle(pole, tolerance).wholeHyperplane(), new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null), @@ -198,7 +198,7 @@ private static BSPTree verticesToTree(final double hyperplaneThickness final int n = vertices.length; if (n == 0) { // the tree represents the whole space - return new BSPTree(Boolean.TRUE); + return new BSPTree<>(Boolean.TRUE); } // build the vertices @@ -208,7 +208,7 @@ private static BSPTree verticesToTree(final double hyperplaneThickness } // build the edges - List edges = new ArrayList(n); + List edges = new ArrayList<>(n); Vertex end = vArray[n - 1]; for (int i = 0; i < n; ++i) { @@ -241,7 +241,7 @@ private static BSPTree verticesToTree(final double hyperplaneThickness } // build the tree top-down - final BSPTree tree = new BSPTree(); + final BSPTree tree = new BSPTree<>(); insertEdges(hyperplaneThickness, tree, edges); return tree; @@ -284,8 +284,8 @@ private static void insertEdges(final double hyperplaneThickness, // we have split the node by inserting an edge as a cut sub-hyperplane // distribute the remaining edges in the two sub-trees - final List outsideList = new ArrayList(); - final List insideList = new ArrayList(); + final List outsideList = new ArrayList<>(); + final List insideList = new ArrayList<>(); for (final Edge edge : edges) { if (edge != inserted) { edge.split(inserted.getCircle(), outsideList, insideList); @@ -384,7 +384,7 @@ public List getBoundaryLoops() throws MathIllegalStateException { // convert the list of all edges into a list of start vertices - loops = new ArrayList(); + loops = new ArrayList<>(); while (!edges.isEmpty()) { // this is an edge belonging to a new loop, store it @@ -468,10 +468,10 @@ public EnclosingBall getEnclosingCap() { // handle special cases first if (isEmpty()) { - return new EnclosingBall(S2Point.PLUS_K, Double.NEGATIVE_INFINITY); + return new EnclosingBall<>(S2Point.PLUS_K, Double.NEGATIVE_INFINITY); } if (isFull()) { - return new EnclosingBall(S2Point.PLUS_K, Double.POSITIVE_INFINITY); + return new EnclosingBall<>(S2Point.PLUS_K, Double.POSITIVE_INFINITY); } // as the polygons is neither empty nor full, it has some boundaries and cut hyperplanes @@ -479,13 +479,13 @@ public EnclosingBall getEnclosingCap() { if (isEmpty(root.getMinus()) && isFull(root.getPlus())) { // the polygon covers an hemisphere, and its boundary is one 2Ï€ long edge final Circle circle = (Circle) root.getCut().getHyperplane(); - return new EnclosingBall(new S2Point(circle.getPole()).negate(), + return new EnclosingBall<>(new S2Point(circle.getPole()).negate(), 0.5 * FastMath.PI); } if (isFull(root.getMinus()) && isEmpty(root.getPlus())) { // the polygon covers an hemisphere, and its boundary is one 2Ï€ long edge final Circle circle = (Circle) root.getCut().getHyperplane(); - return new EnclosingBall(new S2Point(circle.getPole()), + return new EnclosingBall<>(new S2Point(circle.getPole()), 0.5 * FastMath.PI); } @@ -505,7 +505,7 @@ public EnclosingBall getEnclosingCap() { // find the smallest enclosing 3D sphere final SphereGenerator generator = new SphereGenerator(); final WelzlEncloser encloser = - new WelzlEncloser(getTolerance(), generator); + new WelzlEncloser<>(getTolerance(), generator); EnclosingBall enclosing3D = encloser.enclose(points); final Vector3D[] support3D = enclosing3D.getSupport(); @@ -516,12 +516,12 @@ public EnclosingBall getEnclosingCap() { // the 3D sphere is centered on the unit sphere and covers it // fall back to a crude approximation, based only on outside convex cells EnclosingBall enclosingS2 = - new EnclosingBall(S2Point.PLUS_K, Double.POSITIVE_INFINITY); + new EnclosingBall<>(S2Point.PLUS_K, Double.POSITIVE_INFINITY); for (Vector3D outsidePoint : getOutsidePoints()) { final S2Point outsideS2 = new S2Point(outsidePoint); final BoundaryProjection projection = projectToBoundary(outsideS2); if (FastMath.PI - projection.getOffset() < enclosingS2.getRadius()) { - enclosingS2 = new EnclosingBall(outsideS2.negate(), + enclosingS2 = new EnclosingBall<>(outsideS2.negate(), FastMath.PI - projection.getOffset(), (S2Point) projection.getProjected()); } @@ -534,7 +534,7 @@ public EnclosingBall getEnclosingCap() { } final EnclosingBall enclosingS2 = - new EnclosingBall(new S2Point(enclosing3D.getCenter()), + new EnclosingBall<>(new S2Point(enclosing3D.getCenter()), FastMath.acos((1 + h * h - r * r) / (2 * h)), support); diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java index 837c953f47..ba74b52b46 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java @@ -56,14 +56,14 @@ public SplitSubHyperplane split(final Hyperplane hyperplane) if (angle < thisCircle.getTolerance() || angle > FastMath.PI - thisCircle.getTolerance()) { // the two circles are aligned or opposite - return new SplitSubHyperplane(null, null); + return new SplitSubHyperplane<>(null, null); } else { // the two circles intersect each other final Arc arc = thisCircle.getInsideArc(otherCircle); final ArcsSet.Split split = ((ArcsSet) getRemainingRegion()).split(arc); final ArcsSet plus = split.getPlus(); final ArcsSet minus = split.getMinus(); - return new SplitSubHyperplane(plus == null ? null : new SubCircle(thisCircle.copySelf(), plus), + return new SplitSubHyperplane<>(plus == null ? null : new SubCircle(thisCircle.copySelf(), plus), minus == null ? null : new SubCircle(thisCircle.copySelf(), minus)); } diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Vertex.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Vertex.java index d3102c15aa..a8b1db2887 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Vertex.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Vertex.java @@ -45,7 +45,7 @@ public class Vertex { this.location = location; this.incoming = null; this.outgoing = null; - this.circles = new ArrayList(); + this.circles = new ArrayList<>(); } /** Get Vertex location. diff --git a/src/main/java/org/apache/commons/math4/linear/AbstractFieldMatrix.java b/src/main/java/org/apache/commons/math4/linear/AbstractFieldMatrix.java index 23c496934f..a182e49a90 100644 --- a/src/main/java/org/apache/commons/math4/linear/AbstractFieldMatrix.java +++ b/src/main/java/org/apache/commons/math4/linear/AbstractFieldMatrix.java @@ -270,7 +270,7 @@ public FieldMatrix power(final int p) throws NonSquareMatrixException, final char[] binaryRepresentation = Integer.toBinaryString(power) .toCharArray(); - final ArrayList nonZeroPositions = new ArrayList(); + final ArrayList nonZeroPositions = new ArrayList<>(); for (int i = 0; i < binaryRepresentation.length; ++i) { if (binaryRepresentation[i] == '1') { @@ -279,7 +279,7 @@ public FieldMatrix power(final int p) throws NonSquareMatrixException, } } - ArrayList> results = new ArrayList>( + ArrayList> results = new ArrayList<>( binaryRepresentation.length); results.add(0, this.copy()); @@ -537,7 +537,7 @@ public void setColumnMatrix(final int column, final FieldMatrix matrix) @Override public FieldVector getRowVector(final int row) throws OutOfRangeException { - return new ArrayFieldVector(field, getRow(row), false); + return new ArrayFieldVector<>(field, getRow(row), false); } /** {@inheritDoc} */ @@ -560,7 +560,7 @@ public void setRowVector(final int row, final FieldVector vector) @Override public FieldVector getColumnVector(final int column) throws OutOfRangeException { - return new ArrayFieldVector(field, getColumn(column), false); + return new ArrayFieldVector<>(field, getColumn(column), false); } /** {@inheritDoc} */ @@ -726,7 +726,7 @@ public T[] operate(final T[] v) throws DimensionMismatchException { public FieldVector operate(final FieldVector v) throws DimensionMismatchException { try { - return new ArrayFieldVector(field, operate(((ArrayFieldVector) v).getDataRef()), false); + return new ArrayFieldVector<>(field, operate(((ArrayFieldVector) v).getDataRef()), false); } catch (ClassCastException cce) { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); @@ -743,7 +743,7 @@ public FieldVector operate(final FieldVector v) out[row] = sum; } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } } @@ -774,7 +774,7 @@ public T[] preMultiply(final T[] v) throws DimensionMismatchException { public FieldVector preMultiply(final FieldVector v) throws DimensionMismatchException { try { - return new ArrayFieldVector(field, preMultiply(((ArrayFieldVector) v).getDataRef()), false); + return new ArrayFieldVector<>(field, preMultiply(((ArrayFieldVector) v).getDataRef()), false); } catch (ClassCastException cce) { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); @@ -791,7 +791,7 @@ public FieldVector preMultiply(final FieldVector v) out[col] = sum; } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } } diff --git a/src/main/java/org/apache/commons/math4/linear/AbstractRealMatrix.java b/src/main/java/org/apache/commons/math4/linear/AbstractRealMatrix.java index 4dcf64070e..76ef1cb89f 100644 --- a/src/main/java/org/apache/commons/math4/linear/AbstractRealMatrix.java +++ b/src/main/java/org/apache/commons/math4/linear/AbstractRealMatrix.java @@ -198,7 +198,7 @@ public RealMatrix power(final int p) */ final char[] binaryRepresentation = Integer.toBinaryString(power).toCharArray(); - final ArrayList nonZeroPositions = new ArrayList(); + final ArrayList nonZeroPositions = new ArrayList<>(); int maxI = -1; for (int i = 0; i < binaryRepresentation.length; ++i) { diff --git a/src/main/java/org/apache/commons/math4/linear/Array2DRowFieldMatrix.java b/src/main/java/org/apache/commons/math4/linear/Array2DRowFieldMatrix.java index 70d789486e..7a70931908 100644 --- a/src/main/java/org/apache/commons/math4/linear/Array2DRowFieldMatrix.java +++ b/src/main/java/org/apache/commons/math4/linear/Array2DRowFieldMatrix.java @@ -208,13 +208,13 @@ public Array2DRowFieldMatrix(final Field field, final T[] v) { public FieldMatrix createMatrix(final int rowDimension, final int columnDimension) throws NotStrictlyPositiveException { - return new Array2DRowFieldMatrix(getField(), rowDimension, columnDimension); + return new Array2DRowFieldMatrix<>(getField(), rowDimension, columnDimension); } /** {@inheritDoc} */ @Override public FieldMatrix copy() { - return new Array2DRowFieldMatrix(getField(), copyOut(), false); + return new Array2DRowFieldMatrix<>(getField(), copyOut(), false); } /** @@ -242,7 +242,7 @@ public Array2DRowFieldMatrix add(final Array2DRowFieldMatrix m) } } - return new Array2DRowFieldMatrix(getField(), outData, false); + return new Array2DRowFieldMatrix<>(getField(), outData, false); } /** @@ -270,7 +270,7 @@ public Array2DRowFieldMatrix subtract(final Array2DRowFieldMatrix m) } } - return new Array2DRowFieldMatrix(getField(), outData, false); + return new Array2DRowFieldMatrix<>(getField(), outData, false); } @@ -303,7 +303,7 @@ public Array2DRowFieldMatrix multiply(final Array2DRowFieldMatrix m) } } - return new Array2DRowFieldMatrix(getField(), outData, false); + return new Array2DRowFieldMatrix<>(getField(), outData, false); } diff --git a/src/main/java/org/apache/commons/math4/linear/ArrayFieldVector.java b/src/main/java/org/apache/commons/math4/linear/ArrayFieldVector.java index b2240e6c91..b468bb7d17 100644 --- a/src/main/java/org/apache/commons/math4/linear/ArrayFieldVector.java +++ b/src/main/java/org/apache/commons/math4/linear/ArrayFieldVector.java @@ -388,7 +388,7 @@ public Field getField() { /** {@inheritDoc} */ @Override public FieldVector copy() { - return new ArrayFieldVector(this, true); + return new ArrayFieldVector<>(this, true); } /** {@inheritDoc} */ @@ -403,7 +403,7 @@ public FieldVector add(FieldVector v) for (int i = 0; i < data.length; i++) { out[i] = data[i].add(v.getEntry(i)); } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } } @@ -421,7 +421,7 @@ public ArrayFieldVector add(ArrayFieldVector v) for (int i = 0; i < data.length; i++) { out[i] = data[i].add(v.data[i]); } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } /** {@inheritDoc} */ @@ -436,7 +436,7 @@ public FieldVector subtract(FieldVector v) for (int i = 0; i < data.length; i++) { out[i] = data[i].subtract(v.getEntry(i)); } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } } @@ -454,7 +454,7 @@ public ArrayFieldVector subtract(ArrayFieldVector v) for (int i = 0; i < data.length; i++) { out[i] = data[i].subtract(v.data[i]); } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } /** {@inheritDoc} */ @@ -464,7 +464,7 @@ public FieldVector mapAdd(T d) throws NullArgumentException { for (int i = 0; i < data.length; i++) { out[i] = data[i].add(d); } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } /** {@inheritDoc} */ @@ -483,7 +483,7 @@ public FieldVector mapSubtract(T d) throws NullArgumentException { for (int i = 0; i < data.length; i++) { out[i] = data[i].subtract(d); } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } /** {@inheritDoc} */ @@ -502,7 +502,7 @@ public FieldVector mapMultiply(T d) throws NullArgumentException { for (int i = 0; i < data.length; i++) { out[i] = data[i].multiply(d); } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } /** {@inheritDoc} */ @@ -523,7 +523,7 @@ public FieldVector mapDivide(T d) for (int i = 0; i < data.length; i++) { out[i] = data[i].divide(d); } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } /** {@inheritDoc} */ @@ -549,7 +549,7 @@ public FieldVector mapInv() throws MathArithmeticException { throw new MathArithmeticException(LocalizedFormats.INDEX, i); } } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } /** {@inheritDoc} */ @@ -578,7 +578,7 @@ public FieldVector ebeMultiply(FieldVector v) for (int i = 0; i < data.length; i++) { out[i] = data[i].multiply(v.getEntry(i)); } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } } @@ -596,7 +596,7 @@ public ArrayFieldVector ebeMultiply(ArrayFieldVector v) for (int i = 0; i < data.length; i++) { out[i] = data[i].multiply(v.data[i]); } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } /** {@inheritDoc} */ @@ -615,7 +615,7 @@ public FieldVector ebeDivide(FieldVector v) throw new MathArithmeticException(LocalizedFormats.INDEX, i); } } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } } @@ -638,7 +638,7 @@ public ArrayFieldVector ebeDivide(ArrayFieldVector v) throw new MathArithmeticException(LocalizedFormats.INDEX, i); } } - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } /** @@ -710,7 +710,7 @@ public FieldMatrix outerProduct(FieldVector v) { } catch (ClassCastException cce) { final int m = data.length; final int n = v.getDimension(); - final FieldMatrix out = new Array2DRowFieldMatrix(field, m, n); + final FieldMatrix out = new Array2DRowFieldMatrix<>(field, m, n); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { out.setEntry(i, j, data[i].multiply(v.getEntry(j))); @@ -728,7 +728,7 @@ public FieldMatrix outerProduct(FieldVector v) { public FieldMatrix outerProduct(ArrayFieldVector v) { final int m = data.length; final int n = v.data.length; - final FieldMatrix out = new Array2DRowFieldMatrix(field, m, n); + final FieldMatrix out = new Array2DRowFieldMatrix<>(field, m, n); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { out.setEntry(i, j, data[i].multiply(v.data[j])); @@ -755,7 +755,7 @@ public FieldVector append(FieldVector v) { try { return append((ArrayFieldVector) v); } catch (ClassCastException cce) { - return new ArrayFieldVector(this,new ArrayFieldVector(v)); + return new ArrayFieldVector<>(this,new ArrayFieldVector<>(v)); } } @@ -765,7 +765,7 @@ public FieldVector append(FieldVector v) { * @return a new vector */ public ArrayFieldVector append(ArrayFieldVector v) { - return new ArrayFieldVector(this, v); + return new ArrayFieldVector<>(this, v); } /** {@inheritDoc} */ @@ -774,7 +774,7 @@ public FieldVector append(T in) { final T[] out = MathArrays.buildArray(field, data.length + 1); System.arraycopy(data, 0, out, 0, data.length); out[data.length] = in; - return new ArrayFieldVector(field, out, false); + return new ArrayFieldVector<>(field, out, false); } /** {@inheritDoc} */ @@ -784,7 +784,7 @@ public FieldVector getSubVector(int index, int n) if (n < 0) { throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n); } - ArrayFieldVector out = new ArrayFieldVector(field, n); + ArrayFieldVector out = new ArrayFieldVector<>(field, n); try { System.arraycopy(data, index, out.data, 0, n); } catch (IndexOutOfBoundsException e) { diff --git a/src/main/java/org/apache/commons/math4/linear/BlockFieldMatrix.java b/src/main/java/org/apache/commons/math4/linear/BlockFieldMatrix.java index e5294f2c65..74c6fe8d30 100644 --- a/src/main/java/org/apache/commons/math4/linear/BlockFieldMatrix.java +++ b/src/main/java/org/apache/commons/math4/linear/BlockFieldMatrix.java @@ -294,7 +294,7 @@ public static > T[][] createBlocksLayout(final Field createMatrix(final int rowDimension, final int columnDimension) throws NotStrictlyPositiveException { - return new BlockFieldMatrix(getField(), rowDimension, + return new BlockFieldMatrix<>(getField(), rowDimension, columnDimension); } @@ -303,7 +303,7 @@ public FieldMatrix createMatrix(final int rowDimension, public FieldMatrix copy() { // create an empty matrix - BlockFieldMatrix copied = new BlockFieldMatrix(getField(), rows, columns); + BlockFieldMatrix copied = new BlockFieldMatrix<>(getField(), rows, columns); // copy the blocks for (int i = 0; i < blocks.length; ++i) { @@ -324,7 +324,7 @@ public FieldMatrix add(final FieldMatrix m) // safety check checkAdditionCompatible(m); - final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, columns); + final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, columns); // perform addition block-wise, to ensure good cache behavior int blockIndex = 0; @@ -370,7 +370,7 @@ public BlockFieldMatrix add(final BlockFieldMatrix m) // safety check checkAdditionCompatible(m); - final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, columns); + final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, columns); // perform addition block-wise, to ensure good cache behavior for (int blockIndex = 0; blockIndex < out.blocks.length; ++blockIndex) { @@ -396,7 +396,7 @@ public FieldMatrix subtract(final FieldMatrix m) // safety check checkSubtractionCompatible(m); - final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, columns); + final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, columns); // perform subtraction block-wise, to ensure good cache behavior int blockIndex = 0; @@ -440,7 +440,7 @@ public BlockFieldMatrix subtract(final BlockFieldMatrix m) throws MatrixDi // safety check checkSubtractionCompatible(m); - final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, columns); + final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, columns); // perform subtraction block-wise, to ensure good cache behavior for (int blockIndex = 0; blockIndex < out.blocks.length; ++blockIndex) { @@ -458,7 +458,7 @@ public BlockFieldMatrix subtract(final BlockFieldMatrix m) throws MatrixDi /** {@inheritDoc} */ @Override public FieldMatrix scalarAdd(final T d) { - final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, columns); + final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, columns); // perform subtraction block-wise, to ensure good cache behavior for (int blockIndex = 0; blockIndex < out.blocks.length; ++blockIndex) { @@ -476,7 +476,7 @@ public FieldMatrix scalarAdd(final T d) { @Override public FieldMatrix scalarMultiply(final T d) { - final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, columns); + final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, columns); // perform subtraction block-wise, to ensure good cache behavior for (int blockIndex = 0; blockIndex < out.blocks.length; ++blockIndex) { @@ -501,7 +501,7 @@ public FieldMatrix multiply(final FieldMatrix m) // safety check checkMultiplicationCompatible(m); - final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, m.getColumnDimension()); + final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, m.getColumnDimension()); final T zero = getField().getZero(); // perform multiplication block-wise, to ensure good cache behavior @@ -564,7 +564,7 @@ public BlockFieldMatrix multiply(BlockFieldMatrix m) // safety check checkMultiplicationCompatible(m); - final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, m.columns); + final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, m.columns); final T zero = getField().getZero(); // perform multiplication block-wise, to ensure good cache behavior @@ -663,7 +663,7 @@ public FieldMatrix getSubMatrix(final int startRow, final int endRow, // create the output matrix final BlockFieldMatrix out = - new BlockFieldMatrix(getField(), endRow - startRow + 1, endColumn - startColumn + 1); + new BlockFieldMatrix<>(getField(), endRow - startRow + 1, endColumn - startColumn + 1); // compute blocks shifts final int blockStartRow = startRow / BLOCK_SIZE; @@ -836,7 +836,7 @@ public void setSubMatrix(final T[][] subMatrix, final int row, public FieldMatrix getRowMatrix(final int row) throws OutOfRangeException { checkRowIndex(row); - final BlockFieldMatrix out = new BlockFieldMatrix(getField(), 1, columns); + final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), 1, columns); // perform copy block-wise, to ensure good cache behavior final int iBlock = row / BLOCK_SIZE; @@ -922,7 +922,7 @@ public void setRowMatrix(final int row, final BlockFieldMatrix matrix) public FieldMatrix getColumnMatrix(final int column) throws OutOfRangeException { checkColumnIndex(column); - final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, 1); + final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, 1); // perform copy block-wise, to ensure good cache behavior final int jBlock = column / BLOCK_SIZE; @@ -1017,7 +1017,7 @@ public FieldVector getRowVector(final int row) outIndex += jWidth; } - return new ArrayFieldVector(getField(), outData, false); + return new ArrayFieldVector<>(getField(), outData, false); } /** {@inheritDoc} */ @@ -1051,7 +1051,7 @@ public FieldVector getColumnVector(final int column) } } - return new ArrayFieldVector(getField(), outData, false); + return new ArrayFieldVector<>(getField(), outData, false); } /** {@inheritDoc} */ @@ -1220,7 +1220,7 @@ public void multiplyEntry(final int row, final int column, final T factor) public FieldMatrix transpose() { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); - final BlockFieldMatrix out = new BlockFieldMatrix(getField(), nCols, nRows); + final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), nCols, nRows); // perform transpose block-wise, to ensure good cache behavior int blockIndex = 0; diff --git a/src/main/java/org/apache/commons/math4/linear/FieldLUDecomposition.java b/src/main/java/org/apache/commons/math4/linear/FieldLUDecomposition.java index 1e4c47317f..e733f42bf3 100644 --- a/src/main/java/org/apache/commons/math4/linear/FieldLUDecomposition.java +++ b/src/main/java/org/apache/commons/math4/linear/FieldLUDecomposition.java @@ -171,7 +171,7 @@ public FieldLUDecomposition(FieldMatrix matrix) { public FieldMatrix getL() { if ((cachedL == null) && !singular) { final int m = pivot.length; - cachedL = new Array2DRowFieldMatrix(field, m, m); + cachedL = new Array2DRowFieldMatrix<>(field, m, m); for (int i = 0; i < m; ++i) { final T[] luI = lu[i]; for (int j = 0; j < i; ++j) { @@ -191,7 +191,7 @@ public FieldMatrix getL() { public FieldMatrix getU() { if ((cachedU == null) && !singular) { final int m = pivot.length; - cachedU = new Array2DRowFieldMatrix(field, m, m); + cachedU = new Array2DRowFieldMatrix<>(field, m, m); for (int i = 0; i < m; ++i) { final T[] luI = lu[i]; for (int j = i; j < m; ++j) { @@ -214,7 +214,7 @@ public FieldMatrix getU() { public FieldMatrix getP() { if ((cachedP == null) && !singular) { final int m = pivot.length; - cachedP = new Array2DRowFieldMatrix(field, m, m); + cachedP = new Array2DRowFieldMatrix<>(field, m, m); for (int i = 0; i < m; ++i) { cachedP.setEntry(i, pivot[i], field.getOne()); } @@ -253,7 +253,7 @@ public T getDeterminant() { * @return a solver */ public FieldDecompositionSolver getSolver() { - return new Solver(field, lu, pivot, singular); + return new Solver<>(field, lu, pivot, singular); } /** Specialized solver. @@ -332,7 +332,7 @@ public FieldVector solve(FieldVector b) { } } - return new ArrayFieldVector(field, bp, false); + return new ArrayFieldVector<>(field, bp, false); } } @@ -377,7 +377,7 @@ public ArrayFieldVector solve(ArrayFieldVector b) { } } - return new ArrayFieldVector(bp, false); + return new ArrayFieldVector<>(bp, false); } /** {@inheritDoc} */ @@ -431,7 +431,7 @@ public FieldMatrix solve(FieldMatrix b) { } } - return new Array2DRowFieldMatrix(field, bp, false); + return new Array2DRowFieldMatrix<>(field, bp, false); } @@ -440,7 +440,7 @@ public FieldMatrix solve(FieldMatrix b) { public FieldMatrix getInverse() { final int m = pivot.length; final T one = field.getOne(); - FieldMatrix identity = new Array2DRowFieldMatrix(field, m, m); + FieldMatrix identity = new Array2DRowFieldMatrix<>(field, m, m); for (int i = 0; i < m; ++i) { identity.setEntry(i, i, one); } diff --git a/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java b/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java index 19ff724fae..a18c015043 100644 --- a/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java +++ b/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java @@ -101,7 +101,7 @@ public static > FieldMatrix createFieldMatrix(final final int rows, final int columns) { return (rows * columns <= 4096) ? - new Array2DRowFieldMatrix(field, rows, columns) : new BlockFieldMatrix(field, rows, columns); + new Array2DRowFieldMatrix<>(field, rows, columns) : new BlockFieldMatrix<>(field, rows, columns); } /** @@ -161,7 +161,7 @@ public static > FieldMatrix createFieldMatrix(T[][] throw new NullArgumentException(); } return (data.length * data[0].length <= 4096) ? - new Array2DRowFieldMatrix(data) : new BlockFieldMatrix(data); + new Array2DRowFieldMatrix<>(data) : new BlockFieldMatrix<>(data); } /** @@ -200,7 +200,7 @@ public static RealMatrix createRealIdentityMatrix(int dimension) { Arrays.fill(dRow, zero); dRow[row] = one; } - return new Array2DRowFieldMatrix(field, d, false); + return new Array2DRowFieldMatrix<>(field, d, false); } /** @@ -272,7 +272,7 @@ public static > FieldVector createFieldVector(final if (data.length == 0) { throw new ZeroException(LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT); } - return new ArrayFieldVector(data[0].getField(), data, true); + return new ArrayFieldVector<>(data[0].getField(), data, true); } /** diff --git a/src/main/java/org/apache/commons/math4/linear/RealMatrixFormat.java b/src/main/java/org/apache/commons/math4/linear/RealMatrixFormat.java index 8601490961..34c0b0e9c8 100644 --- a/src/main/java/org/apache/commons/math4/linear/RealMatrixFormat.java +++ b/src/main/java/org/apache/commons/math4/linear/RealMatrixFormat.java @@ -315,8 +315,8 @@ public RealMatrix parse(String source, ParsePosition pos) { } // parse components - List> matrix = new ArrayList>(); - List rowComponents = new ArrayList(); + List> matrix = new ArrayList<>(); + List rowComponents = new ArrayList<>(); for (boolean loop = true; loop;){ if (!rowComponents.isEmpty()) { @@ -329,7 +329,7 @@ public RealMatrix parse(String source, ParsePosition pos) { CompositeFormat.parseAndIgnoreWhitespace(source, pos); if (CompositeFormat.parseFixedstring(source, trimmedRowSeparator, pos)) { matrix.add(rowComponents); - rowComponents = new ArrayList(); + rowComponents = new ArrayList<>(); continue; } else { loop = false; diff --git a/src/main/java/org/apache/commons/math4/linear/RealVectorFormat.java b/src/main/java/org/apache/commons/math4/linear/RealVectorFormat.java index 49de55dd7e..2ffb378650 100644 --- a/src/main/java/org/apache/commons/math4/linear/RealVectorFormat.java +++ b/src/main/java/org/apache/commons/math4/linear/RealVectorFormat.java @@ -247,7 +247,7 @@ public ArrayRealVector parse(String source, ParsePosition pos) { } // parse components - List components = new ArrayList(); + List components = new ArrayList<>(); for (boolean loop = true; loop;){ if (!components.isEmpty()) { diff --git a/src/main/java/org/apache/commons/math4/linear/SparseFieldMatrix.java b/src/main/java/org/apache/commons/math4/linear/SparseFieldMatrix.java index b48970c21c..70d5999088 100644 --- a/src/main/java/org/apache/commons/math4/linear/SparseFieldMatrix.java +++ b/src/main/java/org/apache/commons/math4/linear/SparseFieldMatrix.java @@ -51,7 +51,7 @@ public SparseFieldMatrix(final Field field) { super(field); rows = 0; columns= 0; - entries = new OpenIntToFieldHashMap(field); + entries = new OpenIntToFieldHashMap<>(field); } /** @@ -69,7 +69,7 @@ public SparseFieldMatrix(final Field field, super(field, rowDimension, columnDimension); this.rows = rowDimension; this.columns = columnDimension; - entries = new OpenIntToFieldHashMap(field); + entries = new OpenIntToFieldHashMap<>(field); } /** @@ -81,7 +81,7 @@ public SparseFieldMatrix(SparseFieldMatrix other) { super(other.getField(), other.getRowDimension(), other.getColumnDimension()); rows = other.getRowDimension(); columns = other.getColumnDimension(); - entries = new OpenIntToFieldHashMap(other.entries); + entries = new OpenIntToFieldHashMap<>(other.entries); } /** @@ -93,7 +93,7 @@ public SparseFieldMatrix(FieldMatrix other){ super(other.getField(), other.getRowDimension(), other.getColumnDimension()); rows = other.getRowDimension(); columns = other.getColumnDimension(); - entries = new OpenIntToFieldHashMap(getField()); + entries = new OpenIntToFieldHashMap<>(getField()); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { setEntry(i, j, other.getEntry(i, j)); @@ -118,13 +118,13 @@ public void addToEntry(int row, int column, T increment) { /** {@inheritDoc} */ @Override public FieldMatrix copy() { - return new SparseFieldMatrix(this); + return new SparseFieldMatrix<>(this); } /** {@inheritDoc} */ @Override public FieldMatrix createMatrix(int rowDimension, int columnDimension) { - return new SparseFieldMatrix(getField(), rowDimension, columnDimension); + return new SparseFieldMatrix<>(getField(), rowDimension, columnDimension); } /** {@inheritDoc} */ diff --git a/src/main/java/org/apache/commons/math4/linear/SparseFieldVector.java b/src/main/java/org/apache/commons/math4/linear/SparseFieldVector.java index 7065f10900..1bf041dc62 100644 --- a/src/main/java/org/apache/commons/math4/linear/SparseFieldVector.java +++ b/src/main/java/org/apache/commons/math4/linear/SparseFieldVector.java @@ -77,7 +77,7 @@ public SparseFieldVector(Field field) { public SparseFieldVector(Field field, int dimension) { this.field = field; virtualSize = dimension; - entries = new OpenIntToFieldHashMap(field); + entries = new OpenIntToFieldHashMap<>(field); } /** @@ -89,7 +89,7 @@ public SparseFieldVector(Field field, int dimension) { protected SparseFieldVector(SparseFieldVector v, int resize) { field = v.field; virtualSize = v.getDimension() + resize; - entries = new OpenIntToFieldHashMap(v.entries); + entries = new OpenIntToFieldHashMap<>(v.entries); } @@ -103,7 +103,7 @@ protected SparseFieldVector(SparseFieldVector v, int resize) { public SparseFieldVector(Field field, int dimension, int expectedSize) { this.field = field; virtualSize = dimension; - entries = new OpenIntToFieldHashMap(field,expectedSize); + entries = new OpenIntToFieldHashMap<>(field,expectedSize); } /** @@ -118,7 +118,7 @@ public SparseFieldVector(Field field, T[] values) throws NullArgumentExceptio MathUtils.checkNotNull(values); this.field = field; virtualSize = values.length; - entries = new OpenIntToFieldHashMap(field); + entries = new OpenIntToFieldHashMap<>(field); for (int key = 0; key < values.length; key++) { T value = values[key]; entries.put(key, value); @@ -133,7 +133,7 @@ public SparseFieldVector(Field field, T[] values) throws NullArgumentExceptio public SparseFieldVector(SparseFieldVector v) { field = v.field; virtualSize = v.getDimension(); - entries = new OpenIntToFieldHashMap(v.getEntries()); + entries = new OpenIntToFieldHashMap<>(v.getEntries()); } /** @@ -179,7 +179,7 @@ public FieldVector add(SparseFieldVector v) * @return a new vector. */ public FieldVector append(SparseFieldVector v) { - SparseFieldVector res = new SparseFieldVector(this, v.getDimension()); + SparseFieldVector res = new SparseFieldVector<>(this, v.getDimension()); OpenIntToFieldHashMap.Iterator iter = v.entries.iterator(); while (iter.hasNext()) { iter.advance(); @@ -195,7 +195,7 @@ public FieldVector append(FieldVector v) { return append((SparseFieldVector) v); } else { final int n = v.getDimension(); - FieldVector res = new SparseFieldVector(this, n); + FieldVector res = new SparseFieldVector<>(this, n); for (int i = 0; i < n; i++) { res.setEntry(i + virtualSize, v.getEntry(i)); } @@ -209,7 +209,7 @@ public FieldVector append(FieldVector v) { @Override public FieldVector append(T d) throws NullArgumentException { MathUtils.checkNotNull(d); - FieldVector res = new SparseFieldVector(this, 1); + FieldVector res = new SparseFieldVector<>(this, 1); res.setEntry(virtualSize, d); return res; } @@ -217,7 +217,7 @@ public FieldVector append(T d) throws NullArgumentException { /** {@inheritDoc} */ @Override public FieldVector copy() { - return new SparseFieldVector(this); + return new SparseFieldVector<>(this); } /** {@inheritDoc} */ @@ -238,7 +238,7 @@ public T dotProduct(FieldVector v) throws DimensionMismatchException { public FieldVector ebeDivide(FieldVector v) throws DimensionMismatchException, MathArithmeticException { checkVectorDimensions(v.getDimension()); - SparseFieldVector res = new SparseFieldVector(this); + SparseFieldVector res = new SparseFieldVector<>(this); OpenIntToFieldHashMap.Iterator iter = res.entries.iterator(); while (iter.hasNext()) { iter.advance(); @@ -252,7 +252,7 @@ public FieldVector ebeDivide(FieldVector v) public FieldVector ebeMultiply(FieldVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); - SparseFieldVector res = new SparseFieldVector(this); + SparseFieldVector res = new SparseFieldVector<>(this); OpenIntToFieldHashMap.Iterator iter = res.entries.iterator(); while (iter.hasNext()) { iter.advance(); @@ -289,7 +289,7 @@ public FieldVector getSubVector(int index, int n) } checkIndex(index); checkIndex(index + n - 1); - SparseFieldVector res = new SparseFieldVector(field,n); + SparseFieldVector res = new SparseFieldVector<>(field,n); int end = index + n; OpenIntToFieldHashMap.Iterator iter = entries.iterator(); while (iter.hasNext()) { @@ -387,7 +387,7 @@ public FieldVector mapSubtractToSelf(T d) throws NullArgumentException { */ public FieldMatrix outerProduct(SparseFieldVector v) { final int n = v.getDimension(); - SparseFieldMatrix res = new SparseFieldMatrix(field, virtualSize, n); + SparseFieldMatrix res = new SparseFieldMatrix<>(field, virtualSize, n); OpenIntToFieldHashMap.Iterator iter = entries.iterator(); while (iter.hasNext()) { iter.advance(); @@ -407,7 +407,7 @@ public FieldMatrix outerProduct(FieldVector v) { return outerProduct((SparseFieldVector)v); } else { final int n = v.getDimension(); - FieldMatrix res = new SparseFieldMatrix(field, virtualSize, n); + FieldMatrix res = new SparseFieldMatrix<>(field, virtualSize, n); OpenIntToFieldHashMap.Iterator iter = entries.iterator(); while (iter.hasNext()) { iter.advance(); @@ -495,7 +495,7 @@ public FieldVector subtract(FieldVector v) } else { final int n = v.getDimension(); checkVectorDimensions(n); - SparseFieldVector res = new SparseFieldVector(this); + SparseFieldVector res = new SparseFieldVector<>(this); for (int i = 0; i < n; i++) { if (entries.containsKey(i)) { res.setEntry(i, entries.get(i).subtract(v.getEntry(i))); @@ -578,7 +578,7 @@ public FieldVector add(FieldVector v) throws DimensionMismatchException { } else { final int n = v.getDimension(); checkVectorDimensions(n); - SparseFieldVector res = new SparseFieldVector(field, + SparseFieldVector res = new SparseFieldVector<>(field, getDimension()); for (int i = 0; i < n; i++) { res.setEntry(i, v.getEntry(i).add(getEntry(i))); diff --git a/src/main/java/org/apache/commons/math4/ml/clustering/Cluster.java b/src/main/java/org/apache/commons/math4/ml/clustering/Cluster.java index bd264bb1e1..f655065a7f 100644 --- a/src/main/java/org/apache/commons/math4/ml/clustering/Cluster.java +++ b/src/main/java/org/apache/commons/math4/ml/clustering/Cluster.java @@ -38,7 +38,7 @@ public class Cluster implements Serializable { * Build a cluster centered at a specified point. */ public Cluster() { - points = new ArrayList(); + points = new ArrayList<>(); } /** diff --git a/src/main/java/org/apache/commons/math4/ml/clustering/DBSCANClusterer.java b/src/main/java/org/apache/commons/math4/ml/clustering/DBSCANClusterer.java index 1223be84f4..a5614337eb 100644 --- a/src/main/java/org/apache/commons/math4/ml/clustering/DBSCANClusterer.java +++ b/src/main/java/org/apache/commons/math4/ml/clustering/DBSCANClusterer.java @@ -136,8 +136,8 @@ public List> cluster(final Collection points) throws NullArgumentE // sanity checks MathUtils.checkNotNull(points); - final List> clusters = new ArrayList>(); - final Map visited = new HashMap(); + final List> clusters = new ArrayList<>(); + final Map visited = new HashMap<>(); for (final T point : points) { if (visited.get(point) != null) { @@ -146,7 +146,7 @@ public List> cluster(final Collection points) throws NullArgumentE final List neighbors = getNeighbors(point, points); if (neighbors.size() >= minPts) { // DBSCAN does not care about center points - final Cluster cluster = new Cluster(); + final Cluster cluster = new Cluster<>(); clusters.add(expandCluster(cluster, point, neighbors, points, visited)); } else { visited.put(point, PointStatus.NOISE); @@ -174,7 +174,7 @@ private Cluster expandCluster(final Cluster cluster, cluster.addPoint(point); visited.put(point, PointStatus.PART_OF_CLUSTER); - List seeds = new ArrayList(neighbors); + List seeds = new ArrayList<>(neighbors); int index = 0; while (index < seeds.size()) { final T current = seeds.get(index); @@ -205,7 +205,7 @@ private Cluster expandCluster(final Cluster cluster, * @return the List of neighbors */ private List getNeighbors(final T point, final Collection points) { - final List neighbors = new ArrayList(); + final List neighbors = new ArrayList<>(); for (final T neighbor : points) { if (point != neighbor && distance(neighbor, point) <= eps) { neighbors.add(neighbor); @@ -222,7 +222,7 @@ private List getNeighbors(final T point, final Collection points) { * @return merged lists */ private List merge(final List one, final List two) { - final Set oneSet = new HashSet(one); + final Set oneSet = new HashSet<>(one); for (T item : two) { if (!oneSet.contains(item)) { one.add(item); diff --git a/src/main/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClusterer.java b/src/main/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClusterer.java index e57697f379..7ef632f527 100644 --- a/src/main/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClusterer.java +++ b/src/main/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClusterer.java @@ -279,8 +279,8 @@ public List> cluster(final Collection dataPoints) } // copy the input collection to an unmodifiable list with indexed access - points = Collections.unmodifiableList(new ArrayList(dataPoints)); - clusters = new ArrayList>(); + points = Collections.unmodifiableList(new ArrayList<>(dataPoints)); + clusters = new ArrayList<>(); membershipMatrix = new double[size][k]; final double[][] oldMatrix = new double[size][k]; @@ -316,7 +316,7 @@ public List> cluster(final Collection dataPoints) */ private void updateClusterCenters() { int j = 0; - final List> newClusters = new ArrayList>(k); + final List> newClusters = new ArrayList<>(k); for (final CentroidCluster cluster : clusters) { final Clusterable center = cluster.getCenter(); int i = 0; diff --git a/src/main/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClusterer.java b/src/main/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClusterer.java index 1901013d04..79dca8e166 100644 --- a/src/main/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClusterer.java +++ b/src/main/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClusterer.java @@ -216,7 +216,7 @@ public List> cluster(final Collection points) final int max = (maxIterations < 0) ? Integer.MAX_VALUE : maxIterations; for (int count = 0; count < max; count++) { boolean emptyCluster = false; - List> newClusters = new ArrayList>(); + List> newClusters = new ArrayList<>(); for (final CentroidCluster cluster : clusters) { final Clusterable newCenter; if (cluster.getPoints().isEmpty()) { @@ -288,7 +288,7 @@ private List> chooseInitialCenters(final Collection points // Convert to list for indexed access. Make it unmodifiable, since removal of items // would screw up the logic of this method. - final List pointList = Collections.unmodifiableList(new ArrayList (points)); + final List pointList = Collections.unmodifiableList(new ArrayList<> (points)); // The number of points in the list. final int numPoints = pointList.size(); @@ -298,7 +298,7 @@ private List> chooseInitialCenters(final Collection points final boolean[] taken = new boolean[numPoints]; // The resulting list of initial centers. - final List> resultSet = new ArrayList>(); + final List> resultSet = new ArrayList<>(); // Choose one center uniformly at random from among the data points. final int firstPointIndex = random.nextInt(numPoints); diff --git a/src/main/java/org/apache/commons/math4/ml/neuralnet/MapUtils.java b/src/main/java/org/apache/commons/math4/ml/neuralnet/MapUtils.java index d097edd398..a793fa0ac3 100644 --- a/src/main/java/org/apache/commons/math4/ml/neuralnet/MapUtils.java +++ b/src/main/java/org/apache/commons/math4/ml/neuralnet/MapUtils.java @@ -105,7 +105,7 @@ public static Pair findBestAndSecondBest(double[] features, } } - return new Pair(best[0], best[1]); + return new Pair<>(best[0], best[1]); } /** @@ -130,7 +130,7 @@ public static Pair findBestAndSecondBest(double[] features, public static Neuron[] sort(double[] features, Iterable neurons, DistanceMeasure distance) { - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (final Neuron n : neurons) { final double d = distance.compute(n.getFeatures(), features); @@ -196,7 +196,7 @@ public static double[][] computeU(NeuronSquareMesh2D map, public static int[][] computeHitHistogram(Iterable data, NeuronSquareMesh2D map, DistanceMeasure distance) { - final HashMap hit = new HashMap(); + final HashMap hit = new HashMap<>(); final Network net = map.getNetwork(); for (double[] f : data) { diff --git a/src/main/java/org/apache/commons/math4/ml/neuralnet/Network.java b/src/main/java/org/apache/commons/math4/ml/neuralnet/Network.java index 6dcd729b72..6da635ea05 100644 --- a/src/main/java/org/apache/commons/math4/ml/neuralnet/Network.java +++ b/src/main/java/org/apache/commons/math4/ml/neuralnet/Network.java @@ -51,14 +51,14 @@ public class Network private static final long serialVersionUID = 20130207L; /** Neurons. */ private final ConcurrentHashMap neuronMap - = new ConcurrentHashMap(); + = new ConcurrentHashMap<>(); /** Next available neuron identifier. */ private final AtomicLong nextId; /** Neuron's features set size. */ private final int featureSize; /** Links. */ private final ConcurrentHashMap> linkMap - = new ConcurrentHashMap>(); + = new ConcurrentHashMap<>(); /** * Comparator that prescribes an order of the neurons according @@ -155,7 +155,7 @@ public synchronized Network copy() { } for (Map.Entry> e : linkMap.entrySet()) { - copy.linkMap.put(e.getKey(), new HashSet(e.getValue())); + copy.linkMap.put(e.getKey(), new HashSet<>(e.getValue())); } return copy; @@ -178,7 +178,7 @@ public Iterator iterator() { * @see NeuronIdentifierComparator */ public Collection getNeurons(Comparator comparator) { - final List neurons = new ArrayList(); + final List neurons = new ArrayList<>(); neurons.addAll(neuronMap.values()); Collections.sort(neurons, comparator); @@ -356,7 +356,7 @@ public Collection getNeighbours(Iterable neurons) { */ public Collection getNeighbours(Iterable neurons, Iterable exclude) { - final Set idList = new HashSet(); + final Set idList = new HashSet<>(); for (Neuron n : neurons) { idList.addAll(linkMap.get(n.getIdentifier())); @@ -367,7 +367,7 @@ public Collection getNeighbours(Iterable neurons, } } - final List neuronList = new ArrayList(); + final List neuronList = new ArrayList<>(); for (Long id : idList) { neuronList.add(getNeuron(id)); } @@ -403,7 +403,7 @@ public Collection getNeighbours(Neuron neuron, } } - final List neuronList = new ArrayList(); + final List neuronList = new ArrayList<>(); for (Long id : idList) { neuronList.add(getNeuron(id)); } diff --git a/src/main/java/org/apache/commons/math4/ml/neuralnet/Neuron.java b/src/main/java/org/apache/commons/math4/ml/neuralnet/Neuron.java index 56f19768a9..61b3aa192f 100644 --- a/src/main/java/org/apache/commons/math4/ml/neuralnet/Neuron.java +++ b/src/main/java/org/apache/commons/math4/ml/neuralnet/Neuron.java @@ -63,7 +63,7 @@ public class Neuron implements Serializable { double[] features) { this.identifier = identifier; this.size = features.length; - this.features = new AtomicReference(features.clone()); + this.features = new AtomicReference<>(features.clone()); } /** diff --git a/src/main/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenUpdateAction.java b/src/main/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenUpdateAction.java index 87e1bbca21..1c49d06380 100644 --- a/src/main/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenUpdateAction.java +++ b/src/main/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenUpdateAction.java @@ -111,10 +111,10 @@ public void update(Network net, if (currentNeighbourhood > 0) { // Initial set of neurons only contains the winning neuron. - Collection neighbours = new HashSet(); + Collection neighbours = new HashSet<>(); neighbours.add(best); // Winning neuron must be excluded from the neighbours. - final HashSet exclude = new HashSet(); + final HashSet exclude = new HashSet<>(); exclude.add(best); int radius = 1; diff --git a/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2D.java b/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2D.java index 38bd608465..e42491d639 100644 --- a/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2D.java +++ b/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2D.java @@ -423,7 +423,7 @@ private int[] getLocation(int row, */ private void createLinks() { // "linkEnd" will store the identifiers of the "neighbours". - final List linkEnd = new ArrayList(); + final List linkEnd = new ArrayList<>(); final int iLast = numberOfRows - 1; final int jLast = numberOfColumns - 1; for (int i = 0; i < numberOfRows; i++) { diff --git a/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/util/LocationFinder.java b/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/util/LocationFinder.java index fa02e3aac6..7785f7b5dc 100644 --- a/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/util/LocationFinder.java +++ b/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/util/LocationFinder.java @@ -29,7 +29,7 @@ */ public class LocationFinder { /** Identifier to location mapping. */ - private final Map locations = new HashMap(); + private final Map locations = new HashMap<>(); /** * Container holding a (row, column) pair. diff --git a/src/main/java/org/apache/commons/math4/ode/AbstractFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/AbstractFieldIntegrator.java index c61da98a18..2475a482af 100644 --- a/src/main/java/org/apache/commons/math4/ode/AbstractFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/AbstractFieldIntegrator.java @@ -95,10 +95,10 @@ public abstract class AbstractFieldIntegrator> imp protected AbstractFieldIntegrator(final Field field, final String name) { this.field = field; this.name = name; - stepHandlers = new ArrayList>(); + stepHandlers = new ArrayList<>(); stepStart = null; stepSize = null; - eventsStates = new ArrayList>(); + eventsStates = new ArrayList<>(); statesInitialized = false; evaluations = IntegerSequence.Incrementor.create().withMaximalCount(Integer.MAX_VALUE); } @@ -142,7 +142,7 @@ public void addEventHandler(final FieldEventHandler handler, final int maxIterationCount) { addEventHandler(handler, maxCheckInterval, convergence, maxIterationCount, - new FieldBracketingNthOrderBrentSolver(field.getZero().add(DEFAULT_RELATIVE_ACCURACY), + new FieldBracketingNthOrderBrentSolver<>(field.getZero().add(DEFAULT_RELATIVE_ACCURACY), field.getZero().add(convergence), field.getZero().add(DEFAULT_FUNCTION_VALUE_ACCURACY), 5)); @@ -155,14 +155,14 @@ public void addEventHandler(final FieldEventHandler handler, final double convergence, final int maxIterationCount, final BracketedRealFieldUnivariateSolver solver) { - eventsStates.add(new FieldEventState(handler, maxCheckInterval, field.getZero().add(convergence), + eventsStates.add(new FieldEventState<>(handler, maxCheckInterval, field.getZero().add(convergence), maxIterationCount, solver)); } /** {@inheritDoc} */ @Override public Collection> getEventHandlers() { - final List> list = new ArrayList>(eventsStates.size()); + final List> list = new ArrayList<>(eventsStates.size()); for (FieldEventState state : eventsStates) { list.add(state.getEventHandler()); } @@ -223,7 +223,7 @@ protected FieldODEStateAndDerivative initIntegration(final FieldExpandableODE // set up derivatives of initial state final T[] y0Dot = computeDerivatives(t0, y0); - final FieldODEStateAndDerivative state0 = new FieldODEStateAndDerivative(t0, y0, y0Dot); + final FieldODEStateAndDerivative state0 = new FieldODEStateAndDerivative<>(t0, y0, y0Dot); // initialize event handlers for (final FieldEventState state : eventsStates) { @@ -307,7 +307,7 @@ protected FieldODEStateAndDerivative acceptStep(final AbstractFieldStepInterp // search for next events that may occur during the step final int orderingSign = interpolator.isForward() ? +1 : -1; - SortedSet> occurringEvents = new TreeSet>(new Comparator>() { + SortedSet> occurringEvents = new TreeSet<>(new Comparator>() { /** {@inheritDoc} */ @Override 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 072889a002..e4dd02f9e9 100644 --- a/src/main/java/org/apache/commons/math4/ode/AbstractIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/AbstractIntegrator.java @@ -82,10 +82,10 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator { */ public AbstractIntegrator(final String name) { this.name = name; - stepHandlers = new ArrayList(); + stepHandlers = new ArrayList<>(); stepStart = Double.NaN; stepSize = Double.NaN; - eventsStates = new ArrayList(); + eventsStates = new ArrayList<>(); statesInitialized = false; evaluations = IntegerSequence.Incrementor.create().withMaximalCount(Integer.MAX_VALUE); } @@ -145,7 +145,7 @@ public void addEventHandler(final EventHandler handler, /** {@inheritDoc} */ @Override public Collection getEventHandlers() { - final List list = new ArrayList(eventsStates.size()); + final List list = new ArrayList<>(eventsStates.size()); for (EventState state : eventsStates) { list.add(state.getEventHandler()); } @@ -341,7 +341,7 @@ protected double acceptStep(final AbstractStepInterpolator interpolator, // search for next events that may occur during the step final int orderingSign = interpolator.isForward() ? +1 : -1; - SortedSet occurringEvents = new TreeSet(new Comparator() { + SortedSet occurringEvents = new TreeSet<>(new Comparator() { /** {@inheritDoc} */ @Override diff --git a/src/main/java/org/apache/commons/math4/ode/AbstractParameterizable.java b/src/main/java/org/apache/commons/math4/ode/AbstractParameterizable.java index 5b4aea7180..c21365d648 100644 --- a/src/main/java/org/apache/commons/math4/ode/AbstractParameterizable.java +++ b/src/main/java/org/apache/commons/math4/ode/AbstractParameterizable.java @@ -33,7 +33,7 @@ public abstract class AbstractParameterizable implements Parameterizable { * @param names names of the supported parameters */ protected AbstractParameterizable(final String ... names) { - parametersNames = new ArrayList(); + parametersNames = new ArrayList<>(); for (final String name : names) { parametersNames.add(name); } @@ -43,7 +43,7 @@ protected AbstractParameterizable(final String ... names) { * @param names names of the supported parameters */ protected AbstractParameterizable(final Collection names) { - parametersNames = new ArrayList(); + parametersNames = new ArrayList<>(); parametersNames.addAll(names); } diff --git a/src/main/java/org/apache/commons/math4/ode/ContinuousOutputFieldModel.java b/src/main/java/org/apache/commons/math4/ode/ContinuousOutputFieldModel.java index e8b96a1a7f..b1d8be2156 100644 --- a/src/main/java/org/apache/commons/math4/ode/ContinuousOutputFieldModel.java +++ b/src/main/java/org/apache/commons/math4/ode/ContinuousOutputFieldModel.java @@ -100,7 +100,7 @@ public class ContinuousOutputFieldModel> * Build an empty continuous output model. */ public ContinuousOutputFieldModel() { - steps = new ArrayList>(); + steps = new ArrayList<>(); initialTime = null; finalTime = null; forward = true; diff --git a/src/main/java/org/apache/commons/math4/ode/ContinuousOutputModel.java b/src/main/java/org/apache/commons/math4/ode/ContinuousOutputModel.java index e48dff9340..8f63847690 100644 --- a/src/main/java/org/apache/commons/math4/ode/ContinuousOutputModel.java +++ b/src/main/java/org/apache/commons/math4/ode/ContinuousOutputModel.java @@ -111,7 +111,7 @@ public class ContinuousOutputModel * Build an empty continuous output model. */ public ContinuousOutputModel() { - steps = new ArrayList(); + steps = new ArrayList<>(); initialTime = Double.NaN; finalTime = Double.NaN; forward = true; diff --git a/src/main/java/org/apache/commons/math4/ode/ExpandableStatefulODE.java b/src/main/java/org/apache/commons/math4/ode/ExpandableStatefulODE.java index 77e50bcf8d..476b9ffb63 100644 --- a/src/main/java/org/apache/commons/math4/ode/ExpandableStatefulODE.java +++ b/src/main/java/org/apache/commons/math4/ode/ExpandableStatefulODE.java @@ -76,7 +76,7 @@ public ExpandableStatefulODE(final FirstOrderDifferentialEquations primary) { this.time = Double.NaN; this.primaryState = new double[n]; this.primaryStateDot = new double[n]; - this.components = new ArrayList(); + this.components = new ArrayList<>(); } /** Get the primary set of differential equations. @@ -138,7 +138,7 @@ public int addSecondaryEquations(final SecondaryEquations secondary) { final int firstIndex; if (components.isEmpty()) { // lazy creation of the components list - components = new ArrayList(); + components = new ArrayList<>(); firstIndex = primary.getDimension(); } else { final SecondaryComponent last = components.get(components.size() - 1); diff --git a/src/main/java/org/apache/commons/math4/ode/FieldEquationsMapper.java b/src/main/java/org/apache/commons/math4/ode/FieldEquationsMapper.java index 1febe7d831..cafdd662bb 100644 --- a/src/main/java/org/apache/commons/math4/ode/FieldEquationsMapper.java +++ b/src/main/java/org/apache/commons/math4/ode/FieldEquationsMapper.java @@ -130,7 +130,7 @@ public FieldODEStateAndDerivative mapStateAndDerivative(final T t, final T[] final T[] state = extractEquationData(index, y); final T[] derivative = extractEquationData(index, yDot); if (n < 2) { - return new FieldODEStateAndDerivative(t, state, derivative); + return new FieldODEStateAndDerivative<>(t, state, derivative); } else { final T[][] secondaryState = MathArrays.buildArray(t.getField(), n - 1, -1); final T[][] secondaryDerivative = MathArrays.buildArray(t.getField(), n - 1, -1); @@ -138,7 +138,7 @@ public FieldODEStateAndDerivative mapStateAndDerivative(final T t, final T[] secondaryState[index - 1] = extractEquationData(index, y); secondaryDerivative[index - 1] = extractEquationData(index, yDot); } - return new FieldODEStateAndDerivative(t, state, derivative, secondaryState, secondaryDerivative); + return new FieldODEStateAndDerivative<>(t, state, derivative, secondaryState, secondaryDerivative); } } diff --git a/src/main/java/org/apache/commons/math4/ode/FieldExpandableODE.java b/src/main/java/org/apache/commons/math4/ode/FieldExpandableODE.java index e5dd205db8..8dddaad83e 100644 --- a/src/main/java/org/apache/commons/math4/ode/FieldExpandableODE.java +++ b/src/main/java/org/apache/commons/math4/ode/FieldExpandableODE.java @@ -65,8 +65,8 @@ public class FieldExpandableODE> { */ public FieldExpandableODE(final FirstOrderFieldDifferentialEquations primary) { this.primary = primary; - this.components = new ArrayList>(); - this.mapper = new FieldEquationsMapper(null, primary.getDimension()); + this.components = new ArrayList<>(); + this.mapper = new FieldEquationsMapper<>(null, primary.getDimension()); } /** Get the mapper for the set of equations. @@ -86,7 +86,7 @@ public FieldEquationsMapper getMapper() { public int addSecondaryEquations(final FieldSecondaryEquations secondary) { components.add(secondary); - mapper = new FieldEquationsMapper(mapper, secondary.getDimension()); + mapper = new FieldEquationsMapper<>(mapper, secondary.getDimension()); return components.size(); diff --git a/src/main/java/org/apache/commons/math4/ode/JacobianMatrices.java b/src/main/java/org/apache/commons/math4/ode/JacobianMatrices.java index 1296620329..2efed92c6d 100644 --- a/src/main/java/org/apache/commons/math4/ode/JacobianMatrices.java +++ b/src/main/java/org/apache/commons/math4/ode/JacobianMatrices.java @@ -141,7 +141,7 @@ public JacobianMatrices(final MainStateJacobianProvider jode, } this.dirtyParameter = false; - this.jacobianProviders = new ArrayList(); + this.jacobianProviders = new ArrayList<>(); // set the default initial state Jacobian to the identity // and the default initial parameters Jacobian to the null matrix diff --git a/src/main/java/org/apache/commons/math4/ode/MultistepFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/MultistepFieldIntegrator.java index fdb1d907c3..edd65e2614 100644 --- a/src/main/java/org/apache/commons/math4/ode/MultistepFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/MultistepFieldIntegrator.java @@ -130,7 +130,7 @@ protected MultistepFieldIntegrator(final Field field, final String name, nSteps, 2, true); } - starter = new DormandPrince853FieldIntegrator(field, minStep, maxStep, + starter = new DormandPrince853FieldIntegrator<>(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); this.nSteps = nSteps; @@ -170,7 +170,7 @@ protected MultistepFieldIntegrator(final Field field, final String name, fina final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) { super(field, name, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); - starter = new DormandPrince853FieldIntegrator(field, minStep, maxStep, + starter = new DormandPrince853FieldIntegrator<>(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); this.nSteps = nSteps; diff --git a/src/main/java/org/apache/commons/math4/ode/ParameterJacobianWrapper.java b/src/main/java/org/apache/commons/math4/ode/ParameterJacobianWrapper.java index d555aa471d..e28c185e75 100644 --- a/src/main/java/org/apache/commons/math4/ode/ParameterJacobianWrapper.java +++ b/src/main/java/org/apache/commons/math4/ode/ParameterJacobianWrapper.java @@ -51,7 +51,7 @@ class ParameterJacobianWrapper implements ParameterJacobianProvider { final ParameterConfiguration[] paramsAndSteps) { this.fode = fode; this.pode = pode; - this.hParam = new HashMap(); + this.hParam = new HashMap<>(); // set up parameters for jacobian computation for (final ParameterConfiguration param : paramsAndSteps) { diff --git a/src/main/java/org/apache/commons/math4/ode/ParameterizedWrapper.java b/src/main/java/org/apache/commons/math4/ode/ParameterizedWrapper.java index c306ec875f..0d2521d6fb 100644 --- a/src/main/java/org/apache/commons/math4/ode/ParameterizedWrapper.java +++ b/src/main/java/org/apache/commons/math4/ode/ParameterizedWrapper.java @@ -61,7 +61,7 @@ public void computeDerivatives(double t, double[] y, double[] yDot) /** {@inheritDoc} */ @Override public Collection getParametersNames() { - return new ArrayList(); + return new ArrayList<>(); } /** {@inheritDoc} */ diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegrator.java index 977573e3f5..ebb31f0aa3 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegrator.java @@ -301,7 +301,7 @@ public FieldODEStateAndDerivative integrate(final FieldExpandableODE equat } // discrete events handling - setStepStart(acceptStep(new AdamsFieldStepInterpolator(getStepSize(), stepEnd, + setStepStart(acceptStep(new AdamsFieldStepInterpolator<>(getStepSize(), stepEnd, predictedScaled, predictedNordsieck, forward, getStepStart(), stepEnd, equations.getMapper()), diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldStepInterpolator.java index b4b5357c41..feac005cfe 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldStepInterpolator.java @@ -103,7 +103,7 @@ private AdamsFieldStepInterpolator(final T stepSize, final FieldODEStateAndDeriv this.scalingH = stepSize; this.reference = reference; this.scaled = scaled.clone(); - this.nordsieck = new Array2DRowFieldMatrix(nordsieck.getData(), false); + this.nordsieck = new Array2DRowFieldMatrix<>(nordsieck.getData(), false); } /** Create a new instance. @@ -121,7 +121,7 @@ protected AdamsFieldStepInterpolator create(boolean newForward, FieldODEStateAndDerivative newSoftPreviousState, FieldODEStateAndDerivative newSoftCurrentState, FieldEquationsMapper newMapper) { - return new AdamsFieldStepInterpolator(scalingH, reference, scaled, nordsieck, + return new AdamsFieldStepInterpolator<>(scalingH, reference, scaled, nordsieck, newForward, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, @@ -181,7 +181,7 @@ public static > FieldODEStateAndDerivative tayl estimatedDerivatives[j].add(scaled[j].multiply(normalizedAbscissa)).divide(x); } - return new FieldODEStateAndDerivative(time, estimatedState, estimatedDerivatives); + return new FieldODEStateAndDerivative<>(time, estimatedState, estimatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegrator.java index c659cc003d..72d4de225b 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegrator.java @@ -284,8 +284,8 @@ public FieldODEStateAndDerivative integrate(final FieldExpandableODE equat updateHighOrderDerivativesPhase2(predictedScaled, correctedScaled, predictedNordsieck); // discrete events handling - stepEnd = new FieldODEStateAndDerivative(stepEnd.getTime(), predictedY, correctedYDot); - setStepStart(acceptStep(new AdamsFieldStepInterpolator(getStepSize(), stepEnd, + stepEnd = new FieldODEStateAndDerivative<>(stepEnd.getTime(), predictedY, correctedYDot); + setStepStart(acceptStep(new AdamsFieldStepInterpolator<>(getStepSize(), stepEnd, correctedScaled, predictedNordsieck, forward, getStepStart(), stepEnd, equations.getMapper()), diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckFieldTransformer.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckFieldTransformer.java index c1e5beea59..7c2b872f70 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckFieldTransformer.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckFieldTransformer.java @@ -137,8 +137,7 @@ public class AdamsNordsieckFieldTransformer> { private static final Map>, AdamsNordsieckFieldTransformer>>> CACHE = - new HashMap>, - AdamsNordsieckFieldTransformer>>>(); + new HashMap<>(); /** Field to which the time and state vector elements belong. */ private final Field field; @@ -162,11 +161,11 @@ private AdamsNordsieckFieldTransformer(final Field field, final int n) { // compute coefficients FieldMatrix bigP = buildP(rows); FieldDecompositionSolver pSolver = - new FieldLUDecomposition(bigP).getSolver(); + new FieldLUDecomposition<>(bigP).getSolver(); T[] u = MathArrays.buildArray(field, rows); Arrays.fill(u, field.getOne()); - c1 = pSolver.solve(new ArrayFieldVector(u, false)).toArray(); + c1 = pSolver.solve(new ArrayFieldVector<>(u, false)).toArray(); // update coefficients are computed by combining transform from // Nordsieck to multistep, then shifting rows to represent step advance @@ -178,7 +177,7 @@ private AdamsNordsieckFieldTransformer(final Field field, final int n) { } shiftedP[0] = MathArrays.buildArray(field, rows); Arrays.fill(shiftedP[0], field.getZero()); - update = new Array2DRowFieldMatrix(pSolver.solve(new Array2DRowFieldMatrix(shiftedP, false)).getData()); + update = new Array2DRowFieldMatrix<>(pSolver.solve(new Array2DRowFieldMatrix<>(shiftedP, false)).getData()); } @@ -195,14 +194,13 @@ private AdamsNordsieckFieldTransformer(final Field field, final int n) { Map>, AdamsNordsieckFieldTransformer>> map = CACHE.get(nSteps); if (map == null) { - map = new HashMap>, - AdamsNordsieckFieldTransformer>>(); + map = new HashMap<>(); CACHE.put(nSteps, map); } @SuppressWarnings("unchecked") AdamsNordsieckFieldTransformer t = (AdamsNordsieckFieldTransformer) map.get(field); if (t == null) { - t = new AdamsNordsieckFieldTransformer(field, nSteps); + t = new AdamsNordsieckFieldTransformer<>(field, nSteps); map.put(field, t); } return t; @@ -239,7 +237,7 @@ private FieldMatrix buildP(final int rows) { } } - return new Array2DRowFieldMatrix(pData, false); + return new Array2DRowFieldMatrix<>(pData, false); } @@ -303,12 +301,12 @@ public Array2DRowFieldMatrix initializeHighOrderDerivatives(final T h, final // solve the linear system to get the best estimate of the Nordsieck vector [s2 ... sk], // with the additional terms s(k+1) and c grabbing the parts after the truncated Taylor expansion - final FieldLUDecomposition decomposition = new FieldLUDecomposition(new Array2DRowFieldMatrix(a, false)); - final FieldMatrix x = decomposition.getSolver().solve(new Array2DRowFieldMatrix(b, false)); + final FieldLUDecomposition decomposition = new FieldLUDecomposition<>(new Array2DRowFieldMatrix<>(a, false)); + final FieldMatrix x = decomposition.getSolver().solve(new Array2DRowFieldMatrix<>(b, false)); // extract just the Nordsieck vector [s2 ... sk] final Array2DRowFieldMatrix truncatedX = - new Array2DRowFieldMatrix(field, x.getRowDimension() - 1, x.getColumnDimension()); + new Array2DRowFieldMatrix<>(field, x.getRowDimension() - 1, x.getColumnDimension()); for (int i = 0; i < truncatedX.getRowDimension(); ++i) { for (int j = 0; j < truncatedX.getColumnDimension(); ++j) { truncatedX.setEntry(i, j, x.getEntry(i, j)); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckTransformer.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckTransformer.java index 86bc871064..f38e61af8a 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckTransformer.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckTransformer.java @@ -136,7 +136,7 @@ public class AdamsNordsieckTransformer { /** Cache for already computed coefficients. */ private static final Map CACHE = - new HashMap(); + new HashMap<>(); /** Update matrix for the higher order derivatives h2/2 y'', h3/6 y''' ... */ private final Array2DRowRealMatrix update; @@ -155,11 +155,11 @@ private AdamsNordsieckTransformer(final int n) { // compute exact coefficients FieldMatrix bigP = buildP(rows); FieldDecompositionSolver pSolver = - new FieldLUDecomposition(bigP).getSolver(); + new FieldLUDecomposition<>(bigP).getSolver(); BigFraction[] u = new BigFraction[rows]; Arrays.fill(u, BigFraction.ONE); - BigFraction[] bigC1 = pSolver.solve(new ArrayFieldVector(u, false)).toArray(); + BigFraction[] bigC1 = pSolver.solve(new ArrayFieldVector<>(u, false)).toArray(); // update coefficients are computed by combining transform from // Nordsieck to multistep, then shifting rows to represent step advance @@ -172,7 +172,7 @@ private AdamsNordsieckTransformer(final int n) { shiftedP[0] = new BigFraction[rows]; Arrays.fill(shiftedP[0], BigFraction.ZERO); FieldMatrix bigMSupdate = - pSolver.solve(new Array2DRowFieldMatrix(shiftedP, false)); + pSolver.solve(new Array2DRowFieldMatrix<>(shiftedP, false)); // convert coefficients to double update = MatrixUtils.bigFractionMatrixToRealMatrix(bigMSupdate); @@ -239,7 +239,7 @@ private FieldMatrix buildP(final int rows) { } } - return new Array2DRowFieldMatrix(pData, false); + return new Array2DRowFieldMatrix<>(pData, false); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java index 315924a906..56add60dee 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java @@ -105,7 +105,7 @@ public T[] getB() { final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new ClassicalRungeKuttaFieldStepInterpolator(getField(), forward, yDotK, + return new ClassicalRungeKuttaFieldStepInterpolator<>(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldStepInterpolator.java index 522530b515..c4d1263fd3 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldStepInterpolator.java @@ -89,7 +89,7 @@ protected ClassicalRungeKuttaFieldStepInterpolator create(final Field newF final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new ClassicalRungeKuttaFieldStepInterpolator(newField, newForward, newYDotK, + return new ClassicalRungeKuttaFieldStepInterpolator<>(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -129,7 +129,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(coeffDot1, coeffDot23, coeffDot23, coeffDot4); } - return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegrator.java index b8ec110e84..12d7a64751 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegrator.java @@ -193,7 +193,7 @@ public T[] getB() { createInterpolator(final boolean forward, T[][] yDotK, final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new DormandPrince54FieldStepInterpolator(getField(), forward, yDotK, + return new DormandPrince54FieldStepInterpolator<>(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolator.java index 16a2fe4151..61548ce76e 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolator.java @@ -114,7 +114,7 @@ protected DormandPrince54FieldStepInterpolator create(final Field newField final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new DormandPrince54FieldStepInterpolator(newField, newForward, newYDotK, + return new DormandPrince54FieldStepInterpolator<>(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -242,7 +242,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(coeffDot0, coeffDot1, coeffDot2, coeffDot3, coeffDot4, coeffDot5, coeffDot6); } - return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegrator.java index 171b46524d..b40eb5088d 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegrator.java @@ -399,7 +399,7 @@ public T[] getB() { createInterpolator(final boolean forward, T[][] yDotK, final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new DormandPrince853FieldStepInterpolator(getField(), forward, yDotK, + return new DormandPrince853FieldStepInterpolator<>(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolator.java index e4d7ee526b..5228dd2117 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolator.java @@ -195,7 +195,7 @@ protected DormandPrince853FieldStepInterpolator create(final Field newFiel final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new DormandPrince853FieldStepInterpolator(newField, newForward, newYDotK, + return new DormandPrince853FieldStepInterpolator<>(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -295,7 +295,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f q[8], q[9], q[10], q[11], q[12], q[13], q[14], q[15]); } - return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegrator.java index acba7a5134..6238953fb0 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegrator.java @@ -309,7 +309,7 @@ public FieldODEStateAndDerivative integrate(final FieldExpandableODE equat } final T stepEnd = getStepStart().getTime().add(getStepSize()); final T[] yDotTmp = (fsal >= 0) ? yDotK[fsal] : computeDerivatives(stepEnd, yTmp); - final FieldODEStateAndDerivative stateTmp = new FieldODEStateAndDerivative(stepEnd, yTmp, yDotTmp); + final FieldODEStateAndDerivative stateTmp = new FieldODEStateAndDerivative<>(stepEnd, yTmp, yDotTmp); // local error is small enough: accept the step, trigger events and step handlers System.arraycopy(yTmp, 0, y, 0, y0.length); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegrator.java index ce87431110..503231c2a6 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegrator.java @@ -90,7 +90,7 @@ public T[] getB() { final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new EulerFieldStepInterpolator(getField(), forward, yDotK, + return new EulerFieldStepInterpolator<>(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolator.java index e57865ac85..43b8a53779 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolator.java @@ -79,7 +79,7 @@ protected EulerFieldStepInterpolator create(final Field newField, final bo final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new EulerFieldStepInterpolator(newField, newForward, newYDotK, + return new EulerFieldStepInterpolator<>(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -101,7 +101,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(time.getField().getOne()); } - return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegrator.java index 1fc66887c2..0ee8b5dedc 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegrator.java @@ -115,7 +115,7 @@ public T[] getB() { final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new GillFieldStepInterpolator(getField(), forward, yDotK, + return new GillFieldStepInterpolator<>(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolator.java index bb00d04d6b..df474308e9 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolator.java @@ -97,7 +97,7 @@ protected GillFieldStepInterpolator create(final Field newField, final boo final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new GillFieldStepInterpolator(newField, newForward, newYDotK, + return new GillFieldStepInterpolator<>(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -141,7 +141,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(coeffDot1, coeffDot2, coeffDot3, coeffDot4); } - return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegrator.java index 0f8353af46..e88467e95a 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegrator.java @@ -168,7 +168,7 @@ public T[] getB() { createInterpolator(final boolean forward, T[][] yDotK, final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new HighamHall54FieldStepInterpolator(getField(), forward, yDotK, + return new HighamHall54FieldStepInterpolator<>(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolator.java index a915e26487..fd8f5cff24 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolator.java @@ -65,7 +65,7 @@ protected HighamHall54FieldStepInterpolator create(final Field newField, f final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new HighamHall54FieldStepInterpolator(newField, newForward, newYDotK, + return new HighamHall54FieldStepInterpolator<>(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -109,7 +109,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(bDot0, bDot1, bDot2, bDot3, bDot4, bDot5); } - return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegrator.java index 1c3301c8b6..b3c1424429 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegrator.java @@ -140,7 +140,7 @@ public T[] getB() { final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new LutherFieldStepInterpolator(getField(), forward, yDotK, + return new LutherFieldStepInterpolator<>(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolator.java index 438e09e41a..df5ea6a25a 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolator.java @@ -125,7 +125,7 @@ protected LutherFieldStepInterpolator create(final Field newField, final b final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new LutherFieldStepInterpolator(newField, newForward, newYDotK, + return new LutherFieldStepInterpolator<>(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -217,7 +217,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(coeffDot1, coeffDot2, coeffDot3, coeffDot4, coeffDot5, coeffDot6, coeffDot7); } - return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegrator.java index af5a867f39..3b604e37f8 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegrator.java @@ -90,7 +90,7 @@ public T[] getB() { final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new MidpointFieldStepInterpolator(getField(), forward, yDotK, + return new MidpointFieldStepInterpolator<>(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolator.java index 03bd70d848..f64012eabe 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolator.java @@ -81,7 +81,7 @@ protected MidpointFieldStepInterpolator create(final Field newField, final final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new MidpointFieldStepInterpolator(newField, newForward, newYDotK, + return new MidpointFieldStepInterpolator<>(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -111,7 +111,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(coeffDot1, coeffDot2); } - return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegrator.java index 8956fa4e27..f07bbae731 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegrator.java @@ -177,7 +177,7 @@ public FieldODEStateAndDerivative integrate(final FieldExpandableODE equat } final T stepEnd = getStepStart().getTime().add(getStepSize()); final T[] yDotTmp = computeDerivatives(stepEnd, yTmp); - final FieldODEStateAndDerivative stateTmp = new FieldODEStateAndDerivative(stepEnd, yTmp, yDotTmp); + final FieldODEStateAndDerivative stateTmp = new FieldODEStateAndDerivative<>(stepEnd, yTmp, yDotTmp); // discrete events handling System.arraycopy(yTmp, 0, y, 0, y0.length); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegrator.java index 4a786f55ed..8169d75398 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegrator.java @@ -104,7 +104,7 @@ public T[] getB() { final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new ThreeEighthesFieldStepInterpolator(getField(), forward, yDotK, + return new ThreeEighthesFieldStepInterpolator<>(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolator.java index 69df7f8054..b41f91a550 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolator.java @@ -91,7 +91,7 @@ protected ThreeEighthesFieldStepInterpolator create(final Field newField, final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new ThreeEighthesFieldStepInterpolator(newField, newForward, newYDotK, + return new ThreeEighthesFieldStepInterpolator<>(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -132,7 +132,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(coeffDot1, coeffDot2, coeffDot3, coeffDot4); } - return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/optim/linear/LinearConstraintSet.java b/src/main/java/org/apache/commons/math4/optim/linear/LinearConstraintSet.java index 7a31698714..3dcc2a1af9 100644 --- a/src/main/java/org/apache/commons/math4/optim/linear/LinearConstraintSet.java +++ b/src/main/java/org/apache/commons/math4/optim/linear/LinearConstraintSet.java @@ -30,7 +30,7 @@ */ public class LinearConstraintSet implements OptimizationData { /** Set of constraints. */ - private final Set linearConstraints = new LinkedHashSet(); + private final Set linearConstraints = new LinkedHashSet<>(); /** * Creates a set containing the given constraints. diff --git a/src/main/java/org/apache/commons/math4/optim/linear/SimplexSolver.java b/src/main/java/org/apache/commons/math4/optim/linear/SimplexSolver.java index a835765ea7..04b6ab94d8 100644 --- a/src/main/java/org/apache/commons/math4/optim/linear/SimplexSolver.java +++ b/src/main/java/org/apache/commons/math4/optim/linear/SimplexSolver.java @@ -247,7 +247,7 @@ private boolean isValidPivotColumn(SimplexTableau tableau, int col) { */ private Integer getPivotRow(SimplexTableau tableau, final int col) { // create a list of all the rows that tie for the lowest score in the minimum ratio test - List minRatioPositions = new ArrayList(); + List minRatioPositions = new ArrayList<>(); double minRatio = Double.MAX_VALUE; for (int i = tableau.getNumObjectiveFunctions(); i < tableau.getHeight(); i++) { final double rhs = tableau.getEntry(i, tableau.getWidth() - 1); diff --git a/src/main/java/org/apache/commons/math4/optim/linear/SimplexTableau.java b/src/main/java/org/apache/commons/math4/optim/linear/SimplexTableau.java index 7d6c8f0035..02ee6641d3 100644 --- a/src/main/java/org/apache/commons/math4/optim/linear/SimplexTableau.java +++ b/src/main/java/org/apache/commons/math4/optim/linear/SimplexTableau.java @@ -78,7 +78,7 @@ class SimplexTableau implements Serializable { private final boolean restrictToNonNegative; /** The variables each column represents */ - private final List columnLabels = new ArrayList(); + private final List columnLabels = new ArrayList<>(); /** Simple tableau. */ private transient Array2DRowRealMatrix tableau; @@ -272,7 +272,7 @@ protected Array2DRowRealMatrix createTableau(final boolean maximize) { * @return new versions of the constraints */ public List normalizeConstraints(Collection originalConstraints) { - List normalized = new ArrayList(originalConstraints.size()); + List normalized = new ArrayList<>(originalConstraints.size()); for (LinearConstraint constraint : originalConstraints) { normalized.add(normalize(constraint)); } @@ -395,7 +395,7 @@ protected void dropPhase1Objective() { return; } - final Set columnsToDrop = new TreeSet(); + final Set columnsToDrop = new TreeSet<>(); columnsToDrop.add(0); // positive cost non-artificial variables @@ -469,7 +469,7 @@ protected PointValuePair getSolution() { Integer negativeVarBasicRow = negativeVarColumn > 0 ? getBasicRow(negativeVarColumn) : null; double mostNegative = negativeVarBasicRow == null ? 0 : getEntry(negativeVarBasicRow, getRhsOffset()); - final Set usedBasicRows = new HashSet(); + final Set usedBasicRows = new HashSet<>(); final double[] coefficients = new double[getOriginalNumDecisionVariables()]; for (int i = 0; i < coefficients.length; i++) { int colIndex = columnLabels.indexOf("x" + i); diff --git a/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizer.java b/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizer.java index d059868310..49bf465c87 100644 --- a/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizer.java +++ b/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizer.java @@ -41,7 +41,7 @@ public class MultiStartMultivariateOptimizer /** Underlying optimizer. */ private final MultivariateOptimizer optimizer; /** Found optima. */ - private final List optima = new ArrayList(); + private final List optima = new ArrayList<>(); /** * Create a multi-start optimizer from a single-start optimizer. diff --git a/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java b/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java index 727fd18481..2a62609659 100644 --- a/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java +++ b/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java @@ -199,13 +199,13 @@ public class CMAESOptimizer private final RandomGenerator random; /** History of sigma values. */ - private final List statisticsSigmaHistory = new ArrayList(); + private final List statisticsSigmaHistory = new ArrayList<>(); /** History of mean matrix. */ - private final List statisticsMeanHistory = new ArrayList(); + private final List statisticsMeanHistory = new ArrayList<>(); /** History of fitness values. */ - private final List statisticsFitnessHistory = new ArrayList(); + private final List statisticsFitnessHistory = new ArrayList<>(); /** History of D matrix. */ - private final List statisticsDHistory = new ArrayList(); + private final List statisticsDHistory = new ArrayList<>(); /** * @param maxIterations Maximal number of iterations. diff --git a/src/main/java/org/apache/commons/math4/primes/SmallPrimes.java b/src/main/java/org/apache/commons/math4/primes/SmallPrimes.java index 0738cd2490..6f329e3c4c 100644 --- a/src/main/java/org/apache/commons/math4/primes/SmallPrimes.java +++ b/src/main/java/org/apache/commons/math4/primes/SmallPrimes.java @@ -125,7 +125,7 @@ public static int boundedTrialDivision(int n, int maxFactor, List facto * @return the list of prime factors of n */ public static List trialDivision(int n){ - final List factors = new ArrayList(32); + final List factors = new ArrayList<>(32); n = smallTrialDivision(n, factors); if (1 == n) { return factors; diff --git a/src/main/java/org/apache/commons/math4/random/EmpiricalDistribution.java b/src/main/java/org/apache/commons/math4/random/EmpiricalDistribution.java index 6d2722e133..f774ce386f 100644 --- a/src/main/java/org/apache/commons/math4/random/EmpiricalDistribution.java +++ b/src/main/java/org/apache/commons/math4/random/EmpiricalDistribution.java @@ -195,7 +195,7 @@ private EmpiricalDistribution(int binCount, } this.binCount = binCount; this.randomData = randomData; - binStats = new ArrayList(); + binStats = new ArrayList<>(); } /** diff --git a/src/main/java/org/apache/commons/math4/stat/Frequency.java b/src/main/java/org/apache/commons/math4/stat/Frequency.java index d032c75dd6..f6767200b3 100644 --- a/src/main/java/org/apache/commons/math4/stat/Frequency.java +++ b/src/main/java/org/apache/commons/math4/stat/Frequency.java @@ -74,7 +74,7 @@ public class Frequency implements Serializable { * Default constructor. */ public Frequency() { - freqTable = new TreeMap, Long>(); + freqTable = new TreeMap<>(); } /** @@ -84,7 +84,7 @@ public Frequency() { */ @SuppressWarnings("unchecked") // TODO is the cast OK? public Frequency(Comparator comparator) { - freqTable = new TreeMap, Long>((Comparator>) comparator); + freqTable = new TreeMap<>((Comparator>) comparator); } /** @@ -574,7 +574,7 @@ public List> getMode() { } } - List> modeList = new ArrayList>(); + List> modeList = new ArrayList<>(); for (Entry, Long> ent : freqTable.entrySet()) { long frequency = ent.getValue().longValue(); if (frequency == mostPopular) { diff --git a/src/main/java/org/apache/commons/math4/stat/correlation/KendallsCorrelation.java b/src/main/java/org/apache/commons/math4/stat/correlation/KendallsCorrelation.java index 8df17eabb0..32ed6d01f9 100644 --- a/src/main/java/org/apache/commons/math4/stat/correlation/KendallsCorrelation.java +++ b/src/main/java/org/apache/commons/math4/stat/correlation/KendallsCorrelation.java @@ -164,7 +164,7 @@ public double correlation(final double[] xArray, final double[] yArray) @SuppressWarnings("unchecked") Pair[] pairs = new Pair[n]; for (int i = 0; i < n; i++) { - pairs[i] = new Pair(xArray[i], yArray[i]); + pairs[i] = new Pair<>(xArray[i], yArray[i]); } Arrays.sort(pairs, new Comparator>() { diff --git a/src/main/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentile.java b/src/main/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentile.java index 7ba2d16aeb..c81a4d1514 100644 --- a/src/main/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentile.java +++ b/src/main/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentile.java @@ -81,7 +81,7 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic * Initial list of 5 numbers corresponding to 5 markers. NOTE:watch * out for the add methods that are overloaded */ - private final List initialFive = new FixedCapacityList(PSQUARE_CONSTANT); + private final List initialFive = new FixedCapacityList<>(PSQUARE_CONSTANT); /** * The quantile needed should be in range of 0-1. The constructor diff --git a/src/main/java/org/apache/commons/math4/stat/inference/KolmogorovSmirnovTest.java b/src/main/java/org/apache/commons/math4/stat/inference/KolmogorovSmirnovTest.java index 04296a3014..b331ff5c84 100644 --- a/src/main/java/org/apache/commons/math4/stat/inference/KolmogorovSmirnovTest.java +++ b/src/main/java/org/apache/commons/math4/stat/inference/KolmogorovSmirnovTest.java @@ -821,7 +821,7 @@ private FieldMatrix createExactH(double d, int n) } } } - return new Array2DRowFieldMatrix(BigFractionField.getInstance(), Hdata); + return new Array2DRowFieldMatrix<>(BigFractionField.getInstance(), Hdata); } /*** @@ -1181,7 +1181,7 @@ private static void fixTies(double[] x, double[] y) { * @return true if x and y together contain ties */ private static boolean hasTies(double[] x, double[] y) { - final HashSet values = new HashSet(); + final HashSet values = new HashSet<>(); for (int i = 0; i < x.length; i++) { if (!values.add(x[i])) { return true; diff --git a/src/main/java/org/apache/commons/math4/stat/inference/OneWayAnova.java b/src/main/java/org/apache/commons/math4/stat/inference/OneWayAnova.java index 90f4e9680a..5afaa4a703 100644 --- a/src/main/java/org/apache/commons/math4/stat/inference/OneWayAnova.java +++ b/src/main/java/org/apache/commons/math4/stat/inference/OneWayAnova.java @@ -195,7 +195,7 @@ private AnovaStats anovaStats(final Collection categoryData) MathUtils.checkNotNull(categoryData); final Collection categoryDataSummaryStatistics = - new ArrayList(categoryData.size()); + new ArrayList<>(categoryData.size()); // convert arrays to SummaryStatistics for (final double[] data : categoryData) { diff --git a/src/main/java/org/apache/commons/math4/stat/ranking/NaturalRanking.java b/src/main/java/org/apache/commons/math4/stat/ranking/NaturalRanking.java index d6efc09e69..e301959880 100644 --- a/src/main/java/org/apache/commons/math4/stat/ranking/NaturalRanking.java +++ b/src/main/java/org/apache/commons/math4/stat/ranking/NaturalRanking.java @@ -230,7 +230,7 @@ public double[] rank(double[] data) { double[] out = new double[ranks.length]; int pos = 1; // position in sorted array out[ranks[0].getPosition()] = pos; - List tiesTrace = new ArrayList(); + List tiesTrace = new ArrayList<>(); tiesTrace.add(ranks[0].getPosition()); for (int i = 1; i < ranks.length; i++) { if (Double.compare(ranks[i].getValue(), ranks[i - 1].getValue()) > 0) { @@ -239,7 +239,7 @@ public double[] rank(double[] data) { if (tiesTrace.size() > 1) { // if seq is nontrivial, resolve resolveTie(out, tiesTrace); } - tiesTrace = new ArrayList(); + tiesTrace = new ArrayList<>(); tiesTrace.add(ranks[i].getPosition()); } else { // tie sequence continues @@ -410,7 +410,7 @@ private void restoreNaNs(double[] ranks, List nanPositions) { * @return list of indexes i such that ranks[i] = NaN */ private List getNanPositions(IntDoublePair[] ranks) { - ArrayList out = new ArrayList(); + ArrayList out = new ArrayList<>(); for (int i = 0; i < ranks.length; i++) { if (Double.isNaN(ranks[i].getValue())) { out.add(Integer.valueOf(i)); diff --git a/src/main/java/org/apache/commons/math4/util/CombinatoricsUtils.java b/src/main/java/org/apache/commons/math4/util/CombinatoricsUtils.java index 08a9829cb8..0594deef53 100644 --- a/src/main/java/org/apache/commons/math4/util/CombinatoricsUtils.java +++ b/src/main/java/org/apache/commons/math4/util/CombinatoricsUtils.java @@ -43,7 +43,7 @@ public final class CombinatoricsUtils { 6402373705728000l, 121645100408832000l, 2432902008176640000l }; /** Stirling numbers of the second kind. */ - static final AtomicReference STIRLING_S2 = new AtomicReference (null); + static final AtomicReference STIRLING_S2 = new AtomicReference<> (null); /** * Default implementation of {@link #factorialLog(int)} method: diff --git a/src/main/java/org/apache/commons/math4/util/IterationManager.java b/src/main/java/org/apache/commons/math4/util/IterationManager.java index 4437a8f1a0..550bd2582e 100644 --- a/src/main/java/org/apache/commons/math4/util/IterationManager.java +++ b/src/main/java/org/apache/commons/math4/util/IterationManager.java @@ -43,7 +43,7 @@ public class IterationManager { */ public IterationManager(final int maxIterations) { this.iterations = new Incrementor(maxIterations); - this.listeners = new CopyOnWriteArrayList(); + this.listeners = new CopyOnWriteArrayList<>(); } /** @@ -58,7 +58,7 @@ public IterationManager(final int maxIterations) { public IterationManager(final int maxIterations, final Incrementor.MaxCountExceededCallback callBack) { this.iterations = new Incrementor(maxIterations, callBack); - this.listeners = new CopyOnWriteArrayList(); + this.listeners = new CopyOnWriteArrayList<>(); } /** diff --git a/src/main/java/org/apache/commons/math4/util/MathArrays.java b/src/main/java/org/apache/commons/math4/util/MathArrays.java index c50f44c25c..8c850db11b 100644 --- a/src/main/java/org/apache/commons/math4/util/MathArrays.java +++ b/src/main/java/org/apache/commons/math4/util/MathArrays.java @@ -844,7 +844,7 @@ public static void sortInPlace(double[] x, // Associate each abscissa "x[i]" with its index "i". final List list - = new ArrayList(len); + = new ArrayList<>(len); for (int i = 0; i < len; i++) { list.add(new PairDoubleInteger(x[i], i)); } @@ -1921,7 +1921,7 @@ public static double[] concatenate(double[] ...x) { * @since 3.6 */ public static double[] unique(double[] data) { - TreeSet values = new TreeSet(); + TreeSet values = new TreeSet<>(); for (int i = 0; i < data.length; i++) { values.add(data[i]); } diff --git a/src/main/java/org/apache/commons/math4/util/Pair.java b/src/main/java/org/apache/commons/math4/util/Pair.java index 487cdced6f..f56de9b952 100644 --- a/src/main/java/org/apache/commons/math4/util/Pair.java +++ b/src/main/java/org/apache/commons/math4/util/Pair.java @@ -151,6 +151,6 @@ public String toString() { * @since 3.3 */ public static Pair create(K k, V v) { - return new Pair(k, v); + return new Pair<>(k, v); } } diff --git a/src/main/java/org/apache/commons/math4/util/TransformerMap.java b/src/main/java/org/apache/commons/math4/util/TransformerMap.java index 374b9f6f22..78bb86c65c 100644 --- a/src/main/java/org/apache/commons/math4/util/TransformerMap.java +++ b/src/main/java/org/apache/commons/math4/util/TransformerMap.java @@ -49,7 +49,7 @@ public class TransformerMap implements NumberTransformer, Serializable { * Build a map containing only the default transformer. */ public TransformerMap() { - map = new HashMap, NumberTransformer>(); + map = new HashMap<>(); defaultTransformer = new DefaultTransformer(); } diff --git a/src/test/java/org/apache/commons/math4/analysis/differentiation/DSCompilerTest.java b/src/test/java/org/apache/commons/math4/analysis/differentiation/DSCompilerTest.java index e54d7a3e07..4284505414 100644 --- a/src/test/java/org/apache/commons/math4/analysis/differentiation/DSCompilerTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/differentiation/DSCompilerTest.java @@ -155,7 +155,7 @@ public void testSymmetry() { @Test public void testMultiplicationRules() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { - Map referenceRules = new HashMap(); + Map referenceRules = new HashMap<>(); referenceRules.put("(f*g)", "f * g"); referenceRules.put("d(f*g)/dx", "f * dg/dx + df/dx * g"); referenceRules.put("d(f*g)/dy", referenceRules.get("d(f*g)/dx").replaceAll("x", "y")); @@ -246,7 +246,7 @@ public void testSymmetry() { // the following reference rules have all been computed independently from the library, // using only pencil and paper and some search and replace to handle symmetries - Map referenceRules = new HashMap(); + Map referenceRules = new HashMap<>(); referenceRules.put("(f(g))", "(f(g))"); referenceRules.put("d(f(g))/dx", "d(f(g))/dg * dg/dx"); referenceRules.put("d(f(g))/dy", referenceRules.get("d(f(g))/dx").replaceAll("x", "y")); diff --git a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactoryTest.java b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactoryTest.java index 89c05de3b1..6eda1615c5 100644 --- a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactoryTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactoryTest.java @@ -51,7 +51,7 @@ public void testConcurrentCreation() throws InterruptedException, new ArrayBlockingQueue(2)); final List>> results - = new ArrayList>>(); + = new ArrayList<>(); for (int i = 0; i < numTasks; i++) { results.add(exec.submit(new RuleBuilder())); } @@ -103,7 +103,7 @@ protected Pair computeRule(int order) { p[i] = new Double(i); w[i] = new Double(i); } - return new Pair(p, w); + return new Pair<>(p, w); } public int getNumberOfCalls() { diff --git a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorTest.java b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorTest.java index 8270d3b1e9..07e067582b 100644 --- a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorTest.java @@ -34,7 +34,7 @@ public void testGetWeights() { final double[] weights = { 9.8, 7.6, 5.4 }; final GaussIntegrator integrator - = new GaussIntegrator(new Pair(points, weights)); + = new GaussIntegrator(new Pair<>(points, weights)); Assert.assertEquals(weights.length, integrator.getNumberOfPoints()); @@ -49,7 +49,7 @@ public void testGetPoints() { final double[] weights = { 9.8, 7.6, 5.4 }; final GaussIntegrator integrator - = new GaussIntegrator(new Pair(points, weights)); + = new GaussIntegrator(new Pair<>(points, weights)); Assert.assertEquals(points.length, integrator.getNumberOfPoints()); @@ -64,7 +64,7 @@ public void testIntegrate() { final double[] weights = { 1, 1, 1, 1, 1, 1 }; final GaussIntegrator integrator - = new GaussIntegrator(new Pair(points, weights)); + = new GaussIntegrator(new Pair<>(points, weights)); final double val = 123.456; final UnivariateFunction c = new Constant(val); diff --git a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/HermiteParametricTest.java b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/HermiteParametricTest.java index 8eb304fdbd..5bba84e86f 100644 --- a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/HermiteParametricTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/HermiteParametricTest.java @@ -72,7 +72,7 @@ public HermiteParametricTest(int numberOfPoints, @SuppressWarnings("boxing") // OK here @Parameters public static Collection getParameters() { - final ArrayList parameters = new ArrayList(); + final ArrayList parameters = new ArrayList<>(); for (int k = 1; k <= MAX_NUM_POINTS; k++) { parameters.add(new Object[] { k, 2 * k - 1, Math.ulp(1d), 195 }); } diff --git a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionParametricTest.java b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionParametricTest.java index 976488fd3f..896f8e09bb 100644 --- a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionParametricTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionParametricTest.java @@ -70,7 +70,7 @@ public LegendreHighPrecisionParametricTest(int numberOfPoints, @SuppressWarnings("boxing") // OK here @Parameters public static Collection getParameters() { - final ArrayList parameters = new ArrayList(); + final ArrayList parameters = new ArrayList<>(); for (int k = 1; k <= MAX_NUM_POINTS; k++) { parameters.add(new Object[] { k, 2 * k - 1, Math.ulp(1d), 13d }); } diff --git a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreParametricTest.java b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreParametricTest.java index 3f0fc63951..812611194d 100644 --- a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreParametricTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreParametricTest.java @@ -70,7 +70,7 @@ public LegendreParametricTest(int numberOfPoints, @SuppressWarnings("boxing") // OK here @Parameters public static Collection getParameters() { - final ArrayList parameters = new ArrayList(); + final ArrayList parameters = new ArrayList<>(); for (int k = 1; k <= MAX_NUM_POINTS; k++) { parameters.add(new Object[] { k, 2 * k - 1, Math.ulp(1d), 91d }); } diff --git a/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java b/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java index 1e5b031f8c..33fab5de94 100644 --- a/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java @@ -33,7 +33,7 @@ public class FieldHermiteInterpolatorTest { @Test public void testZero() { - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); interpolator.addSamplePoint(new BigFraction(0), new BigFraction[] { new BigFraction(0) }); for (int x = -10; x < 10; x++) { BigFraction y = interpolator.value(new BigFraction(x))[0]; @@ -46,7 +46,7 @@ public void testZero() { @Test public void testQuadratic() { - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); interpolator.addSamplePoint(new BigFraction(0), new BigFraction[] { new BigFraction(2) }); interpolator.addSamplePoint(new BigFraction(1), new BigFraction[] { new BigFraction(0) }); interpolator.addSamplePoint(new BigFraction(2), new BigFraction[] { new BigFraction(0) }); @@ -63,7 +63,7 @@ public void testQuadratic() { @Test public void testMixedDerivatives() { - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); interpolator.addSamplePoint(new BigFraction(0), new BigFraction[] { new BigFraction(1) }, new BigFraction[] { new BigFraction(2) }); interpolator.addSamplePoint(new BigFraction(1), new BigFraction[] { new BigFraction(4) }); interpolator.addSamplePoint(new BigFraction(2), new BigFraction[] { new BigFraction(5) }, new BigFraction[] { new BigFraction(2) }); @@ -107,7 +107,7 @@ public void testRandomPolynomialsValuesOnly() { DfpField field = new DfpField(30); Dfp step = field.getOne().divide(field.newDfp(10)); - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); for (int j = 0; j < 1 + maxDegree; ++j) { Dfp x = field.newDfp(j).multiply(step); Dfp[] values = new Dfp[p.length]; @@ -151,7 +151,7 @@ public void testRandomPolynomialsFirstDerivative() { DfpField field = new DfpField(30); Dfp step = field.getOne().divide(field.newDfp(10)); - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); for (int j = 0; j < 1 + maxDegree / 2; ++j) { Dfp x = field.newDfp(j).multiply(step); Dfp[] values = new Dfp[p.length]; @@ -186,7 +186,7 @@ public void testRandomPolynomialsFirstDerivative() { @Test public void testSine() { DfpField field = new DfpField(30); - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); for (Dfp x = field.getZero(); x.getReal() < FastMath.PI; x = x.add(0.5)) { interpolator.addSamplePoint(x, new Dfp[] { x.sin() }); } @@ -199,7 +199,7 @@ public void testSine() { @Test public void testSquareRoot() { DfpField field = new DfpField(30); - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); for (Dfp x = field.getOne(); x.getReal() < 3.6; x = x.add(0.5)) { interpolator.addSamplePoint(x, new Dfp[] { x.sqrt() }); } @@ -213,7 +213,7 @@ public void testSquareRoot() { public void testWikipedia() { // this test corresponds to the example from Wikipedia page: // http://en.wikipedia.org/wiki/Hermite_interpolation - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); interpolator.addSamplePoint(new BigFraction(-1), new BigFraction[] { new BigFraction( 2) }, new BigFraction[] { new BigFraction(-8) }, @@ -237,7 +237,7 @@ public void testWikipedia() { @Test public void testOnePointParabola() { - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); interpolator.addSamplePoint(new BigFraction(0), new BigFraction[] { new BigFraction(1) }, new BigFraction[] { new BigFraction(1) }, @@ -268,7 +268,7 @@ public void testEmptySampleDerivative() { @Test(expected=MathIllegalArgumentException.class) public void testDuplicatedAbscissa() { - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); interpolator.addSamplePoint(new BigFraction(1), new BigFraction[] { new BigFraction(0) }); interpolator.addSamplePoint(new BigFraction(1), new BigFraction[] { new BigFraction(1) }); } diff --git a/src/test/java/org/apache/commons/math4/analysis/solvers/FieldBracketingNthOrderBrentSolverTest.java b/src/test/java/org/apache/commons/math4/analysis/solvers/FieldBracketingNthOrderBrentSolverTest.java index a1d5587f79..d50e06c07f 100644 --- a/src/test/java/org/apache/commons/math4/analysis/solvers/FieldBracketingNthOrderBrentSolverTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/solvers/FieldBracketingNthOrderBrentSolverTest.java @@ -36,14 +36,14 @@ public final class FieldBracketingNthOrderBrentSolverTest { @Test(expected=NumberIsTooSmallException.class) public void testInsufficientOrder3() { - new FieldBracketingNthOrderBrentSolver(relativeAccuracy, absoluteAccuracy, + new FieldBracketingNthOrderBrentSolver<>(relativeAccuracy, absoluteAccuracy, functionValueAccuracy, 1); } @Test public void testConstructorOK() { FieldBracketingNthOrderBrentSolver solver = - new FieldBracketingNthOrderBrentSolver(relativeAccuracy, absoluteAccuracy, + new FieldBracketingNthOrderBrentSolver<>(relativeAccuracy, absoluteAccuracy, functionValueAccuracy, 2); Assert.assertEquals(2, solver.getMaximalOrder()); } @@ -51,7 +51,7 @@ public void testConstructorOK() { @Test public void testConvergenceOnFunctionAccuracy() { FieldBracketingNthOrderBrentSolver solver = - new FieldBracketingNthOrderBrentSolver(relativeAccuracy, absoluteAccuracy, + new FieldBracketingNthOrderBrentSolver<>(relativeAccuracy, absoluteAccuracy, field.newDfp(1.0e-20), 20); RealFieldUnivariateFunction f = new RealFieldUnivariateFunction() { public Dfp value(Dfp x) { @@ -127,7 +127,7 @@ public Dfp value(Dfp x) { private void check(RealFieldUnivariateFunction f, int maxEval, double min, double max, AllowedSolution allowedSolution) { FieldBracketingNthOrderBrentSolver solver = - new FieldBracketingNthOrderBrentSolver(relativeAccuracy, absoluteAccuracy, + new FieldBracketingNthOrderBrentSolver<>(relativeAccuracy, absoluteAccuracy, functionValueAccuracy, 20); Dfp xResult = solver.solve(maxEval, f, field.newDfp(min), field.newDfp(max), allowedSolution); diff --git a/src/test/java/org/apache/commons/math4/distribution/EnumeratedRealDistributionTest.java b/src/test/java/org/apache/commons/math4/distribution/EnumeratedRealDistributionTest.java index f1cf6521d3..f903cbc3f7 100644 --- a/src/test/java/org/apache/commons/math4/distribution/EnumeratedRealDistributionTest.java +++ b/src/test/java/org/apache/commons/math4/distribution/EnumeratedRealDistributionTest.java @@ -192,10 +192,10 @@ public void testSample() { @Test public void testIssue942() { - List> list = new ArrayList>(); + List> list = new ArrayList<>(); list.add(new Pair(new Object() {}, new Double(0))); list.add(new Pair(new Object() {}, new Double(1))); - Assert.assertEquals(1, new EnumeratedDistribution(list).sample(1).length); + Assert.assertEquals(1, new EnumeratedDistribution<>(list).sample(1).length); } @Test diff --git a/src/test/java/org/apache/commons/math4/distribution/MultivariateNormalMixtureModelDistributionTest.java b/src/test/java/org/apache/commons/math4/distribution/MultivariateNormalMixtureModelDistributionTest.java index 8bed770001..aedaba0e76 100644 --- a/src/test/java/org/apache/commons/math4/distribution/MultivariateNormalMixtureModelDistributionTest.java +++ b/src/test/java/org/apache/commons/math4/distribution/MultivariateNormalMixtureModelDistributionTest.java @@ -151,12 +151,12 @@ private MultivariateNormalMixtureModelDistribution create(double[] weights, double[][] means, double[][][] covariances) { final List> mvns - = new ArrayList>(); + = new ArrayList<>(); for (int i = 0; i < weights.length; i++) { final MultivariateNormalDistribution dist = new MultivariateNormalDistribution(means[i], covariances[i]); - mvns.add(new Pair(weights[i], dist)); + mvns.add(new Pair<>(weights[i], dist)); } return new MultivariateNormalMixtureModelDistribution(mvns); diff --git a/src/test/java/org/apache/commons/math4/distribution/RealDistributionAbstractTest.java b/src/test/java/org/apache/commons/math4/distribution/RealDistributionAbstractTest.java index 9fffeaf6a1..1a5e2109f0 100644 --- a/src/test/java/org/apache/commons/math4/distribution/RealDistributionAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/distribution/RealDistributionAbstractTest.java @@ -357,7 +357,7 @@ public double value(double x) { return distribution.density(x); } }; - final ArrayList integrationTestPoints = new ArrayList(); + final ArrayList integrationTestPoints = new ArrayList<>(); for (int i = 0; i < cumulativeTestPoints.length; i++) { if (Double.isNaN(cumulativeTestValues[i]) || cumulativeTestValues[i] < 1.0e-5 || diff --git a/src/test/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximizationTest.java b/src/test/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximizationTest.java index cb6860357d..f31f4c80dc 100644 --- a/src/test/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximizationTest.java +++ b/src/test/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximizationTest.java @@ -129,10 +129,10 @@ public void testIncompatibleIntialMixture() { // Create components and mixture List> components = - new ArrayList>(); - components.add(new Pair( + new ArrayList<>(); + components.add(new Pair<>( weights[0], mvns[0])); - components.add(new Pair( + components.add(new Pair<>( weights[1], mvns[1])); MixtureMultivariateNormalDistribution badInitialMix diff --git a/src/test/java/org/apache/commons/math4/exception/util/ArgUtilsTest.java b/src/test/java/org/apache/commons/math4/exception/util/ArgUtilsTest.java index 46ed1893ce..e7fddf6921 100644 --- a/src/test/java/org/apache/commons/math4/exception/util/ArgUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/exception/util/ArgUtilsTest.java @@ -30,7 +30,7 @@ public class ArgUtilsTest { @Test public void testFlatten() { - final List orig = new ArrayList(); + final List orig = new ArrayList<>(); final Object[] struct = new Object[] { new Object[] { diff --git a/src/test/java/org/apache/commons/math4/fitting/HarmonicCurveFitterTest.java b/src/test/java/org/apache/commons/math4/fitting/HarmonicCurveFitterTest.java index 17097f56d3..e3b1959477 100644 --- a/src/test/java/org/apache/commons/math4/fitting/HarmonicCurveFitterTest.java +++ b/src/test/java/org/apache/commons/math4/fitting/HarmonicCurveFitterTest.java @@ -170,7 +170,7 @@ public void testMath844() { 0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 3, 2, 1, 0 }; - final List points = new ArrayList(); + final List points = new ArrayList<>(); for (int i = 0; i < y.length; i++) { points.add(new WeightedObservedPoint(1, i, y[i])); } diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleProblem.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleProblem.java index 377726d7e7..016bf8bc01 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleProblem.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleProblem.java @@ -57,7 +57,7 @@ class CircleProblem { public CircleProblem(double xError, double yError, int searchResolution) { - points = new ArrayList(); + points = new ArrayList<>(); xSigma = xError; ySigma = yError; resolution = searchResolution; diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java index 3c88431fda..87a2b6f849 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java @@ -29,7 +29,7 @@ class CircleVectorial { private ArrayList points; public CircleVectorial() { - points = new ArrayList(); + points = new ArrayList<>(); } public void addPoint(double px, double py) { diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTest.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTest.java index b34dcafe2a..bffb95b8ee 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTest.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTest.java @@ -262,7 +262,7 @@ public void testLazyEvaluationPrecondition() { // "MultivariateJacobianFunction". final MultivariateJacobianFunction m1 = new MultivariateJacobianFunction() { public Pair value(RealVector notUsed) { - return new Pair(null, null); + return new Pair<>(null, null); } }; @@ -276,7 +276,7 @@ public Pair value(RealVector notUsed) { final MultivariateJacobianFunction m2 = new ValueAndJacobianFunction() { public Pair value(RealVector notUsed) { - return new Pair(null, null); + return new Pair<>(null, null); } public RealVector computeValue(final double[] params) { return null; diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTestValidation.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTestValidation.java index 6642854271..3c637aeb34 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTestValidation.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTestValidation.java @@ -232,7 +232,7 @@ public void testParametersErrorMonteCarloParameters() { // Index 0 = slope // Index 1 = offset // Index 2 = normalized chi2 - final List paramsAndChi2 = new ArrayList(gridSize * gridSize); + final List paramsAndChi2 = new ArrayList<>(gridSize * gridSize); final double slopeRange = 10 * sigma.getEntry(0); final double offsetRange = 10 * sigma.getEntry(1); diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java index 6198eb71cb..9b9c55d26f 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java @@ -360,8 +360,8 @@ private static class BevingtonProblem { private List count; public BevingtonProblem() { - time = new ArrayList(); - count = new ArrayList(); + time = new ArrayList<>(); + count = new ArrayList<>(); } public void addPoint(double t, double c) { diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/StatisticalReferenceDataset.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/StatisticalReferenceDataset.java index f78b318d28..08c60f7082 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/StatisticalReferenceDataset.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/StatisticalReferenceDataset.java @@ -68,7 +68,7 @@ public abstract class StatisticalReferenceDataset { public StatisticalReferenceDataset(final BufferedReader in) throws IOException { - final ArrayList lines = new ArrayList(); + final ArrayList lines = new ArrayList<>(); for (String line = in.readLine(); line != null; line = in.readLine()) { lines.add(line); } diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/StraightLineProblem.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/StraightLineProblem.java index b59e703be2..7ce8323c65 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/StraightLineProblem.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/StraightLineProblem.java @@ -46,7 +46,7 @@ class StraightLineProblem { * @param error Assumed error for the y-coordinate. */ public StraightLineProblem(double error) { - points = new ArrayList(); + points = new ArrayList<>(); sigma = error; } diff --git a/src/test/java/org/apache/commons/math4/genetics/ChromosomeTest.java b/src/test/java/org/apache/commons/math4/genetics/ChromosomeTest.java index 126d5c3987..3c1a6edb23 100644 --- a/src/test/java/org/apache/commons/math4/genetics/ChromosomeTest.java +++ b/src/test/java/org/apache/commons/math4/genetics/ChromosomeTest.java @@ -92,7 +92,7 @@ public double fitness() { } }; - List popChr = new ArrayList(); + List popChr = new ArrayList<>(); popChr.add(c1); popChr.add(c2); popChr.add(c3); diff --git a/src/test/java/org/apache/commons/math4/genetics/FitnessCachingTest.java b/src/test/java/org/apache/commons/math4/genetics/FitnessCachingTest.java index 71ae818bda..0903c49798 100644 --- a/src/test/java/org/apache/commons/math4/genetics/FitnessCachingTest.java +++ b/src/test/java/org/apache/commons/math4/genetics/FitnessCachingTest.java @@ -81,7 +81,7 @@ public void testFitnessCaching() { * Initializes a random population. */ private static ElitisticListPopulation randomPopulation() { - List popList = new LinkedList(); + List popList = new LinkedList<>(); for (int i=0; i popList = new LinkedList(); + List popList = new LinkedList<>(); for (int i=0; i sequence = new ArrayList(); + private static final List sequence = new ArrayList<>(); static { for (int i=0; i popList = new ArrayList(); + List popList = new ArrayList<>(); for (int i=0; i chromosomes = new ArrayList (); + ArrayList chromosomes = new ArrayList<> (); chromosomes.add(c1); chromosomes.add(c2); chromosomes.add(c3); @@ -67,7 +67,7 @@ public Population nextGeneration() { @Test public void testChromosomes() { - final ArrayList chromosomes = new ArrayList (); + final ArrayList chromosomes = new ArrayList<> (); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); @@ -112,7 +112,7 @@ public Population nextGeneration() { @Test(expected = NotPositiveException.class) public void testChromosomeListConstructorPopulationLimitNotPositive() { - final ArrayList chromosomes = new ArrayList (); + final ArrayList chromosomes = new ArrayList<> (); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); new ListPopulation(chromosomes, -10) { public Population nextGeneration() { @@ -124,7 +124,7 @@ public Population nextGeneration() { @Test(expected = NumberIsTooLargeException.class) public void testConstructorListOfChromosomesBiggerThanPopulationSize() { - final ArrayList chromosomes = new ArrayList (); + final ArrayList chromosomes = new ArrayList<> (); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); @@ -138,7 +138,7 @@ public Population nextGeneration() { @Test(expected=NumberIsTooLargeException.class) public void testAddTooManyChromosomes() { - final ArrayList chromosomes = new ArrayList (); + final ArrayList chromosomes = new ArrayList<> (); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); @@ -170,7 +170,7 @@ public Population nextGeneration() { @Test(expected = UnsupportedOperationException.class) public void testIterator() { - final ArrayList chromosomes = new ArrayList(); + final ArrayList chromosomes = new ArrayList<>(); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); @@ -193,7 +193,7 @@ public Population nextGeneration() { @Test(expected=NumberIsTooSmallException.class) public void testSetPopulationLimitTooSmall() { - final ArrayList chromosomes = new ArrayList (); + final ArrayList chromosomes = new ArrayList<> (); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); diff --git a/src/test/java/org/apache/commons/math4/genetics/NPointCrossoverTest.java b/src/test/java/org/apache/commons/math4/genetics/NPointCrossoverTest.java index 4f05d81b3f..2a1231f2e5 100644 --- a/src/test/java/org/apache/commons/math4/genetics/NPointCrossoverTest.java +++ b/src/test/java/org/apache/commons/math4/genetics/NPointCrossoverTest.java @@ -94,7 +94,7 @@ public void testCrossover() { BinaryChromosome p2c = new DummyBinaryChromosome(p2); final int order = 3; - NPointCrossover npc = new NPointCrossover(order); + NPointCrossover npc = new NPointCrossover<>(order); // the two parent chromosomes are different at each position, so it is easy to detect // the number of crossovers that happened for each child diff --git a/src/test/java/org/apache/commons/math4/genetics/OnePointCrossoverTest.java b/src/test/java/org/apache/commons/math4/genetics/OnePointCrossoverTest.java index 6f431e2cf3..482aad007f 100644 --- a/src/test/java/org/apache/commons/math4/genetics/OnePointCrossoverTest.java +++ b/src/test/java/org/apache/commons/math4/genetics/OnePointCrossoverTest.java @@ -34,7 +34,7 @@ public void testCrossover() { BinaryChromosome p1c = new DummyBinaryChromosome(p1); BinaryChromosome p2c = new DummyBinaryChromosome(p2); - OnePointCrossover opc = new OnePointCrossover(); + OnePointCrossover opc = new OnePointCrossover<>(); // how to test a stochastic method? for (int i=0; i<20; i++) { diff --git a/src/test/java/org/apache/commons/math4/genetics/OrderedCrossoverTest.java b/src/test/java/org/apache/commons/math4/genetics/OrderedCrossoverTest.java index 9379da1ce2..2290fabdb9 100644 --- a/src/test/java/org/apache/commons/math4/genetics/OrderedCrossoverTest.java +++ b/src/test/java/org/apache/commons/math4/genetics/OrderedCrossoverTest.java @@ -42,8 +42,8 @@ public void testCrossover() { final CrossoverPolicy cp = new OrderedCrossover(); for (int i = 0; i < 20; i++) { - final Set parentSet1 = new HashSet(Arrays.asList(p1)); - final Set parentSet2 = new HashSet(Arrays.asList(p2)); + final Set parentSet1 = new HashSet<>(Arrays.asList(p1)); + final Set parentSet2 = new HashSet<>(Arrays.asList(p2)); final ChromosomePair pair = cp.crossover(p1c, p2c); diff --git a/src/test/java/org/apache/commons/math4/genetics/UniformCrossoverTest.java b/src/test/java/org/apache/commons/math4/genetics/UniformCrossoverTest.java index 45e2a2b295..73c6052dc7 100644 --- a/src/test/java/org/apache/commons/math4/genetics/UniformCrossoverTest.java +++ b/src/test/java/org/apache/commons/math4/genetics/UniformCrossoverTest.java @@ -33,8 +33,8 @@ public class UniformCrossoverTest { private static final int LEN = 10000; - private static final List p1 = new ArrayList(LEN); - private static final List p2 = new ArrayList(LEN); + private static final List p1 = new ArrayList<>(LEN); + private static final List p2 = new ArrayList<>(LEN); @SuppressWarnings("boxing") @BeforeClass diff --git a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java index 3729574e60..f0daa4cfe1 100644 --- a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java @@ -37,7 +37,7 @@ public class WelzlEncloser2DTest { public void testNullList() { DiskGenerator generator = new DiskGenerator(); WelzlEncloser encloser = - new WelzlEncloser(1.0e-10, generator); + new WelzlEncloser<>(1.0e-10, generator); EnclosingBall ball = encloser.enclose(null); Assert.assertTrue(ball.getRadius() < 0); } @@ -46,7 +46,7 @@ public void testNullList() { public void testNoPoints() { DiskGenerator generator = new DiskGenerator(); WelzlEncloser encloser = - new WelzlEncloser(1.0e-10, generator); + new WelzlEncloser<>(1.0e-10, generator); EnclosingBall ball = encloser.enclose(new ArrayList()); Assert.assertTrue(ball.getRadius() < 0); } @@ -87,7 +87,7 @@ public void testLargeSamples() { RandomGenerator random = new Well1024a(0xa2a63cad12c01fb2l); for (int k = 0; k < 100; ++k) { int nbPoints = random.nextInt(10000); - List points = new ArrayList(); + List points = new ArrayList<>(); for (int i = 0; i < nbPoints; ++i) { double x = random.nextDouble(); double y = random.nextDouble(); @@ -98,7 +98,7 @@ public void testLargeSamples() { } private List buildList(final double ... coordinates) { - List list = new ArrayList(coordinates.length / 2); + List list = new ArrayList<>(coordinates.length / 2); for (int i = 0; i < coordinates.length; i += 2) { list.add(new Vector2D(coordinates[i], coordinates[i + 1])); } @@ -129,7 +129,7 @@ private void checkDisk(List points, List refSupport) { // check removing any point of the support disk fails to enclose the point for (int i = 0; i < disk.getSupportSize(); ++i) { - List reducedSupport = new ArrayList(); + List reducedSupport = new ArrayList<>(); int count = 0; for (Vector2D s : disk.getSupport()) { if (count++ != i) { @@ -151,7 +151,7 @@ private void checkDisk(List points, List refSupport) { private EnclosingBall checkDisk(List points) { WelzlEncloser encloser = - new WelzlEncloser(1.0e-10, new DiskGenerator()); + new WelzlEncloser<>(1.0e-10, new DiskGenerator()); EnclosingBall disk = encloser.enclose(points); // all points are enclosed diff --git a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java index aaa4c43466..f8ef012f18 100644 --- a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java @@ -39,7 +39,7 @@ public class WelzlEncloser3DTest { public void testNullList() { SphereGenerator generator = new SphereGenerator(); WelzlEncloser encloser = - new WelzlEncloser(1.0e-10, generator); + new WelzlEncloser<>(1.0e-10, generator); EnclosingBall ball = encloser.enclose(null); Assert.assertTrue(ball.getRadius() < 0); } @@ -48,7 +48,7 @@ public void testNullList() { public void testNoPoints() { SphereGenerator generator = new SphereGenerator(); WelzlEncloser encloser = - new WelzlEncloser(1.0e-10, generator); + new WelzlEncloser<>(1.0e-10, generator); EnclosingBall ball = encloser.enclose(new ArrayList()); Assert.assertTrue(ball.getRadius() < 0); } @@ -68,7 +68,7 @@ public void testReducingBall() { new Vector3D(-7.140322188726825, -16.574152894557717, 11.710305611121410), new Vector3D(-7.141116131477088, -16.574061164624560, 11.712938509321699)); WelzlEncloser encloser = - new WelzlEncloser(1.0e-10, new SphereGenerator()); + new WelzlEncloser<>(1.0e-10, new SphereGenerator()); EnclosingBall ball = encloser.enclose(list); Assert.assertTrue(ball.getRadius() > 0); } @@ -97,7 +97,7 @@ public void testInfiniteLoop() { new Vector3D( -0.98034899533935820, -3.34004481162763960, 13.03245014017556800)); WelzlEncloser encloser = - new WelzlEncloser(1.0e-10, new SphereGenerator()); + new WelzlEncloser<>(1.0e-10, new SphereGenerator()); EnclosingBall ball = encloser.enclose(list); Assert.assertTrue(ball.getRadius() > 0); } @@ -114,7 +114,7 @@ public void testLargeSamples() throws IOException { Vector3D refCenter = new Vector3D(d, new Vector3D(sr.nextVector())); // set up a large sample inside the reference sphere int nbPoints = random.nextInt(1000); - List points = new ArrayList(); + List points = new ArrayList<>(); for (int i = 0; i < nbPoints; ++i) { double r = refRadius * random.nextDouble(); points.add(new Vector3D(1.0, refCenter, r, new Vector3D(sr.nextVector()))); @@ -135,7 +135,7 @@ private void checkSphere(List points, double refRadius) { // check removing any point of the support Sphere fails to enclose the point for (int i = 0; i < sphere.getSupportSize(); ++i) { - List reducedSupport = new ArrayList(); + List reducedSupport = new ArrayList<>(); int count = 0; for (Vector3D s : sphere.getSupport()) { if (count++ != i) { @@ -158,7 +158,7 @@ private void checkSphere(List points, double refRadius) { private EnclosingBall checkSphere(List points) { WelzlEncloser encloser = - new WelzlEncloser(1.0e-10, new SphereGenerator()); + new WelzlEncloser<>(1.0e-10, new SphereGenerator()); EnclosingBall Sphere = encloser.enclose(points); // all points are enclosed diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java index a8b00dcafd..b7c839913b 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java @@ -66,7 +66,7 @@ public void testInfinite() { @Test public void testMultiple() { - RegionFactory factory = new RegionFactory(); + RegionFactory factory = new RegionFactory<>(); IntervalsSet set = (IntervalsSet) factory.intersection(factory.union(factory.difference(new IntervalsSet(1.0, 6.0, 1.0e-10), new IntervalsSet(3.0, 5.0, 1.0e-10)), diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java index 5b352eb178..d9308fdf2c 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java @@ -66,7 +66,7 @@ public void testIdentity() { @Deprecated public void testAxisAngleDeprecated() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3)); + FieldRotation r = new FieldRotation<>(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3)); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 1, 0)); checkVector(r.applyTo(createVector(0, 1, 0)), createVector(0, 0, 1)); checkVector(r.applyTo(createVector(0, 0, 1)), createVector(1, 0, 0)); @@ -75,16 +75,16 @@ public void testAxisAngleDeprecated() throws MathIllegalArgumentException { checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new FieldRotation(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3)); + new FieldRotation<>(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3)); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new FieldRotation(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI)); + r = new FieldRotation<>(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI)); checkVector(r.getAxis(), createVector(0, 0, -1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new FieldRotation(createAxis(0, 1, 0), createAngle(FastMath.PI)); + r = new FieldRotation<>(createAxis(0, 1, 0), createAngle(FastMath.PI)); checkVector(r.getAxis(), createVector(0, 1, 0)); checkAngle(r.getAngle(), FastMath.PI); @@ -95,7 +95,7 @@ public void testAxisAngleDeprecated() throws MathIllegalArgumentException { @Test public void testAxisAngleVectorOperator() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation(createAxis(10, 10, 10), + FieldRotation r = new FieldRotation<>(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3) , RotationConvention.VECTOR_OPERATOR); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 1, 0)); @@ -107,21 +107,21 @@ public void testAxisAngleVectorOperator() throws MathIllegalArgumentException { checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new FieldRotation(createAxis(0, 0, 0), + new FieldRotation<>(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3), RotationConvention.VECTOR_OPERATOR); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new FieldRotation(createAxis(0, 0, 1), + r = new FieldRotation<>(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI), RotationConvention.VECTOR_OPERATOR); checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, 0, -1)); checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, 0, +1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new FieldRotation(createAxis(0, 1, 0), + r = new FieldRotation<>(createAxis(0, 1, 0), createAngle(FastMath.PI), RotationConvention.VECTOR_OPERATOR); checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, +1, 0)); @@ -136,7 +136,7 @@ public void testAxisAngleVectorOperator() throws MathIllegalArgumentException { @Test public void testAxisAngleFrameTransform() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation(createAxis(10, 10, 10), + FieldRotation r = new FieldRotation<>(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3) , RotationConvention.FRAME_TRANSFORM); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 0, 1)); @@ -148,21 +148,21 @@ public void testAxisAngleFrameTransform() throws MathIllegalArgumentException { checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new FieldRotation(createAxis(0, 0, 0), + new FieldRotation<>(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3), RotationConvention.FRAME_TRANSFORM); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new FieldRotation(createAxis(0, 0, 1), + r = new FieldRotation<>(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI), RotationConvention.FRAME_TRANSFORM); checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, 0, -1)); checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, 0, +1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new FieldRotation(createAxis(0, 1, 0), + r = new FieldRotation<>(createAxis(0, 1, 0), createAngle(FastMath.PI), RotationConvention.FRAME_TRANSFORM); checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, +1, 0)); @@ -395,13 +395,13 @@ public void testVectorOnePair() throws MathArithmeticException { FieldVector3D u = createVector(3, 2, 1); FieldVector3D v = createVector(-4, 2, 2); - FieldRotation r = new FieldRotation(u, v); + FieldRotation r = new FieldRotation<>(u, v); checkVector(r.applyTo(u.scalarMultiply(v.getNorm())), v.scalarMultiply(u.getNorm())); - checkAngle(new FieldRotation(u, u.negate()).getAngle(), FastMath.PI); + checkAngle(new FieldRotation<>(u, u.negate()).getAngle(), FastMath.PI); try { - new FieldRotation(u, createVector(0, 0, 0)); + new FieldRotation<>(u, createVector(0, 0, 0)); Assert.fail("an exception should have been thrown"); } catch (MathArithmeticException e) { // expected behavior @@ -416,11 +416,11 @@ public void testVectorTwoPairs() throws MathArithmeticException { FieldVector3D u2 = createVector(0, 5, 0); FieldVector3D v1 = createVector(0, 0, 2); FieldVector3D v2 = createVector(-2, 0, 2); - FieldRotation r = new FieldRotation(u1, u2, v1, v2); + FieldRotation r = new FieldRotation<>(u1, u2, v1, v2); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 0, 1)); checkVector(r.applyTo(createVector(0, 1, 0)), createVector(-1, 0, 0)); - r = new FieldRotation(u1, u2, u1.negate(), u2.negate()); + r = new FieldRotation<>(u1, u2, u1.negate(), u2.negate()); FieldVector3D axis = r.getAxis(RotationConvention.VECTOR_OPERATOR); if (FieldVector3D.dotProduct(axis, createVector(0, 0, 1)).getReal() > 0) { checkVector(axis, createVector(0, 0, 1)); @@ -430,18 +430,18 @@ public void testVectorTwoPairs() throws MathArithmeticException { checkAngle(r.getAngle(), FastMath.PI); double sqrt = FastMath.sqrt(2) / 2; - r = new FieldRotation(createVector(1, 0, 0), createVector(0, 1, 0), + r = new FieldRotation<>(createVector(1, 0, 0), createVector(0, 1, 0), createVector(0.5, 0.5, sqrt), createVector(0.5, 0.5, -sqrt)); checkRotationDS(r, sqrt, 0.5, 0.5, 0); - r = new FieldRotation(u1, u2, u1, FieldVector3D.crossProduct(u1, u2)); + r = new FieldRotation<>(u1, u2, u1, FieldVector3D.crossProduct(u1, u2)); checkRotationDS(r, sqrt, -sqrt, 0, 0); - checkRotationDS(new FieldRotation(u1, u2, u1, u2), 1, 0, 0, 0); + checkRotationDS(new FieldRotation<>(u1, u2, u1, u2), 1, 0, 0, 0); try { - new FieldRotation(u1, u2, createVector(0, 0, 0), v2); + new FieldRotation<>(u1, u2, createVector(0, 0, 0), v2); Assert.fail("an exception should have been thrown"); } catch (MathArithmeticException e) { // expected behavior @@ -571,11 +571,11 @@ public void testMatrix() } checkVector(r.applyTo(createVector(1, 0, 0)), - new FieldVector3D(m3[0][0], m3[1][0], m3[2][0])); + new FieldVector3D<>(m3[0][0], m3[1][0], m3[2][0])); checkVector(r.applyTo(createVector(0, 1, 0)), - new FieldVector3D(m3[0][1], m3[1][1], m3[2][1])); + new FieldVector3D<>(m3[0][1], m3[1][1], m3[2][1])); checkVector(r.applyTo(createVector(0, 0, 1)), - new FieldVector3D(m3[0][2], m3[1][2], m3[2][2])); + new FieldVector3D<>(m3[0][2], m3[1][2], m3[2][2])); double[][] m4 = { { 1.0, 0.0, 0.0 }, { 0.0, -1.0, 0.0 }, @@ -609,7 +609,7 @@ public void testAnglesDeprecated() for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 0.3) { for (double alpha2 = -1.55; alpha2 < 1.55; alpha2 += 0.3) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 0.3) { - FieldRotation r = new FieldRotation(CardanOrders[i], + FieldRotation r = new FieldRotation<>(CardanOrders[i], new DerivativeStructure(3, 1, 0, alpha1), new DerivativeStructure(3, 1, 1, alpha2), new DerivativeStructure(3, 1, 2, alpha3)); @@ -631,7 +631,7 @@ public void testAnglesDeprecated() for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 0.3) { for (double alpha2 = 0.05; alpha2 < 3.1; alpha2 += 0.3) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 0.3) { - FieldRotation r = new FieldRotation(EulerOrders[i], + FieldRotation r = new FieldRotation<>(EulerOrders[i], new DerivativeStructure(3, 1, 0, alpha1), new DerivativeStructure(3, 1, 1, alpha2), new DerivativeStructure(3, 1, 2, alpha3)); @@ -661,7 +661,7 @@ public void testAngles() for (double alpha2 = -1.55; alpha2 < 1.55; alpha2 += 0.3) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 0.3) { FieldRotation r = - new FieldRotation(CardanOrders[i], + new FieldRotation<>(CardanOrders[i], convention, new DerivativeStructure(3, 1, 0, alpha1), new DerivativeStructure(3, 1, 1, alpha2), @@ -685,7 +685,7 @@ public void testAngles() for (double alpha2 = 0.05; alpha2 < 3.1; alpha2 += 0.3) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 0.3) { FieldRotation r = - new FieldRotation(EulerOrders[i], + new FieldRotation<>(EulerOrders[i], convention, new DerivativeStructure(3, 1, 0, alpha1), new DerivativeStructure(3, 1, 1, alpha2), @@ -715,7 +715,7 @@ public void testSingularities() { for (int i = 0; i < CardanOrders.length; ++i) { for (int j = 0; j < singularCardanAngle.length; ++j) { FieldRotation r = - new FieldRotation(CardanOrders[i], + new FieldRotation<>(CardanOrders[i], convention, new DerivativeStructure(3, 1, 0, 0.1), new DerivativeStructure(3, 1, 1, singularCardanAngle[j]), @@ -738,7 +738,7 @@ public void testSingularities() { for (int i = 0; i < EulerOrders.length; ++i) { for (int j = 0; j < singularEulerAngle.length; ++j) { FieldRotation r = - new FieldRotation(EulerOrders[i], + new FieldRotation<>(EulerOrders[i], convention, new DerivativeStructure(3, 1, 0, 0.1), new DerivativeStructure(3, 1, 1, singularEulerAngle[j]), @@ -758,11 +758,11 @@ public void testSingularities() { @Test public void testQuaternion() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); double n = 23.5; - FieldRotation r2 = new FieldRotation(r1.getQ0().multiply(n), r1.getQ1().multiply(n), + FieldRotation r2 = new FieldRotation<>(r1.getQ0().multiply(n), r1.getQ1().multiply(n), r1.getQ2().multiply(n), r1.getQ3().multiply(n), true); for (double x = -0.9; x < 0.9; x += 0.2) { @@ -788,10 +788,10 @@ public void testQuaternion() throws MathIllegalArgumentException { @Test public void testApplyToRotation() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.applyTo(r1); @@ -816,10 +816,10 @@ public void testApplyToRotation() throws MathIllegalArgumentException { @Test public void testComposeVectorOperator() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.compose(r1, RotationConvention.VECTOR_OPERATOR); @@ -845,10 +845,10 @@ public void testComposeVectorOperator() throws MathIllegalArgumentException { @Test public void testComposeFrameTransform() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.FRAME_TRANSFORM); - FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.FRAME_TRANSFORM); FieldRotation r3 = r2.compose(r1, RotationConvention.FRAME_TRANSFORM); @@ -874,10 +874,10 @@ public void testComposeFrameTransform() throws MathIllegalArgumentException { @Test public void testApplyInverseToRotation() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.applyInverseTo(r1); @@ -902,10 +902,10 @@ public void testApplyInverseToRotation() throws MathIllegalArgumentException { @Test public void testComposeInverseVectorOperator() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.composeInverse(r1, RotationConvention.VECTOR_OPERATOR); @@ -931,10 +931,10 @@ public void testComposeInverseVectorOperator() throws MathIllegalArgumentExcepti @Test public void testComposeInverseframeTransform() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.FRAME_TRANSFORM); - FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.FRAME_TRANSFORM); FieldRotation r3 = r2.composeInverse(r1, RotationConvention.FRAME_TRANSFORM); @@ -964,7 +964,7 @@ public void testDoubleVectors() throws MathIllegalArgumentException { UnitSphereRandomVectorGenerator g = new UnitSphereRandomVectorGenerator(3, random); for (int i = 0; i < 10; ++i) { double[] unit = g.nextVector(); - FieldRotation r = new FieldRotation(createVector(unit[0], unit[1], unit[2]), + FieldRotation r = new FieldRotation<>(createVector(unit[0], unit[1], unit[2]), createAngle(random.nextDouble()), RotationConvention.VECTOR_OPERATOR); @@ -982,9 +982,9 @@ public void testDoubleVectors() throws MathIllegalArgumentException { DerivativeStructure[] rIuArray = new DerivativeStructure[3]; r.applyInverseTo(new double[] { x, y, z}, rIuArray); checkVector(ruds, ru); - checkVector(ruds, new FieldVector3D(ruArray)); + checkVector(ruds, new FieldVector3D<>(ruArray)); checkVector(rIuds, rIu); - checkVector(rIuds, new FieldVector3D(rIuArray)); + checkVector(rIuds, new FieldVector3D<>(rIuArray)); } } } @@ -1001,13 +1001,13 @@ public void testDoubleRotations() throws MathIllegalArgumentException { double[] unit1 = g.nextVector(); Rotation r1 = new Rotation(new Vector3D(unit1[0], unit1[1], unit1[2]), random.nextDouble(), RotationConvention.VECTOR_OPERATOR); - FieldRotation r1Prime = new FieldRotation(new DerivativeStructure(4, 1, 0, r1.getQ0()), + FieldRotation r1Prime = new FieldRotation<>(new DerivativeStructure(4, 1, 0, r1.getQ0()), new DerivativeStructure(4, 1, 1, r1.getQ1()), new DerivativeStructure(4, 1, 2, r1.getQ2()), new DerivativeStructure(4, 1, 3, r1.getQ3()), false); double[] unit2 = g.nextVector(); - FieldRotation r2 = new FieldRotation(createVector(unit2[0], unit2[1], unit2[2]), + FieldRotation r2 = new FieldRotation<>(createVector(unit2[0], unit2[1], unit2[2]), createAngle(random.nextDouble()), RotationConvention.VECTOR_OPERATOR); @@ -1047,7 +1047,7 @@ public void testDerivatives() { double theta = 1.7; double cosTheta = FastMath.cos(theta); double sinTheta = FastMath.sin(theta); - FieldRotation r = new FieldRotation(createAxis(kx, ky, kz), + FieldRotation r = new FieldRotation<>(createAxis(kx, ky, kz), createAngle(theta), RotationConvention.VECTOR_OPERATOR); Vector3D a = new Vector3D(kx / n, ky / n, kz / n); @@ -1113,7 +1113,7 @@ public void testDerivatives() { @Test public void testArray() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation(createAxis(2, -3, 5), + FieldRotation r = new FieldRotation<>(createAxis(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); @@ -1143,7 +1143,7 @@ public void testApplyInverseTo() throws MathIllegalArgumentException { DerivativeStructure[] in = new DerivativeStructure[3]; DerivativeStructure[] out = new DerivativeStructure[3]; DerivativeStructure[] rebuilt = new DerivativeStructure[3]; - FieldRotation r = new FieldRotation(createVector(2, -3, 5), + FieldRotation r = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); for (double lambda = 0; lambda < 6.2; lambda += 0.2) { @@ -1176,7 +1176,7 @@ public void testApplyInverseTo() throws MathIllegalArgumentException { } } - r = new FieldRotation(createVector(0, 0, 1), + r = new FieldRotation<>(createVector(0, 0, 1), createAngle(FastMath.PI), RotationConvention.VECTOR_OPERATOR); for (double lambda = 0; lambda < 6.2; lambda += 0.2) { @@ -1199,7 +1199,7 @@ public void testIssue639() throws MathArithmeticException{ FieldVector3D u2 =createVector( -5712344449280879.0 / 2097152.0, -2275058564560979.0 / 1048576.0, 4423475992255071.0 / 65536.0); - FieldRotation rot = new FieldRotation(u1, u2, createVector(1, 0, 0),createVector(0, 0, 1)); + FieldRotation rot = new FieldRotation<>(u1, u2, createVector(1, 0, 0),createVector(0, 0, 1)); Assert.assertEquals( 0.6228370359608200639829222, rot.getQ0().getReal(), 1.0e-15); Assert.assertEquals( 0.0257707621456498790029987, rot.getQ1().getReal(), 1.0e-15); Assert.assertEquals(-0.0000000002503012255839931, rot.getQ2().getReal(), 1.0e-15); @@ -1214,7 +1214,7 @@ public void testIssue801() throws MathArithmeticException { FieldVector3D v1 = createVector(0.9999999999999999, 0.0, 0.0); FieldVector3D v2 = createVector(0.0, 0.0, -1.0); - FieldRotation quat = new FieldRotation(u1, u2, v1, v2); + FieldRotation quat = new FieldRotation<>(u1, u2, v1, v2); double q2 = quat.getQ0().getReal() * quat.getQ0().getReal() + quat.getQ1().getReal() * quat.getQ1().getReal() + quat.getQ2().getReal() * quat.getQ2().getReal() + @@ -1236,7 +1236,7 @@ private void checkRotationDS(FieldRotation r, double q0, do private FieldRotation createRotation(double q0, double q1, double q2, double q3, boolean needsNormalization) { - return new FieldRotation(new DerivativeStructure(4, 1, 0, q0), + return new FieldRotation<>(new DerivativeStructure(4, 1, 0, q0), new DerivativeStructure(4, 1, 1, q1), new DerivativeStructure(4, 1, 2, q2), new DerivativeStructure(4, 1, 3, q3), @@ -1252,17 +1252,17 @@ private FieldRotation createRotation(double[][] m, double t index = (index + 1) % 4; } } - return new FieldRotation(mds, threshold); + return new FieldRotation<>(mds, threshold); } private FieldVector3D createVector(double x, double y, double z) { - return new FieldVector3D(new DerivativeStructure(4, 1, x), + return new FieldVector3D<>(new DerivativeStructure(4, 1, x), new DerivativeStructure(4, 1, y), new DerivativeStructure(4, 1, z)); } private FieldVector3D createAxis(double x, double y, double z) { - return new FieldVector3D(new DerivativeStructure(4, 1, 0, x), + return new FieldVector3D<>(new DerivativeStructure(4, 1, 0, x), new DerivativeStructure(4, 1, 1, y), new DerivativeStructure(4, 1, 2, z)); } diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java index e7df1b0c67..386e6432bc 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java @@ -65,7 +65,7 @@ public void testIdentity() { @Deprecated public void testAxisAngleDeprecated() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3)); + FieldRotation r = new FieldRotation<>(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3)); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 1, 0)); checkVector(r.applyTo(createVector(0, 1, 0)), createVector(0, 0, 1)); checkVector(r.applyTo(createVector(0, 0, 1)), createVector(1, 0, 0)); @@ -74,16 +74,16 @@ public void testAxisAngleDeprecated() throws MathIllegalArgumentException { checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new FieldRotation(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3)); + new FieldRotation<>(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3)); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new FieldRotation(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI)); + r = new FieldRotation<>(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI)); checkVector(r.getAxis(), createVector(0, 0, -1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new FieldRotation(createAxis(0, 1, 0), createAngle(FastMath.PI)); + r = new FieldRotation<>(createAxis(0, 1, 0), createAngle(FastMath.PI)); checkVector(r.getAxis(), createVector(0, 1, 0)); checkAngle(r.getAngle(), FastMath.PI); @@ -94,7 +94,7 @@ public void testAxisAngleDeprecated() throws MathIllegalArgumentException { @Test public void testAxisAngleVectorOperator() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation(createAxis(10, 10, 10), + FieldRotation r = new FieldRotation<>(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3) , RotationConvention.VECTOR_OPERATOR); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 1, 0)); @@ -106,21 +106,21 @@ public void testAxisAngleVectorOperator() throws MathIllegalArgumentException { checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new FieldRotation(createAxis(0, 0, 0), + new FieldRotation<>(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3), RotationConvention.VECTOR_OPERATOR); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new FieldRotation(createAxis(0, 0, 1), + r = new FieldRotation<>(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI), RotationConvention.VECTOR_OPERATOR); checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, 0, -1)); checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, 0, +1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new FieldRotation(createAxis(0, 1, 0), + r = new FieldRotation<>(createAxis(0, 1, 0), createAngle(FastMath.PI), RotationConvention.VECTOR_OPERATOR); checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, +1, 0)); @@ -135,7 +135,7 @@ public void testAxisAngleVectorOperator() throws MathIllegalArgumentException { @Test public void testAxisAngleFrameTransform() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation(createAxis(10, 10, 10), + FieldRotation r = new FieldRotation<>(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3) , RotationConvention.FRAME_TRANSFORM); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 0, 1)); @@ -147,21 +147,21 @@ public void testAxisAngleFrameTransform() throws MathIllegalArgumentException { checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new FieldRotation(createAxis(0, 0, 0), + new FieldRotation<>(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3), RotationConvention.FRAME_TRANSFORM); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new FieldRotation(createAxis(0, 0, 1), + r = new FieldRotation<>(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI), RotationConvention.FRAME_TRANSFORM); checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, 0, -1)); checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, 0, +1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new FieldRotation(createAxis(0, 1, 0), + r = new FieldRotation<>(createAxis(0, 1, 0), createAngle(FastMath.PI), RotationConvention.FRAME_TRANSFORM); checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, +1, 0)); @@ -235,13 +235,13 @@ public void testVectorOnePair() throws MathArithmeticException { FieldVector3D u = createVector(3, 2, 1); FieldVector3D v = createVector(-4, 2, 2); - FieldRotation r = new FieldRotation(u, v); + FieldRotation r = new FieldRotation<>(u, v); checkVector(r.applyTo(u.scalarMultiply(v.getNorm())), v.scalarMultiply(u.getNorm())); - checkAngle(new FieldRotation(u, u.negate()).getAngle(), FastMath.PI); + checkAngle(new FieldRotation<>(u, u.negate()).getAngle(), FastMath.PI); try { - new FieldRotation(u, createVector(0, 0, 0)); + new FieldRotation<>(u, createVector(0, 0, 0)); Assert.fail("an exception should have been thrown"); } catch (MathArithmeticException e) { // expected behavior @@ -256,11 +256,11 @@ public void testVectorTwoPairs() throws MathArithmeticException { FieldVector3D u2 = createVector(0, 5, 0); FieldVector3D v1 = createVector(0, 0, 2); FieldVector3D v2 = createVector(-2, 0, 2); - FieldRotation r = new FieldRotation(u1, u2, v1, v2); + FieldRotation r = new FieldRotation<>(u1, u2, v1, v2); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 0, 1)); checkVector(r.applyTo(createVector(0, 1, 0)), createVector(-1, 0, 0)); - r = new FieldRotation(u1, u2, u1.negate(), u2.negate()); + r = new FieldRotation<>(u1, u2, u1.negate(), u2.negate()); FieldVector3D axis = r.getAxis(RotationConvention.VECTOR_OPERATOR); if (FieldVector3D.dotProduct(axis, createVector(0, 0, 1)).getReal() > 0) { checkVector(axis, createVector(0, 0, 1)); @@ -270,18 +270,18 @@ public void testVectorTwoPairs() throws MathArithmeticException { checkAngle(r.getAngle(), FastMath.PI); double sqrt = FastMath.sqrt(2) / 2; - r = new FieldRotation(createVector(1, 0, 0), createVector(0, 1, 0), + r = new FieldRotation<>(createVector(1, 0, 0), createVector(0, 1, 0), createVector(0.5, 0.5, sqrt), createVector(0.5, 0.5, -sqrt)); checkRotationDS(r, sqrt, 0.5, 0.5, 0); - r = new FieldRotation(u1, u2, u1, FieldVector3D.crossProduct(u1, u2)); + r = new FieldRotation<>(u1, u2, u1, FieldVector3D.crossProduct(u1, u2)); checkRotationDS(r, sqrt, -sqrt, 0, 0); - checkRotationDS(new FieldRotation(u1, u2, u1, u2), 1, 0, 0, 0); + checkRotationDS(new FieldRotation<>(u1, u2, u1, u2), 1, 0, 0, 0); try { - new FieldRotation(u1, u2, createVector(0, 0, 0), v2); + new FieldRotation<>(u1, u2, createVector(0, 0, 0), v2); Assert.fail("an exception should have been thrown"); } catch (MathArithmeticException e) { // expected behavior @@ -411,11 +411,11 @@ public void testMatrix() } checkVector(r.applyTo(createVector(1, 0, 0)), - new FieldVector3D(m3[0][0], m3[1][0], m3[2][0])); + new FieldVector3D<>(m3[0][0], m3[1][0], m3[2][0])); checkVector(r.applyTo(createVector(0, 1, 0)), - new FieldVector3D(m3[0][1], m3[1][1], m3[2][1])); + new FieldVector3D<>(m3[0][1], m3[1][1], m3[2][1])); checkVector(r.applyTo(createVector(0, 0, 1)), - new FieldVector3D(m3[0][2], m3[1][2], m3[2][2])); + new FieldVector3D<>(m3[0][2], m3[1][2], m3[2][2])); double[][] m4 = { { 1.0, 0.0, 0.0 }, { 0.0, -1.0, 0.0 }, @@ -451,7 +451,7 @@ public void testAnglesDeprecated() for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 2.0) { for (double alpha2 = -1.55; alpha2 < 1.55; alpha2 += 0.8) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 2.0) { - FieldRotation r = new FieldRotation(CardanOrders[i], + FieldRotation r = new FieldRotation<>(CardanOrders[i], field.newDfp(alpha1), field.newDfp(alpha2), field.newDfp(alpha3)); @@ -473,7 +473,7 @@ public void testAnglesDeprecated() for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 2.0) { for (double alpha2 = 0.05; alpha2 < 3.1; alpha2 += 0.8) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 2.0) { - FieldRotation r = new FieldRotation(EulerOrders[i], + FieldRotation r = new FieldRotation<>(EulerOrders[i], field.newDfp(alpha1), field.newDfp(alpha2), field.newDfp(alpha3)); @@ -504,7 +504,7 @@ public void testAngles() for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 2.0) { for (double alpha2 = -1.55; alpha2 < 1.55; alpha2 += 0.8) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 2.0) { - FieldRotation r = new FieldRotation(CardanOrders[i], + FieldRotation r = new FieldRotation<>(CardanOrders[i], convention, field.newDfp(alpha1), field.newDfp(alpha2), @@ -527,7 +527,7 @@ public void testAngles() for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 2.0) { for (double alpha2 = 0.05; alpha2 < 3.1; alpha2 += 0.8) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 2.0) { - FieldRotation r = new FieldRotation(EulerOrders[i], + FieldRotation r = new FieldRotation<>(EulerOrders[i], convention, field.newDfp(alpha1), field.newDfp(alpha2), @@ -557,7 +557,7 @@ public void testSingularities() { double[] singularCardanAngle = { FastMath.PI / 2, -FastMath.PI / 2 }; for (int i = 0; i < CardanOrders.length; ++i) { for (int j = 0; j < singularCardanAngle.length; ++j) { - FieldRotation r = new FieldRotation(CardanOrders[i], + FieldRotation r = new FieldRotation<>(CardanOrders[i], convention, field.newDfp(0.1), field.newDfp(singularCardanAngle[j]), @@ -579,7 +579,7 @@ public void testSingularities() { double[] singularEulerAngle = { 0, FastMath.PI }; for (int i = 0; i < EulerOrders.length; ++i) { for (int j = 0; j < singularEulerAngle.length; ++j) { - FieldRotation r = new FieldRotation(EulerOrders[i], + FieldRotation r = new FieldRotation<>(EulerOrders[i], convention, field.newDfp(0.1), field.newDfp(singularEulerAngle[j]), @@ -599,11 +599,11 @@ public void testSingularities() { @Test public void testQuaternion() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); double n = 23.5; - FieldRotation r2 = new FieldRotation(r1.getQ0().multiply(n), r1.getQ1().multiply(n), + FieldRotation r2 = new FieldRotation<>(r1.getQ0().multiply(n), r1.getQ1().multiply(n), r1.getQ2().multiply(n), r1.getQ3().multiply(n), true); for (double x = -0.9; x < 0.9; x += 0.2) { @@ -625,10 +625,10 @@ public void testQuaternion() throws MathIllegalArgumentException { @Test public void testApplyToRotation() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.applyTo(r1); @@ -653,10 +653,10 @@ public void testApplyToRotation() throws MathIllegalArgumentException { @Test public void testComposeVectorOperator() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.compose(r1, RotationConvention.VECTOR_OPERATOR); @@ -682,10 +682,10 @@ public void testComposeVectorOperator() throws MathIllegalArgumentException { @Test public void testComposeFrameTransform() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.FRAME_TRANSFORM); - FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.FRAME_TRANSFORM); FieldRotation r3 = r2.compose(r1, RotationConvention.FRAME_TRANSFORM); @@ -713,10 +713,10 @@ public void testComposeFrameTransform() throws MathIllegalArgumentException { @Test public void testApplyInverseToRotation() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.applyInverseTo(r1); @@ -741,10 +741,10 @@ public void testApplyInverseToRotation() throws MathIllegalArgumentException { @Test public void testComposeInverseVectorOperator() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.composeInverse(r1, RotationConvention.VECTOR_OPERATOR); @@ -770,10 +770,10 @@ public void testComposeInverseVectorOperator() throws MathIllegalArgumentExcepti @Test public void testComposeInverseFrameTransform() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.FRAME_TRANSFORM); - FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.FRAME_TRANSFORM); FieldRotation r3 = r2.composeInverse(r1, RotationConvention.FRAME_TRANSFORM); @@ -805,7 +805,7 @@ public void testDoubleVectors() throws MathIllegalArgumentException { UnitSphereRandomVectorGenerator g = new UnitSphereRandomVectorGenerator(3, random); for (int i = 0; i < 10; ++i) { double[] unit = g.nextVector(); - FieldRotation r = new FieldRotation(createVector(unit[0], unit[1], unit[2]), + FieldRotation r = new FieldRotation<>(createVector(unit[0], unit[1], unit[2]), createAngle(random.nextDouble()), RotationConvention.VECTOR_OPERATOR); @@ -823,9 +823,9 @@ public void testDoubleVectors() throws MathIllegalArgumentException { Dfp[] rIuArray = new Dfp[3]; r.applyInverseTo(new double[] { x, y, z}, rIuArray); checkVector(ruds, ru); - checkVector(ruds, new FieldVector3D(ruArray)); + checkVector(ruds, new FieldVector3D<>(ruArray)); checkVector(rIuds, rIu); - checkVector(rIuds, new FieldVector3D(rIuArray)); + checkVector(rIuds, new FieldVector3D<>(rIuArray)); } } } @@ -843,13 +843,13 @@ public void testDoubleRotations() throws MathIllegalArgumentException { double[] unit1 = g.nextVector(); Rotation r1 = new Rotation(new Vector3D(unit1[0], unit1[1], unit1[2]), random.nextDouble(), RotationConvention.VECTOR_OPERATOR); - FieldRotation r1Prime = new FieldRotation(field.newDfp(r1.getQ0()), + FieldRotation r1Prime = new FieldRotation<>(field.newDfp(r1.getQ0()), field.newDfp(r1.getQ1()), field.newDfp(r1.getQ2()), field.newDfp(r1.getQ3()), false); double[] unit2 = g.nextVector(); - FieldRotation r2 = new FieldRotation(createVector(unit2[0], unit2[1], unit2[2]), + FieldRotation r2 = new FieldRotation<>(createVector(unit2[0], unit2[1], unit2[2]), createAngle(random.nextDouble()), RotationConvention.VECTOR_OPERATOR); @@ -880,7 +880,7 @@ public void testDoubleRotations() throws MathIllegalArgumentException { @Test public void testArray() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation(createAxis(2, -3, 5), + FieldRotation r = new FieldRotation<>(createAxis(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); @@ -910,7 +910,7 @@ public void testApplyInverseTo() throws MathIllegalArgumentException { Dfp[] in = new Dfp[3]; Dfp[] out = new Dfp[3]; Dfp[] rebuilt = new Dfp[3]; - FieldRotation r = new FieldRotation(createVector(2, -3, 5), + FieldRotation r = new FieldRotation<>(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); for (double lambda = 0; lambda < 6.2; lambda += 0.2) { @@ -943,7 +943,7 @@ public void testApplyInverseTo() throws MathIllegalArgumentException { } } - r = new FieldRotation(createVector(0, 0, 1), createAngle(FastMath.PI), RotationConvention.VECTOR_OPERATOR); + r = new FieldRotation<>(createVector(0, 0, 1), createAngle(FastMath.PI), RotationConvention.VECTOR_OPERATOR); for (double lambda = 0; lambda < 6.2; lambda += 0.2) { for (double phi = -1.55; phi < 1.55; phi += 0.2) { FieldVector3D u = createVector(FastMath.cos(lambda) * FastMath.cos(phi), @@ -964,7 +964,7 @@ public void testIssue639() throws MathArithmeticException{ FieldVector3D u2 =createVector( -5712344449280879.0 / 2097152.0, -2275058564560979.0 / 1048576.0, 4423475992255071.0 / 65536.0); - FieldRotation rot = new FieldRotation(u1, u2, createVector(1, 0, 0),createVector(0, 0, 1)); + FieldRotation rot = new FieldRotation<>(u1, u2, createVector(1, 0, 0),createVector(0, 0, 1)); Assert.assertEquals( 0.6228370359608200639829222, rot.getQ0().getReal(), 1.0e-15); Assert.assertEquals( 0.0257707621456498790029987, rot.getQ1().getReal(), 1.0e-15); Assert.assertEquals(-0.0000000002503012255839931, rot.getQ2().getReal(), 1.0e-15); @@ -979,7 +979,7 @@ public void testIssue801() throws MathArithmeticException { FieldVector3D v1 = createVector(0.9999999999999999, 0.0, 0.0); FieldVector3D v2 = createVector(0.0, 0.0, -1.0); - FieldRotation quat = new FieldRotation(u1, u2, v1, v2); + FieldRotation quat = new FieldRotation<>(u1, u2, v1, v2); double q2 = quat.getQ0().getReal() * quat.getQ0().getReal() + quat.getQ1().getReal() * quat.getQ1().getReal() + quat.getQ2().getReal() * quat.getQ2().getReal() + @@ -1002,7 +1002,7 @@ private void checkRotationDS(FieldRotation r, double q0, double q1, double private FieldRotation createRotation(double q0, double q1, double q2, double q3, boolean needsNormalization) { DfpField field = new DfpField(20); - return new FieldRotation(field.newDfp(q0), + return new FieldRotation<>(field.newDfp(q0), field.newDfp(q1), field.newDfp(q2), field.newDfp(q3), @@ -1017,17 +1017,17 @@ private FieldRotation createRotation(double[][] m, double threshold) { mds[i][j] = field.newDfp(m[i][j]); } } - return new FieldRotation(mds, threshold); + return new FieldRotation<>(mds, threshold); } private FieldVector3D createVector(double x, double y, double z) { DfpField field = new DfpField(20); - return new FieldVector3D(field.newDfp(x), field.newDfp(y), field.newDfp(z)); + return new FieldVector3D<>(field.newDfp(x), field.newDfp(y), field.newDfp(z)); } private FieldVector3D createAxis(double x, double y, double z) { DfpField field = new DfpField(20); - return new FieldVector3D(field.newDfp(x), field.newDfp(y), field.newDfp(z)); + return new FieldVector3D<>(field.newDfp(x), field.newDfp(y), field.newDfp(z)); } private Dfp createAngle(double alpha) { diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java index 24e5515046..758e870057 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java @@ -41,8 +41,8 @@ public void testConstructors() throws DimensionMismatchException { double sinAlpha = FastMath.sqrt(3) / 2.0; double cosDelta = FastMath.sqrt(2) / 2.0; double sinDelta = -FastMath.sqrt(2) / 2.0; - FieldVector3D u = new FieldVector3D(2, - new FieldVector3D(new DerivativeStructure(2, 1, 0, FastMath.PI / 3), + FieldVector3D u = new FieldVector3D<>(2, + new FieldVector3D<>(new DerivativeStructure(2, 1, 0, FastMath.PI / 3), new DerivativeStructure(2, 1, 1, -FastMath.PI / 4))); checkVector(u, 2 * cosAlpha * cosDelta, 2 * sinAlpha * cosDelta, 2 * sinDelta); Assert.assertEquals(-2 * sinAlpha * cosDelta, u.getX().getPartialDerivative(1, 0), 1.0e-12); @@ -52,41 +52,41 @@ public void testConstructors() throws DimensionMismatchException { Assert.assertEquals(-2 * sinAlpha * sinDelta, u.getY().getPartialDerivative(0, 1), 1.0e-12); Assert.assertEquals(2 * cosDelta, u.getZ().getPartialDerivative(0, 1), 1.0e-12); - checkVector(new FieldVector3D(2, createVector(1, 0, 0, 3)), + checkVector(new FieldVector3D<>(2, createVector(1, 0, 0, 3)), 2, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2); - checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), createVector(1, 0, 0, 4)), 2, 0, 0, 2, 0, 0, 1, 0, 2, 0, 0, 0, 0, 2, 0); - checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), new Vector3D(1, 0, 0)), 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0); - checkVector(new FieldVector3D(2, createVector(1, 0, 0, 3), + checkVector(new FieldVector3D<>(2, createVector(1, 0, 0, 3), -3, createVector(0, 0, -1, 3)), 2, 0, 3, -1, 0, 0, 0, -1, 0, 0, 0, -1); - checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), createVector(1, 0, 0, 4), new DerivativeStructure(4, 1, 3, -3.0), createVector(0, 0, -1, 4)), 2, 0, 3, -1, 0, 0, 1, 0, -1, 0, 0, 0, 0, -1, -1); - checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), new Vector3D(1, 0, 0), new DerivativeStructure(4, 1, 3, -3.0), new Vector3D(0, 0, -1)), 2, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1); - checkVector(new FieldVector3D(2, createVector(1, 0, 0, 3), + checkVector(new FieldVector3D<>(2, createVector(1, 0, 0, 3), 5, createVector(0, 1, 0, 3), -3, createVector(0, 0, -1, 3)), 2, 5, 3, 4, 0, 0, 0, 4, 0, 0, 0, 4); - checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), createVector(1, 0, 0, 4), new DerivativeStructure(4, 1, 3, 5.0), createVector(0, 1, 0, 4), new DerivativeStructure(4, 1, 3, -3.0), createVector(0, 0, -1, 4)), 2, 5, 3, 4, 0, 0, 1, 0, 4, 0, 1, 0, 0, 4, -1); - checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), new Vector3D(1, 0, 0), new DerivativeStructure(4, 1, 3, 5.0), new Vector3D(0, 1, 0), @@ -94,12 +94,12 @@ public void testConstructors() throws DimensionMismatchException { new Vector3D(0, 0, -1)), 2, 5, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, -1); - checkVector(new FieldVector3D(2, createVector(1, 0, 0, 3), + checkVector(new FieldVector3D<>(2, createVector(1, 0, 0, 3), 5, createVector(0, 1, 0, 3), 5, createVector(0, -1, 0, 3), -3, createVector(0, 0, -1, 3)), 2, 0, 3, 9, 0, 0, 0, 9, 0, 0, 0, 9); - checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), createVector(1, 0, 0, 4), new DerivativeStructure(4, 1, 3, 5.0), createVector(0, 1, 0, 4), @@ -108,7 +108,7 @@ public void testConstructors() throws DimensionMismatchException { new DerivativeStructure(4, 1, 3, -3.0), createVector(0, 0, -1, 4)), 2, 0, 3, 9, 0, 0, 1, 0, 9, 0, 0, 0, 0, 9, -1); - checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), new Vector3D(1, 0, 0), new DerivativeStructure(4, 1, 3, 5.0), new Vector3D(0, 1, 0), @@ -118,7 +118,7 @@ public void testConstructors() throws DimensionMismatchException { new Vector3D(0, 0, -1)), 2, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1); - checkVector(new FieldVector3D(new DerivativeStructure[] { + checkVector(new FieldVector3D<>(new DerivativeStructure[] { new DerivativeStructure(3, 1, 2, 2), new DerivativeStructure(3, 1, 1, 5), new DerivativeStructure(3, 1, 0, -3) @@ -132,16 +132,16 @@ public void testEquals() { FieldVector3D u1 = createVector(1, 2, 3, 3); FieldVector3D v = createVector(1, 2, 3 + 10 * Precision.EPSILON, 3); Assert.assertTrue(u1.equals(u1)); - Assert.assertTrue(u1.equals(new FieldVector3D(new DerivativeStructure(3, 1, 0, 1.0), + Assert.assertTrue(u1.equals(new FieldVector3D<>(new DerivativeStructure(3, 1, 0, 1.0), new DerivativeStructure(3, 1, 1, 2.0), new DerivativeStructure(3, 1, 2, 3.0)))); - Assert.assertFalse(u1.equals(new FieldVector3D(new DerivativeStructure(3, 1, 1.0), + Assert.assertFalse(u1.equals(new FieldVector3D<>(new DerivativeStructure(3, 1, 1.0), new DerivativeStructure(3, 1, 1, 2.0), new DerivativeStructure(3, 1, 2, 3.0)))); - Assert.assertFalse(u1.equals(new FieldVector3D(new DerivativeStructure(3, 1, 0, 1.0), + Assert.assertFalse(u1.equals(new FieldVector3D<>(new DerivativeStructure(3, 1, 0, 1.0), new DerivativeStructure(3, 1, 2.0), new DerivativeStructure(3, 1, 2, 3.0)))); - Assert.assertFalse(u1.equals(new FieldVector3D(new DerivativeStructure(3, 1, 0, 1.0), + Assert.assertFalse(u1.equals(new FieldVector3D<>(new DerivativeStructure(3, 1, 0, 1.0), new DerivativeStructure(3, 1, 1, 2.0), new DerivativeStructure(3, 1, 3.0)))); Assert.assertFalse(u1.equals(v)); @@ -184,7 +184,7 @@ public void testToString() { @Test(expected=DimensionMismatchException.class) public void testWrongDimension() throws DimensionMismatchException { - new FieldVector3D(new DerivativeStructure[] { + new FieldVector3D<>(new DerivativeStructure[] { new DerivativeStructure(3, 1, 0, 2), new DerivativeStructure(3, 1, 0, 5) }); @@ -475,8 +475,8 @@ public void testCrossProductCancellation() { checkVector(FieldVector3D.crossProduct(v1, v2), -1, 2, 1); double scale = FastMath.scalb(1.0, 100); - FieldVector3D big1 = new FieldVector3D(scale, v1); - FieldVector3D small2 = new FieldVector3D(1 / scale, v2); + FieldVector3D big1 = new FieldVector3D<>(scale, v1); + FieldVector3D small2 = new FieldVector3D<>(1 / scale, v2); checkVector(FieldVector3D.crossProduct(big1, small2), -1, 2, 1); } @@ -637,7 +637,7 @@ public void testAccurateCrossProduct() { final FieldVector3D u3 = createVector(12753243807587107.0 / 18446744073709551616.0, -2313766922703915.0 / 18446744073709551616.0, -227970081415313.0 / 288230376151711744.0, 3); - FieldVector3D cNaive = new FieldVector3D(u1.getY().multiply(u2.getZ()).subtract(u1.getZ().multiply(u2.getY())), + FieldVector3D cNaive = new FieldVector3D<>(u1.getY().multiply(u2.getZ()).subtract(u1.getZ().multiply(u2.getY())), u1.getZ().multiply(u2.getX()).subtract(u1.getX().multiply(u2.getZ())), u1.getX().multiply(u2.getY()).subtract(u1.getY().multiply(u2.getX()))); FieldVector3D cAccurate = FieldVector3D.crossProduct(u1, u2); @@ -679,7 +679,7 @@ public void testCrossProduct() { } private FieldVector3D createVector(double x, double y, double z, int params) { - return new FieldVector3D(new DerivativeStructure(params, 1, 0, x), + return new FieldVector3D<>(new DerivativeStructure(params, 1, 0, x), new DerivativeStructure(params, 1, 1, y), new DerivativeStructure(params, 1, 2, z)); } diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PLYParser.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PLYParser.java index f65663cc25..7670e69ad3 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PLYParser.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PLYParser.java @@ -214,7 +214,7 @@ private void complain() throws ParseException { */ private List parseNextLine() throws IOException, ParseException { - final List fields = new ArrayList(); + final List fields = new ArrayList<>(); line = br.readLine(); if (line == null) { throw new EOFException(); diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java index b1b902ad52..d8b1d7dbb4 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java @@ -243,7 +243,7 @@ public void testCross() { new PolyhedronsSet(x - w, x + w, y - l, y + l, z - w, z + w, 1.0e-10); PolyhedronsSet zBeam = new PolyhedronsSet(x - w, x + w, y - w, y + w, z - l, z + l, 1.0e-10); - RegionFactory factory = new RegionFactory(); + RegionFactory factory = new RegionFactory<>(); PolyhedronsSet tree = (PolyhedronsSet) factory.union(xBeam, factory.union(yBeam, zBeam)); Vector3D barycenter = (Vector3D) tree.getBarycenter(); @@ -273,7 +273,7 @@ public void testIssue780() throws MathArithmeticException { 1, 5, 6, 1, 6, 2, 2, 6, 7, 2, 7, 3, 4, 0, 3, 4, 3, 7}; - ArrayList> subHyperplaneList = new ArrayList>(); + ArrayList> subHyperplaneList = new ArrayList<>(); for (int idx = 0; idx < indices.length; idx += 3) { int idxA = indices[idx] * 3; int idxB = indices[idx + 1] * 3; @@ -283,7 +283,7 @@ public void testIssue780() throws MathArithmeticException { Vector3D v_3 = new Vector3D(coords[idxC], coords[idxC + 1], coords[idxC + 2]); Vector3D[] vertices = {v_1, v_2, v_3}; Plane polyPlane = new Plane(v_1, v_2, v_3, 1.0e-10); - ArrayList> lines = new ArrayList>(); + ArrayList> lines = new ArrayList<>(); Vector2D[] projPts = new Vector2D[vertices.length]; for (int ptIdx = 0; ptIdx < projPts.length; ptIdx++) { diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGeneratorTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGeneratorTest.java index 5fdc4f6feb..81b9b2382b 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGeneratorTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGeneratorTest.java @@ -143,7 +143,7 @@ public void testRandom() { double d = 25 * random.nextDouble(); double refRadius = 10 * random.nextDouble(); Vector3D refCenter = new Vector3D(d, new Vector3D(sr.nextVector())); - List support = new ArrayList(); + List support = new ArrayList<>(); for (int j = 0; j < 5; ++j) { support.add(new Vector3D(1.0, refCenter, refRadius, new Vector3D(sr.nextVector()))); } diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGeneratorTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGeneratorTest.java index 5ca929589e..8c5268245f 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGeneratorTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGeneratorTest.java @@ -108,7 +108,7 @@ public void testRandom() { double d = 25 * random.nextDouble(); double refRadius = 10 * random.nextDouble(); Vector2D refCenter = new Vector2D(d, new Vector2D(sr.nextVector())); - List support = new ArrayList(); + List support = new ArrayList<>(); for (int j = 0; j < 3; ++j) { support.add(new Vector2D(1.0, refCenter, refRadius, new Vector2D(sr.nextVector()))); } diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java index 28b5eda93d..bb4e51bb29 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java @@ -675,15 +675,15 @@ public void testChoppedHexagon() { hyp[4] = (SubLine) hyp[4].split(hyp[3].getHyperplane()).getMinus().split(hyp[0].getHyperplane()).getMinus(); hyp[5] = (SubLine) hyp[5].split(hyp[4].getHyperplane()).getMinus().split(hyp[0].getHyperplane()).getMinus(); hyp[6] = (SubLine) hyp[6].split(hyp[3].getHyperplane()).getMinus().split(hyp[1].getHyperplane()).getMinus(); - BSPTree tree = new BSPTree(Boolean.TRUE); + BSPTree tree = new BSPTree<>(Boolean.TRUE); for (int i = hyp.length - 1; i >= 0; --i) { - tree = new BSPTree(hyp[i], new BSPTree(Boolean.FALSE), tree, null); + tree = new BSPTree<>(hyp[i], new BSPTree(Boolean.FALSE), tree, null); } PolygonsSet set = new PolygonsSet(tree, 1.0e-10); SubLine splitter = new Line(new Vector2D(-2.0 * sqrt3 / 3.0, 0.0), 9 * pi6, 1.0e-10).wholeHyperplane(); PolygonsSet slice = - new PolygonsSet(new BSPTree(splitter, + new PolygonsSet(new BSPTree<>(splitter, set.getTree(false).split(splitter).getPlus(), new BSPTree(Boolean.FALSE), null), 1.0e-10); @@ -726,85 +726,85 @@ public void testConcentric() { @Test public void testBug20040520() { BSPTree a0 = - new BSPTree(buildSegment(new Vector2D(0.85, -0.05), + new BSPTree<>(buildSegment(new Vector2D(0.85, -0.05), new Vector2D(0.90, -0.10)), new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null); BSPTree a1 = - new BSPTree(buildSegment(new Vector2D(0.85, -0.10), + new BSPTree<>(buildSegment(new Vector2D(0.85, -0.10), new Vector2D(0.90, -0.10)), new BSPTree(Boolean.FALSE), a0, null); BSPTree a2 = - new BSPTree(buildSegment(new Vector2D(0.90, -0.05), + new BSPTree<>(buildSegment(new Vector2D(0.90, -0.05), new Vector2D(0.85, -0.05)), new BSPTree(Boolean.FALSE), a1, null); BSPTree a3 = - new BSPTree(buildSegment(new Vector2D(0.82, -0.05), + new BSPTree<>(buildSegment(new Vector2D(0.82, -0.05), new Vector2D(0.82, -0.08)), new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null); BSPTree a4 = - new BSPTree(buildHalfLine(new Vector2D(0.85, -0.05), + new BSPTree<>(buildHalfLine(new Vector2D(0.85, -0.05), new Vector2D(0.80, -0.05), false), new BSPTree(Boolean.FALSE), a3, null); BSPTree a5 = - new BSPTree(buildSegment(new Vector2D(0.82, -0.08), + new BSPTree<>(buildSegment(new Vector2D(0.82, -0.08), new Vector2D(0.82, -0.18)), new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null); BSPTree a6 = - new BSPTree(buildHalfLine(new Vector2D(0.82, -0.18), + new BSPTree<>(buildHalfLine(new Vector2D(0.82, -0.18), new Vector2D(0.85, -0.15), true), new BSPTree(Boolean.FALSE), a5, null); BSPTree a7 = - new BSPTree(buildHalfLine(new Vector2D(0.85, -0.05), + new BSPTree<>(buildHalfLine(new Vector2D(0.85, -0.05), new Vector2D(0.82, -0.08), false), a4, a6, null); BSPTree a8 = - new BSPTree(buildLine(new Vector2D(0.85, -0.25), + new BSPTree<>(buildLine(new Vector2D(0.85, -0.25), new Vector2D(0.85, 0.05)), a2, a7, null); BSPTree a9 = - new BSPTree(buildLine(new Vector2D(0.90, 0.05), + new BSPTree<>(buildLine(new Vector2D(0.90, 0.05), new Vector2D(0.90, -0.50)), a8, new BSPTree(Boolean.FALSE), null); BSPTree b0 = - new BSPTree(buildSegment(new Vector2D(0.92, -0.12), + new BSPTree<>(buildSegment(new Vector2D(0.92, -0.12), new Vector2D(0.92, -0.08)), new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null); BSPTree b1 = - new BSPTree(buildHalfLine(new Vector2D(0.92, -0.08), + new BSPTree<>(buildHalfLine(new Vector2D(0.92, -0.08), new Vector2D(0.90, -0.10), true), new BSPTree(Boolean.FALSE), b0, null); BSPTree b2 = - new BSPTree(buildSegment(new Vector2D(0.92, -0.18), + new BSPTree<>(buildSegment(new Vector2D(0.92, -0.18), new Vector2D(0.92, -0.12)), new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null); BSPTree b3 = - new BSPTree(buildSegment(new Vector2D(0.85, -0.15), + new BSPTree<>(buildSegment(new Vector2D(0.85, -0.15), new Vector2D(0.90, -0.20)), new BSPTree(Boolean.FALSE), b2, null); BSPTree b4 = - new BSPTree(buildSegment(new Vector2D(0.95, -0.15), + new BSPTree<>(buildSegment(new Vector2D(0.95, -0.15), new Vector2D(0.85, -0.05)), b1, b3, null); BSPTree b5 = - new BSPTree(buildHalfLine(new Vector2D(0.85, -0.05), + new BSPTree<>(buildHalfLine(new Vector2D(0.85, -0.05), new Vector2D(0.85, -0.25), true), new BSPTree(Boolean.FALSE), b4, null); BSPTree b6 = - new BSPTree(buildLine(new Vector2D(0.0, -1.10), + new BSPTree<>(buildLine(new Vector2D(0.0, -1.10), new Vector2D(1.0, -0.10)), new BSPTree(Boolean.FALSE), b5, null); @@ -866,7 +866,7 @@ public void testBug20041003() { }; BSPTree node1 = - new BSPTree(new SubLine(l[0], + new BSPTree<>(new SubLine(l[0], new IntervalsSet(intersectionAbscissa(l[0], l[1]), intersectionAbscissa(l[0], l[2]), 1.0e-10)), @@ -874,7 +874,7 @@ public void testBug20041003() { new BSPTree(Boolean.FALSE), null); BSPTree node2 = - new BSPTree(new SubLine(l[1], + new BSPTree<>(new SubLine(l[1], new IntervalsSet(intersectionAbscissa(l[1], l[2]), intersectionAbscissa(l[1], l[3]), 1.0e-10)), @@ -882,14 +882,14 @@ public void testBug20041003() { new BSPTree(Boolean.FALSE), null); BSPTree node3 = - new BSPTree(new SubLine(l[2], + new BSPTree<>(new SubLine(l[2], new IntervalsSet(intersectionAbscissa(l[2], l[3]), Double.POSITIVE_INFINITY, 1.0e-10)), node2, new BSPTree(Boolean.FALSE), null); BSPTree node4 = - new BSPTree(l[3].wholeHyperplane(), + new BSPTree<>(l[3].wholeHyperplane(), node3, new BSPTree(Boolean.FALSE), null); @@ -1126,7 +1126,7 @@ public void testIssue1162() { @Test public void testThinRectangle() { - RegionFactory factory = new RegionFactory(); + RegionFactory factory = new RegionFactory<>(); Vector2D pA = new Vector2D(0.0, 1.0); Vector2D pB = new Vector2D(0.0, 0.0); Vector2D pC = new Vector2D(1.0 / 64.0, 0.0); @@ -1236,7 +1236,7 @@ public int getLeafNodes() { } private PolygonsSet buildSet(Vector2D[][] vertices) { - ArrayList> edges = new ArrayList>(); + ArrayList> edges = new ArrayList<>(); for (int i = 0; i < vertices.length; ++i) { int l = vertices[i].length; for (int j = 0; j < l; ++j) { diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java index 717b2644c4..d1af7a5284 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java @@ -93,7 +93,7 @@ public void testTwoPoints() { @Test public void testAllIdentical() { - final Collection points = new ArrayList(); + final Collection points = new ArrayList<>(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(1, 1)); points.add(new Vector2D(1, 1)); @@ -118,7 +118,7 @@ public void testConvexHull() { @Test public void testCollinearPoints() { - final Collection points = new ArrayList(); + final Collection points = new ArrayList<>(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(2, 2)); points.add(new Vector2D(2, 4)); @@ -131,7 +131,7 @@ public void testCollinearPoints() { @Test public void testCollinearPointsReverse() { - final Collection points = new ArrayList(); + final Collection points = new ArrayList<>(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(2, 2)); points.add(new Vector2D(2, 4)); @@ -144,7 +144,7 @@ public void testCollinearPointsReverse() { @Test public void testCollinearPointsIncluded() { - final Collection points = new ArrayList(); + final Collection points = new ArrayList<>(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(2, 2)); points.add(new Vector2D(2, 4)); @@ -157,7 +157,7 @@ public void testCollinearPointsIncluded() { @Test public void testCollinearPointsIncludedReverse() { - final Collection points = new ArrayList(); + final Collection points = new ArrayList<>(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(2, 2)); points.add(new Vector2D(2, 4)); @@ -170,7 +170,7 @@ public void testCollinearPointsIncludedReverse() { @Test public void testIdenticalPoints() { - final Collection points = new ArrayList(); + final Collection points = new ArrayList<>(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(2, 2)); points.add(new Vector2D(2, 4)); @@ -183,7 +183,7 @@ public void testIdenticalPoints() { @Test public void testIdenticalPoints2() { - final Collection points = new ArrayList(); + final Collection points = new ArrayList<>(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(2, 2)); points.add(new Vector2D(2, 4)); @@ -196,7 +196,7 @@ public void testIdenticalPoints2() { @Test public void testClosePoints() { - final Collection points = new ArrayList(); + final Collection points = new ArrayList<>(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(2, 2)); points.add(new Vector2D(2, 4)); @@ -211,7 +211,7 @@ public void testClosePoints() { public void testCollinearPointOnExistingBoundary() { // MATH-1135: check that collinear points on the hull are handled correctly // when only a minimal hull shall be constructed - final Collection points = new ArrayList(); + final Collection points = new ArrayList<>(); points.add(new Vector2D(7.3152, 34.7472)); points.add(new Vector2D(6.400799999999997, 34.747199999999985)); points.add(new Vector2D(5.486399999999997, 34.7472)); @@ -233,7 +233,7 @@ public void testCollinearPointsInAnyOrder() { // make sure that they are processed in the proper order // for each algorithm. - List points = new ArrayList(); + List points = new ArrayList<>(); // first case: 3 points are collinear points.add(new Vector2D(16.078200000000184, -36.52519999989808)); @@ -270,7 +270,7 @@ public void testCollinearPointsInAnyOrder() { @Test public void testIssue1123() { - List points = new ArrayList(); + List points = new ArrayList<>(); int[][] data = new int[][] { { -11, -1 }, { -11, 0 }, { -11, 1 }, { -10, -3 }, { -10, -2 }, { -10, -1 }, { -10, 0 }, { -10, 1 }, @@ -367,7 +367,7 @@ public void testIssue1123() { protected final List createRandomPoints(int size) { // create the cloud container - List points = new ArrayList(size); + List points = new ArrayList<>(size); // fill the cloud with a random distribution of points for (int i = 0; i < size; i++) { points.add(new Vector2D(random.nextDouble() * 2.0 - 1.0, random.nextDouble() * 2.0 - 1.0)); diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java index ebc2f6cebe..7860b9db5a 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java @@ -40,7 +40,7 @@ protected ConvexHullGenerator2D createConvexHullGenerator(boolean includeColline @Test(expected=ConvergenceException.class) public void testConvergenceException() { - final Collection points = new ArrayList(); + final Collection points = new ArrayList<>(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(1, 5)); diff --git a/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java b/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java index 29e48f33ee..ced1989783 100644 --- a/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java +++ b/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java @@ -211,7 +211,7 @@ public TreeBuilder(final String type, final String s) getWord(TOLERANCE); tolerance = getNumber(); getWord(PLUS); - root = new BSPTree(); + root = new BSPTree<>(); parseTree(root); if (tokenizer.hasMoreTokens()) { throw new ParseException("unexpected " + tokenizer.nextToken(), 0); diff --git a/src/test/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSetTest.java index e57286b0d6..6f868579a9 100644 --- a/src/test/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSetTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSetTest.java @@ -170,7 +170,7 @@ public void testTiny() { @Test public void testSpecialConstruction() { - List> boundary = new ArrayList>(); + List> boundary = new ArrayList<>(); boundary.add(new LimitAngle(new S1Point(0.0), false, 1.0e-10).wholeHyperplane()); boundary.add(new LimitAngle(new S1Point(MathUtils.TWO_PI - 1.0e-11), true, 1.0e-10).wholeHyperplane()); ArcsSet set = new ArcsSet(boundary, 1.0e-10); @@ -271,7 +271,7 @@ public void testIntersection() { @Test public void testMultiple() { - RegionFactory factory = new RegionFactory(); + RegionFactory factory = new RegionFactory<>(); ArcsSet set = (ArcsSet) factory.intersection(factory.union(factory.difference(new ArcsSet(1.0, 6.0, 1.0e-10), new ArcsSet(3.0, 5.0, 1.0e-10)), @@ -347,9 +347,9 @@ public void testShiftedAngles() { for (int k = -2; k < 3; ++k) { SubLimitAngle l1 = new LimitAngle(new S1Point(1.0 + k * MathUtils.TWO_PI), false, 1.0e-10).wholeHyperplane(); SubLimitAngle l2 = new LimitAngle(new S1Point(1.5 + k * MathUtils.TWO_PI), true, 1.0e-10).wholeHyperplane(); - ArcsSet set = new ArcsSet(new BSPTree(l1, + ArcsSet set = new ArcsSet(new BSPTree<>(l1, new BSPTree(Boolean.FALSE), - new BSPTree(l2, + new BSPTree<>(l2, new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null), @@ -371,10 +371,10 @@ public void testInconsistentState() { SubLimitAngle l1 = new LimitAngle(new S1Point(1.0), false, 1.0e-10).wholeHyperplane(); SubLimitAngle l2 = new LimitAngle(new S1Point(2.0), true, 1.0e-10).wholeHyperplane(); SubLimitAngle l3 = new LimitAngle(new S1Point(3.0), false, 1.0e-10).wholeHyperplane(); - new ArcsSet(new BSPTree(l1, + new ArcsSet(new BSPTree<>(l1, new BSPTree(Boolean.FALSE), - new BSPTree(l2, - new BSPTree(l3, + new BSPTree<>(l2, + new BSPTree<>(l3, new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null), diff --git a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSetTest.java index e9fbe475a0..4b0368e171 100644 --- a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSetTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSetTest.java @@ -110,7 +110,7 @@ public void testSouthHemisphere() { public void testPositiveOctantByIntersection() { double tol = 0.01; double sinTol = FastMath.sin(tol); - RegionFactory factory = new RegionFactory(); + RegionFactory factory = new RegionFactory<>(); SphericalPolygonsSet plusX = new SphericalPolygonsSet(Vector3D.PLUS_I, tol); SphericalPolygonsSet plusY = new SphericalPolygonsSet(Vector3D.PLUS_J, tol); SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Vector3D.PLUS_K, tol); @@ -198,7 +198,7 @@ public void testPositiveOctantByVertices() { public void testNonConvex() { double tol = 0.01; double sinTol = FastMath.sin(tol); - RegionFactory factory = new RegionFactory(); + RegionFactory factory = new RegionFactory<>(); SphericalPolygonsSet plusX = new SphericalPolygonsSet(Vector3D.PLUS_I, tol); SphericalPolygonsSet plusY = new SphericalPolygonsSet(Vector3D.PLUS_J, tol); SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Vector3D.PLUS_K, tol); @@ -267,7 +267,7 @@ public void testNonConvex() { @Test public void testModeratlyComplexShape() { double tol = 0.01; - List> boundary = new ArrayList>(); + List> boundary = new ArrayList<>(); boundary.add(create(Vector3D.MINUS_J, Vector3D.PLUS_I, Vector3D.PLUS_K, tol, 0.0, 0.5 * FastMath.PI)); boundary.add(create(Vector3D.MINUS_I, Vector3D.PLUS_K, Vector3D.PLUS_J, tol, 0.0, 0.5 * FastMath.PI)); boundary.add(create(Vector3D.PLUS_K, Vector3D.PLUS_J, Vector3D.MINUS_I, tol, 0.0, 0.5 * FastMath.PI)); @@ -324,7 +324,7 @@ public void testModeratlyComplexShape() { public void testSeveralParts() { double tol = 0.01; double sinTol = FastMath.sin(tol); - List> boundary = new ArrayList>(); + List> boundary = new ArrayList<>(); // first part: +X, +Y, +Z octant boundary.add(create(Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_I, tol, 0.0, 0.5 * FastMath.PI)); @@ -406,7 +406,7 @@ public void testConcentricSubParts() { SphericalPolygonsSet triOut = new SphericalPolygonsSet(center, Vector3D.PLUS_K, 0.25, 3, tol); SphericalPolygonsSet triIn = new SphericalPolygonsSet(center, Vector3D.PLUS_K, 0.15, 3, tol); - RegionFactory factory = new RegionFactory(); + RegionFactory factory = new RegionFactory<>(); SphericalPolygonsSet hexa = (SphericalPolygonsSet) factory.difference(hexaOut, hexaIn); SphericalPolygonsSet penta = (SphericalPolygonsSet) factory.difference(pentaOut, pentaIn); SphericalPolygonsSet quadri = (SphericalPolygonsSet) factory.difference(quadriOut, quadriIn); @@ -467,7 +467,7 @@ public void testGeographicalMap() { { 42.15249, 9.56001 }, { 43.00998, 9.39000 }, { 42.62812, 8.74600 }, { 42.25651, 8.54421 }, { 41.58361, 8.77572 }, { 41.38000, 9.22975 } }); - RegionFactory factory = new RegionFactory(); + RegionFactory factory = new RegionFactory<>(); SphericalPolygonsSet zone = (SphericalPolygonsSet) factory.union(continental, corsica); EnclosingBall enclosing = zone.getEnclosingCap(); Vector3D enclosingCenter = ((S2Point) enclosing.getCenter()).getVector(); @@ -525,7 +525,7 @@ public void testGeographicalMap() { private SubCircle create(Vector3D pole, Vector3D x, Vector3D y, double tolerance, double ... limits) { - RegionFactory factory = new RegionFactory(); + RegionFactory factory = new RegionFactory<>(); Circle circle = new Circle(pole, tolerance); Circle phased = (Circle) Circle.getTransform(new Rotation(circle.getXAxis(), circle.getYAxis(), x, y)).apply(circle); diff --git a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SubCircleTest.java b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SubCircleTest.java index 891f6207f6..34b6278f79 100644 --- a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SubCircleTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SubCircleTest.java @@ -127,7 +127,7 @@ public void testSideSplitConsistency() { private SubCircle create(Vector3D pole, Vector3D x, Vector3D y, double tolerance, double ... limits) { - RegionFactory factory = new RegionFactory(); + RegionFactory factory = new RegionFactory<>(); Circle circle = new Circle(pole, tolerance); Circle phased = (Circle) Circle.getTransform(new Rotation(circle.getXAxis(), circle.getYAxis(), x, y)).apply(circle); diff --git a/src/test/java/org/apache/commons/math4/linear/ArrayFieldVectorTest.java b/src/test/java/org/apache/commons/math4/linear/ArrayFieldVectorTest.java index a9f7ac7911..1268b262c5 100644 --- a/src/test/java/org/apache/commons/math4/linear/ArrayFieldVectorTest.java +++ b/src/test/java/org/apache/commons/math4/linear/ArrayFieldVectorTest.java @@ -139,7 +139,7 @@ public FieldVector mapMultiply(T d) { for (int i = 0; i < data.length; i++) { out[i] = data[i].multiply(d); } - return new FieldVectorTestImpl(out); + return new FieldVectorTestImpl<>(out); } public FieldVector mapMultiplyToSelf(T d) { @@ -263,70 +263,70 @@ public T[] toArray() { @Test public void testConstructors() { - ArrayFieldVector v0 = new ArrayFieldVector(FractionField.getInstance()); + ArrayFieldVector v0 = new ArrayFieldVector<>(FractionField.getInstance()); Assert.assertEquals(0, v0.getDimension()); - ArrayFieldVector v1 = new ArrayFieldVector(FractionField.getInstance(), 7); + ArrayFieldVector v1 = new ArrayFieldVector<>(FractionField.getInstance(), 7); Assert.assertEquals(7, v1.getDimension()); Assert.assertEquals(Fraction.ZERO, v1.getEntry(6)); - ArrayFieldVector v2 = new ArrayFieldVector(5, new Fraction(123, 100)); + ArrayFieldVector v2 = new ArrayFieldVector<>(5, new Fraction(123, 100)); Assert.assertEquals(5, v2.getDimension()); Assert.assertEquals(new Fraction(123, 100), v2.getEntry(4)); - ArrayFieldVector v3 = new ArrayFieldVector(FractionField.getInstance(), vec1); + ArrayFieldVector v3 = new ArrayFieldVector<>(FractionField.getInstance(), vec1); Assert.assertEquals(3, v3.getDimension()); Assert.assertEquals(new Fraction(2), v3.getEntry(1)); - ArrayFieldVector v4 = new ArrayFieldVector(FractionField.getInstance(), vec4, 3, 2); + ArrayFieldVector v4 = new ArrayFieldVector<>(FractionField.getInstance(), vec4, 3, 2); Assert.assertEquals(2, v4.getDimension()); Assert.assertEquals(new Fraction(4), v4.getEntry(0)); try { - new ArrayFieldVector(vec4, 8, 3); + new ArrayFieldVector<>(vec4, 8, 3); Assert.fail("MathIllegalArgumentException expected"); } catch (MathIllegalArgumentException ex) { // expected behavior } - FieldVector v5_i = new ArrayFieldVector(dvec1); + FieldVector v5_i = new ArrayFieldVector<>(dvec1); Assert.assertEquals(9, v5_i.getDimension()); Assert.assertEquals(new Fraction(9), v5_i.getEntry(8)); - ArrayFieldVector v5 = new ArrayFieldVector(dvec1); + ArrayFieldVector v5 = new ArrayFieldVector<>(dvec1); Assert.assertEquals(9, v5.getDimension()); Assert.assertEquals(new Fraction(9), v5.getEntry(8)); - ArrayFieldVector v6 = new ArrayFieldVector(dvec1, 3, 2); + ArrayFieldVector v6 = new ArrayFieldVector<>(dvec1, 3, 2); Assert.assertEquals(2, v6.getDimension()); Assert.assertEquals(new Fraction(4), v6.getEntry(0)); try { - new ArrayFieldVector(dvec1, 8, 3); + new ArrayFieldVector<>(dvec1, 8, 3); Assert.fail("MathIllegalArgumentException expected"); } catch (MathIllegalArgumentException ex) { // expected behavior } - ArrayFieldVector v7 = new ArrayFieldVector(v1); + ArrayFieldVector v7 = new ArrayFieldVector<>(v1); Assert.assertEquals(7, v7.getDimension()); Assert.assertEquals(Fraction.ZERO, v7.getEntry(6)); - FieldVectorTestImpl v7_i = new FieldVectorTestImpl(vec1); + FieldVectorTestImpl v7_i = new FieldVectorTestImpl<>(vec1); - ArrayFieldVector v7_2 = new ArrayFieldVector(v7_i); + ArrayFieldVector v7_2 = new ArrayFieldVector<>(v7_i); Assert.assertEquals(3, v7_2.getDimension()); Assert.assertEquals(new Fraction(2), v7_2.getEntry(1)); - ArrayFieldVector v8 = new ArrayFieldVector(v1, true); + ArrayFieldVector v8 = new ArrayFieldVector<>(v1, true); Assert.assertEquals(7, v8.getDimension()); Assert.assertEquals(Fraction.ZERO, v8.getEntry(6)); Assert.assertNotSame("testData not same object ", v1.getDataRef(), v8.getDataRef()); - ArrayFieldVector v8_2 = new ArrayFieldVector(v1, false); + ArrayFieldVector v8_2 = new ArrayFieldVector<>(v1, false); Assert.assertEquals(7, v8_2.getDimension()); Assert.assertEquals(Fraction.ZERO, v8_2.getEntry(6)); Assert.assertArrayEquals(v1.getDataRef(), v8_2.getDataRef()); - ArrayFieldVector v9 = new ArrayFieldVector((FieldVector) v1, (FieldVector) v3); + ArrayFieldVector v9 = new ArrayFieldVector<>((FieldVector) v1, (FieldVector) v3); Assert.assertEquals(10, v9.getDimension()); Assert.assertEquals(new Fraction(1), v9.getEntry(7)); @@ -335,10 +335,10 @@ public void testConstructors() { @Test public void testDataInOut() { - ArrayFieldVector v1 = new ArrayFieldVector(vec1); - ArrayFieldVector v2 = new ArrayFieldVector(vec2); - ArrayFieldVector v4 = new ArrayFieldVector(vec4); - FieldVectorTestImpl v2_t = new FieldVectorTestImpl(vec2); + ArrayFieldVector v1 = new ArrayFieldVector<>(vec1); + ArrayFieldVector v2 = new ArrayFieldVector<>(vec2); + ArrayFieldVector v4 = new ArrayFieldVector<>(vec4); + FieldVectorTestImpl v2_t = new FieldVectorTestImpl<>(vec2); FieldVector v_append_1 = v1.append(v2); Assert.assertEquals(6, v_append_1.getDimension()); @@ -430,7 +430,7 @@ public void testDataInOut() { @Test public void testMapFunctions() { - ArrayFieldVector v1 = new ArrayFieldVector(vec1); + ArrayFieldVector v1 = new ArrayFieldVector<>(vec1); //octave = v1 .+ 2.0 FieldVector v_mapAdd = v1.mapAdd(new Fraction(2)); @@ -491,18 +491,18 @@ public void testMapFunctions() { @Test public void testBasicFunctions() { - ArrayFieldVector v1 = new ArrayFieldVector(vec1); - ArrayFieldVector v2 = new ArrayFieldVector(vec2); - new ArrayFieldVector(vec_null); + ArrayFieldVector v1 = new ArrayFieldVector<>(vec1); + ArrayFieldVector v2 = new ArrayFieldVector<>(vec2); + new ArrayFieldVector<>(vec_null); - FieldVectorTestImpl v2_t = new FieldVectorTestImpl(vec2); + FieldVectorTestImpl v2_t = new FieldVectorTestImpl<>(vec2); //octave = v1 + v2 ArrayFieldVector v_add = v1.add(v2); Fraction[] result_add = {new Fraction(5), new Fraction(7), new Fraction(9)}; checkArray("compare vect" ,v_add.toArray(),result_add); - FieldVectorTestImpl vt2 = new FieldVectorTestImpl(vec2); + FieldVectorTestImpl vt2 = new FieldVectorTestImpl<>(vec2); FieldVector v_add_i = v1.add(vt2); Fraction[] result_add_i = {new Fraction(5), new Fraction(7), new Fraction(9)}; checkArray("compare vect" ,v_add_i.toArray(),result_add_i); @@ -560,9 +560,9 @@ public void testBasicFunctions() { @Test public void testMisc() { - ArrayFieldVector v1 = new ArrayFieldVector(vec1); - ArrayFieldVector v4 = new ArrayFieldVector(vec4); - FieldVector v4_2 = new ArrayFieldVector(vec4); + ArrayFieldVector v1 = new ArrayFieldVector<>(vec1); + ArrayFieldVector v4 = new ArrayFieldVector<>(vec4); + FieldVector v4_2 = new ArrayFieldVector<>(vec4); String out1 = v1.toString(); Assert.assertTrue("some output ", out1.length()!=0); @@ -596,7 +596,7 @@ public void testMisc() { @Test public void testSerial() { - ArrayFieldVector v = new ArrayFieldVector(vec1); + ArrayFieldVector v = new ArrayFieldVector<>(vec1); Assert.assertEquals(v,TestUtils.serializeAndRecover(v)); } @@ -605,40 +605,40 @@ public void testZeroVectors() { // when the field is not specified, array cannot be empty try { - new ArrayFieldVector(new Fraction[0]); + new ArrayFieldVector<>(new Fraction[0]); Assert.fail("MathIllegalArgumentException expected"); } catch (MathIllegalArgumentException ex) { // expected behavior } try { - new ArrayFieldVector(new Fraction[0], true); + new ArrayFieldVector<>(new Fraction[0], true); Assert.fail("MathIllegalArgumentException expected"); } catch (MathIllegalArgumentException ex) { // expected behavior } try { - new ArrayFieldVector(new Fraction[0], false); + new ArrayFieldVector<>(new Fraction[0], false); Assert.fail("MathIllegalArgumentException expected"); } catch (MathIllegalArgumentException ex) { // expected behavior } // when the field is specified, array can be empty - Assert.assertEquals(0, new ArrayFieldVector(FractionField.getInstance(), new Fraction[0]).getDimension()); - Assert.assertEquals(0, new ArrayFieldVector(FractionField.getInstance(), new Fraction[0], true).getDimension()); - Assert.assertEquals(0, new ArrayFieldVector(FractionField.getInstance(), new Fraction[0], false).getDimension()); + Assert.assertEquals(0, new ArrayFieldVector<>(FractionField.getInstance(), new Fraction[0]).getDimension()); + Assert.assertEquals(0, new ArrayFieldVector<>(FractionField.getInstance(), new Fraction[0], true).getDimension()); + Assert.assertEquals(0, new ArrayFieldVector<>(FractionField.getInstance(), new Fraction[0], false).getDimension()); } @Test public void testOuterProduct() { final ArrayFieldVector u - = new ArrayFieldVector(FractionField.getInstance(), + = new ArrayFieldVector<>(FractionField.getInstance(), new Fraction[] {new Fraction(1), new Fraction(2), new Fraction(-3)}); final ArrayFieldVector v - = new ArrayFieldVector(FractionField.getInstance(), + = new ArrayFieldVector<>(FractionField.getInstance(), new Fraction[] {new Fraction(4), new Fraction(-2)}); @@ -675,7 +675,7 @@ public void testWalkInDefaultOrderPreservingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector(data); + final ArrayFieldVector v = new ArrayFieldVector<>(data); final FieldVectorPreservingVisitor visitor; visitor = new FieldVectorPreservingVisitor() { @@ -762,7 +762,7 @@ public void testWalkInDefaultOrderPreservingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector(data); + final ArrayFieldVector v = new ArrayFieldVector<>(data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorPreservingVisitor visitor; @@ -800,7 +800,7 @@ public void testWalkInOptimizedOrderPreservingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector(data); + final ArrayFieldVector v = new ArrayFieldVector<>(data); final FieldVectorPreservingVisitor visitor; visitor = new FieldVectorPreservingVisitor() { private final boolean[] visited = new boolean[data.length]; @@ -889,7 +889,7 @@ public void testWalkInOptimizedOrderPreservingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector(data); + final ArrayFieldVector v = new ArrayFieldVector<>(data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorPreservingVisitor visitor; @@ -929,7 +929,7 @@ public void testWalkInDefaultOrderChangingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector(data); + final ArrayFieldVector v = new ArrayFieldVector<>(data); final FieldVectorChangingVisitor visitor; visitor = new FieldVectorChangingVisitor() { @@ -1020,7 +1020,7 @@ public void testWalkInDefaultOrderChangingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector(data); + final ArrayFieldVector v = new ArrayFieldVector<>(data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorChangingVisitor visitor; @@ -1062,7 +1062,7 @@ public void testWalkInOptimizedOrderChangingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector(data); + final ArrayFieldVector v = new ArrayFieldVector<>(data); final FieldVectorChangingVisitor visitor; visitor = new FieldVectorChangingVisitor() { private final boolean[] visited = new boolean[data.length]; @@ -1155,7 +1155,7 @@ public void testWalkInOptimizedOrderChangingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector(data); + final ArrayFieldVector v = new ArrayFieldVector<>(data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorChangingVisitor visitor; @@ -1196,6 +1196,6 @@ private ArrayFieldVector create(int n) { for (int i = 0; i < n; ++i) { t[i] = Fraction.ZERO; } - return new ArrayFieldVector(t); + return new ArrayFieldVector<>(t); } } diff --git a/src/test/java/org/apache/commons/math4/linear/BlockFieldMatrixTest.java b/src/test/java/org/apache/commons/math4/linear/BlockFieldMatrixTest.java index 00dde9df66..57c9cb7de7 100644 --- a/src/test/java/org/apache/commons/math4/linear/BlockFieldMatrixTest.java +++ b/src/test/java/org/apache/commons/math4/linear/BlockFieldMatrixTest.java @@ -167,8 +167,8 @@ public final class BlockFieldMatrixTest { /** test dimensions */ @Test public void testDimensions() { - BlockFieldMatrix m = new BlockFieldMatrix(testData); - BlockFieldMatrix m2 = new BlockFieldMatrix(testData2); + BlockFieldMatrix m = new BlockFieldMatrix<>(testData); + BlockFieldMatrix m2 = new BlockFieldMatrix<>(testData2); Assert.assertEquals("testData row dimension",3,m.getRowDimension()); Assert.assertEquals("testData column dimension",3,m.getColumnDimension()); Assert.assertTrue("testData is square",m.isSquare()); @@ -182,18 +182,18 @@ public void testDimensions() { public void testCopyFunctions() { Random r = new Random(66636328996002l); BlockFieldMatrix m1 = createRandomMatrix(r, 47, 83); - BlockFieldMatrix m2 = new BlockFieldMatrix(m1.getData()); + BlockFieldMatrix m2 = new BlockFieldMatrix<>(m1.getData()); Assert.assertEquals(m1, m2); - BlockFieldMatrix m3 = new BlockFieldMatrix(testData); - BlockFieldMatrix m4 = new BlockFieldMatrix(m3.getData()); + BlockFieldMatrix m3 = new BlockFieldMatrix<>(testData); + BlockFieldMatrix m4 = new BlockFieldMatrix<>(m3.getData()); Assert.assertEquals(m3, m4); } /** test add */ @Test public void testAdd() { - BlockFieldMatrix m = new BlockFieldMatrix(testData); - BlockFieldMatrix mInv = new BlockFieldMatrix(testDataInv); + BlockFieldMatrix m = new BlockFieldMatrix<>(testData); + BlockFieldMatrix mInv = new BlockFieldMatrix<>(testDataInv); FieldMatrix mPlusMInv = m.add(mInv); Fraction[][] sumEntries = mPlusMInv.getData(); for (int row = 0; row < m.getRowDimension(); row++) { @@ -206,8 +206,8 @@ public void testAdd() { /** test add failure */ @Test public void testAddFail() { - BlockFieldMatrix m = new BlockFieldMatrix(testData); - BlockFieldMatrix m2 = new BlockFieldMatrix(testData2); + BlockFieldMatrix m = new BlockFieldMatrix<>(testData); + BlockFieldMatrix m2 = new BlockFieldMatrix<>(testData2); try { m.add(m2); Assert.fail("MathIllegalArgumentException expected"); @@ -219,11 +219,11 @@ public void testAddFail() { /** test m-n = m + -n */ @Test public void testPlusMinus() { - BlockFieldMatrix m = new BlockFieldMatrix(testData); - BlockFieldMatrix m2 = new BlockFieldMatrix(testDataInv); + BlockFieldMatrix m = new BlockFieldMatrix<>(testData); + BlockFieldMatrix m2 = new BlockFieldMatrix<>(testDataInv); TestUtils.assertEquals(m.subtract(m2), m2.scalarMultiply(new Fraction(-1)).add(m)); try { - m.subtract(new BlockFieldMatrix(testData2)); + m.subtract(new BlockFieldMatrix<>(testData2)); Assert.fail("Expecting illegalArgumentException"); } catch (MathIllegalArgumentException ex) { // ignored @@ -233,17 +233,17 @@ public void testPlusMinus() { /** test multiply */ @Test public void testMultiply() { - BlockFieldMatrix m = new BlockFieldMatrix(testData); - BlockFieldMatrix mInv = new BlockFieldMatrix(testDataInv); - BlockFieldMatrix identity = new BlockFieldMatrix(id); - BlockFieldMatrix m2 = new BlockFieldMatrix(testData2); + BlockFieldMatrix m = new BlockFieldMatrix<>(testData); + BlockFieldMatrix mInv = new BlockFieldMatrix<>(testDataInv); + BlockFieldMatrix identity = new BlockFieldMatrix<>(id); + BlockFieldMatrix m2 = new BlockFieldMatrix<>(testData2); TestUtils.assertEquals(m.multiply(mInv), identity); TestUtils.assertEquals(mInv.multiply(m), identity); TestUtils.assertEquals(m.multiply(identity), m); TestUtils.assertEquals(identity.multiply(mInv), mInv); TestUtils.assertEquals(m2.multiply(identity), m2); try { - m.multiply(new BlockFieldMatrix(bigSingular)); + m.multiply(new BlockFieldMatrix<>(bigSingular)); Assert.fail("Expecting illegalArgumentException"); } catch (MathIllegalArgumentException ex) { // expected @@ -253,7 +253,7 @@ public void testMultiply() { @Test public void testSeveralBlocks() { FieldMatrix m = - new BlockFieldMatrix(FractionField.getInstance(), 37, 41); + new BlockFieldMatrix<>(FractionField.getInstance(), 37, 41); for (int i = 0; i < m.getRowDimension(); ++i) { for (int j = 0; j < m.getColumnDimension(); ++j) { m.setEntry(i, j, new Fraction(i * 11 + j, 11)); @@ -351,18 +351,18 @@ public void testSeveralBlocks() { @Test public void testMultiply2() { - FieldMatrix m3 = new BlockFieldMatrix(d3); - FieldMatrix m4 = new BlockFieldMatrix(d4); - FieldMatrix m5 = new BlockFieldMatrix(d5); + FieldMatrix m3 = new BlockFieldMatrix<>(d3); + FieldMatrix m4 = new BlockFieldMatrix<>(d4); + FieldMatrix m5 = new BlockFieldMatrix<>(d5); TestUtils.assertEquals(m3.multiply(m4), m5); } /** test trace */ @Test public void testTrace() { - FieldMatrix m = new BlockFieldMatrix(id); + FieldMatrix m = new BlockFieldMatrix<>(id); Assert.assertEquals(new Fraction(3),m.getTrace()); - m = new BlockFieldMatrix(testData2); + m = new BlockFieldMatrix<>(testData2); try { m.getTrace(); Assert.fail("Expecting NonSquareMatrixException"); @@ -374,18 +374,18 @@ public void testTrace() { /** test scalarAdd */ @Test public void testScalarAdd() { - FieldMatrix m = new BlockFieldMatrix(testData); - TestUtils.assertEquals(new BlockFieldMatrix(testDataPlus2), + FieldMatrix m = new BlockFieldMatrix<>(testData); + TestUtils.assertEquals(new BlockFieldMatrix<>(testDataPlus2), m.scalarAdd(new Fraction(2))); } /** test operate */ @Test public void testOperate() { - FieldMatrix m = new BlockFieldMatrix(id); + FieldMatrix m = new BlockFieldMatrix<>(id); TestUtils.assertEquals(testVector, m.operate(testVector)); - TestUtils.assertEquals(testVector, m.operate(new ArrayFieldVector(testVector)).toArray()); - m = new BlockFieldMatrix(bigSingular); + TestUtils.assertEquals(testVector, m.operate(new ArrayFieldVector<>(testVector)).toArray()); + m = new BlockFieldMatrix<>(bigSingular); try { m.operate(testVector); Assert.fail("Expecting illegalArgumentException"); @@ -425,7 +425,7 @@ public void testOperatePremultiplyLarge() { /** test issue MATH-209 */ @Test public void testMath209() { - FieldMatrix a = new BlockFieldMatrix(new Fraction[][] { + FieldMatrix a = new BlockFieldMatrix<>(new Fraction[][] { { new Fraction(1), new Fraction(2) }, { new Fraction(3), new Fraction(4) }, { new Fraction(5), new Fraction(6) } @@ -440,23 +440,23 @@ public void testMath209() { /** test transpose */ @Test public void testTranspose() { - FieldMatrix m = new BlockFieldMatrix(testData); - FieldMatrix mIT = new FieldLUDecomposition(m).getSolver().getInverse().transpose(); - FieldMatrix mTI = new FieldLUDecomposition(m.transpose()).getSolver().getInverse(); + FieldMatrix m = new BlockFieldMatrix<>(testData); + FieldMatrix mIT = new FieldLUDecomposition<>(m).getSolver().getInverse().transpose(); + FieldMatrix mTI = new FieldLUDecomposition<>(m.transpose()).getSolver().getInverse(); TestUtils.assertEquals(mIT, mTI); - m = new BlockFieldMatrix(testData2); - FieldMatrix mt = new BlockFieldMatrix(testData2T); + m = new BlockFieldMatrix<>(testData2); + FieldMatrix mt = new BlockFieldMatrix<>(testData2T); TestUtils.assertEquals(mt, m.transpose()); } /** test preMultiply by vector */ @Test public void testPremultiplyVector() { - FieldMatrix m = new BlockFieldMatrix(testData); + FieldMatrix m = new BlockFieldMatrix<>(testData); TestUtils.assertEquals(m.preMultiply(testVector), preMultTest); - TestUtils.assertEquals(m.preMultiply(new ArrayFieldVector(testVector).toArray()), + TestUtils.assertEquals(m.preMultiply(new ArrayFieldVector<>(testVector).toArray()), preMultTest); - m = new BlockFieldMatrix(bigSingular); + m = new BlockFieldMatrix<>(bigSingular); try { m.preMultiply(testVector); Assert.fail("expecting MathIllegalArgumentException"); @@ -467,20 +467,20 @@ public void testPremultiplyVector() { @Test public void testPremultiply() { - FieldMatrix m3 = new BlockFieldMatrix(d3); - FieldMatrix m4 = new BlockFieldMatrix(d4); - FieldMatrix m5 = new BlockFieldMatrix(d5); + FieldMatrix m3 = new BlockFieldMatrix<>(d3); + FieldMatrix m4 = new BlockFieldMatrix<>(d4); + FieldMatrix m5 = new BlockFieldMatrix<>(d5); TestUtils.assertEquals(m4.preMultiply(m3), m5); - BlockFieldMatrix m = new BlockFieldMatrix(testData); - BlockFieldMatrix mInv = new BlockFieldMatrix(testDataInv); - BlockFieldMatrix identity = new BlockFieldMatrix(id); + BlockFieldMatrix m = new BlockFieldMatrix<>(testData); + BlockFieldMatrix mInv = new BlockFieldMatrix<>(testDataInv); + BlockFieldMatrix identity = new BlockFieldMatrix<>(id); TestUtils.assertEquals(m.preMultiply(mInv), identity); TestUtils.assertEquals(mInv.preMultiply(m), identity); TestUtils.assertEquals(m.preMultiply(identity), m); TestUtils.assertEquals(identity.preMultiply(mInv), mInv); try { - m.preMultiply(new BlockFieldMatrix(bigSingular)); + m.preMultiply(new BlockFieldMatrix<>(bigSingular)); Assert.fail("Expecting illegalArgumentException"); } catch (MathIllegalArgumentException ex) { // ignored @@ -489,7 +489,7 @@ public void testPremultiply() { @Test public void testGetVectors() { - FieldMatrix m = new BlockFieldMatrix(testData); + FieldMatrix m = new BlockFieldMatrix<>(testData); TestUtils.assertEquals(m.getRow(0), testDataRow1); TestUtils.assertEquals(m.getColumn(2), testDataCol3); try { @@ -508,7 +508,7 @@ public void testGetVectors() { @Test public void testGetEntry() { - FieldMatrix m = new BlockFieldMatrix(testData); + FieldMatrix m = new BlockFieldMatrix<>(testData); Assert.assertEquals(m.getEntry(0,1),new Fraction(2)); try { m.getEntry(10, 4); @@ -526,20 +526,20 @@ public void testExamples() { {new Fraction(1),new Fraction(2),new Fraction(3)}, {new Fraction(2),new Fraction(5),new Fraction(3)} }; - FieldMatrix m = new BlockFieldMatrix(matrixData); + FieldMatrix m = new BlockFieldMatrix<>(matrixData); // One more with three rows, two columns Fraction[][] matrixData2 = { {new Fraction(1),new Fraction(2)}, {new Fraction(2),new Fraction(5)}, {new Fraction(1), new Fraction(7)} }; - FieldMatrix n = new BlockFieldMatrix(matrixData2); + FieldMatrix n = new BlockFieldMatrix<>(matrixData2); // Now multiply m by n FieldMatrix p = m.multiply(n); Assert.assertEquals(2, p.getRowDimension()); Assert.assertEquals(2, p.getColumnDimension()); // Invert p - FieldMatrix pInverse = new FieldLUDecomposition(p).getSolver().getInverse(); + FieldMatrix pInverse = new FieldLUDecomposition<>(p).getSolver().getInverse(); Assert.assertEquals(2, pInverse.getRowDimension()); Assert.assertEquals(2, pInverse.getColumnDimension()); @@ -549,14 +549,14 @@ public void testExamples() { {new Fraction(-1), new Fraction(7), new Fraction(6)}, {new Fraction(4), new Fraction(-3), new Fraction(-5)} }; - FieldMatrix coefficients = new BlockFieldMatrix(coefficientsData); + FieldMatrix coefficients = new BlockFieldMatrix<>(coefficientsData); Fraction[] constants = { new Fraction(1), new Fraction(-2), new Fraction(1) }; Fraction[] solution; - solution = new FieldLUDecomposition(coefficients) + solution = new FieldLUDecomposition<>(coefficients) .getSolver() - .solve(new ArrayFieldVector(constants, false)).toArray(); + .solve(new ArrayFieldVector<>(constants, false)).toArray(); Assert.assertEquals(new Fraction(2).multiply(solution[0]). add(new Fraction(3).multiply(solution[1])). subtract(new Fraction(2).multiply(solution[2])), @@ -575,7 +575,7 @@ public void testExamples() { // test submatrix accessors @Test public void testGetSubMatrix() { - FieldMatrix m = new BlockFieldMatrix(subTestData); + FieldMatrix m = new BlockFieldMatrix<>(subTestData); checkGetSubMatrix(m, subRows23Cols00, 2 , 3 , 0, 0); checkGetSubMatrix(m, subRows00Cols33, 0 , 0 , 3, 3); checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3); @@ -598,7 +598,7 @@ private void checkGetSubMatrix(FieldMatrix m, Fraction[][] reference, try { FieldMatrix sub = m.getSubMatrix(startRow, endRow, startColumn, endColumn); if (reference != null) { - Assert.assertEquals(new BlockFieldMatrix(reference), sub); + Assert.assertEquals(new BlockFieldMatrix<>(reference), sub); } else { Assert.fail("Expecting OutOfRangeException or NotStrictlyPositiveException" + " or NumberIsTooSmallException or NoDataException"); @@ -627,7 +627,7 @@ private void checkGetSubMatrix(FieldMatrix m, Fraction[][] reference, try { FieldMatrix sub = m.getSubMatrix(selectedRows, selectedColumns); if (reference != null) { - Assert.assertEquals(new BlockFieldMatrix(reference), sub); + Assert.assertEquals(new BlockFieldMatrix<>(reference), sub); } else { Assert.fail("Expecting OutOfRangeException"); } @@ -654,9 +654,9 @@ private void checkGetSubMatrix(FieldMatrix m, Fraction[][] reference, public void testGetSetMatrixLarge() { int n = 3 * BlockFieldMatrix.BLOCK_SIZE; FieldMatrix m = - new BlockFieldMatrix(FractionField.getInstance(), n, n); + new BlockFieldMatrix<>(FractionField.getInstance(), n, n); FieldMatrix sub = - new BlockFieldMatrix(FractionField.getInstance(), n - 4, n - 4).scalarAdd(new Fraction(1)); + new BlockFieldMatrix<>(FractionField.getInstance(), n - 4, n - 4).scalarAdd(new Fraction(1)); m.setSubMatrix(sub.getData(), 2, 2); for (int i = 0; i < n; ++i) { @@ -673,7 +673,7 @@ public void testGetSetMatrixLarge() { @Test public void testCopySubMatrix() { - FieldMatrix m = new BlockFieldMatrix(subTestData); + FieldMatrix m = new BlockFieldMatrix<>(subTestData); checkCopy(m, subRows23Cols00, 2 , 3 , 0, 0); checkCopy(m, subRows00Cols33, 0 , 0 , 3, 3); checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3); @@ -700,7 +700,7 @@ private void checkCopy(FieldMatrix m, Fraction[][] reference, new Fraction[reference.length][reference[0].length]; m.copySubMatrix(startRow, endRow, startColumn, endColumn, sub); if (reference != null) { - Assert.assertEquals(new BlockFieldMatrix(reference), new BlockFieldMatrix(sub)); + Assert.assertEquals(new BlockFieldMatrix<>(reference), new BlockFieldMatrix<>(sub)); } else { Assert.fail("Expecting OutOfRangeException or NumberIsTooSmallException or NoDataException"); } @@ -727,7 +727,7 @@ private void checkCopy(FieldMatrix m, Fraction[][] reference, new Fraction[reference.length][reference[0].length]; m.copySubMatrix(selectedRows, selectedColumns, sub); if (reference != null) { - Assert.assertEquals(new BlockFieldMatrix(reference), new BlockFieldMatrix(sub)); + Assert.assertEquals(new BlockFieldMatrix<>(reference), new BlockFieldMatrix<>(sub)); } else { Assert.fail("Expecting OutOfRangeException or NumberIsTooSmallException or NoDataException"); } @@ -748,9 +748,9 @@ private void checkCopy(FieldMatrix m, Fraction[][] reference, @Test public void testGetRowMatrix() { - FieldMatrix m = new BlockFieldMatrix(subTestData); - FieldMatrix mRow0 = new BlockFieldMatrix(subRow0); - FieldMatrix mRow3 = new BlockFieldMatrix(subRow3); + FieldMatrix m = new BlockFieldMatrix<>(subTestData); + FieldMatrix mRow0 = new BlockFieldMatrix<>(subRow0); + FieldMatrix mRow3 = new BlockFieldMatrix<>(subRow3); Assert.assertEquals("Row0", mRow0, m.getRowMatrix(0)); Assert.assertEquals("Row3", mRow3, m.getRowMatrix(3)); try { @@ -769,8 +769,8 @@ public void testGetRowMatrix() { @Test public void testSetRowMatrix() { - FieldMatrix m = new BlockFieldMatrix(subTestData); - FieldMatrix mRow3 = new BlockFieldMatrix(subRow3); + FieldMatrix m = new BlockFieldMatrix<>(subTestData); + FieldMatrix mRow3 = new BlockFieldMatrix<>(subRow3); Assert.assertNotSame(mRow3, m.getRowMatrix(0)); m.setRowMatrix(0, mRow3); Assert.assertEquals(mRow3, m.getRowMatrix(0)); @@ -792,9 +792,9 @@ public void testSetRowMatrix() { public void testGetSetRowMatrixLarge() { int n = 3 * BlockFieldMatrix.BLOCK_SIZE; FieldMatrix m = - new BlockFieldMatrix(FractionField.getInstance(), n, n); + new BlockFieldMatrix<>(FractionField.getInstance(), n, n); FieldMatrix sub = - new BlockFieldMatrix(FractionField.getInstance(), 1, n).scalarAdd(new Fraction(1)); + new BlockFieldMatrix<>(FractionField.getInstance(), 1, n).scalarAdd(new Fraction(1)); m.setRowMatrix(2, sub); for (int i = 0; i < n; ++i) { @@ -812,9 +812,9 @@ public void testGetSetRowMatrixLarge() { @Test public void testGetColumnMatrix() { - FieldMatrix m = new BlockFieldMatrix(subTestData); - FieldMatrix mColumn1 = new BlockFieldMatrix(subColumn1); - FieldMatrix mColumn3 = new BlockFieldMatrix(subColumn3); + FieldMatrix m = new BlockFieldMatrix<>(subTestData); + FieldMatrix mColumn1 = new BlockFieldMatrix<>(subColumn1); + FieldMatrix mColumn3 = new BlockFieldMatrix<>(subColumn3); Assert.assertEquals(mColumn1, m.getColumnMatrix(1)); Assert.assertEquals(mColumn3, m.getColumnMatrix(3)); try { @@ -833,8 +833,8 @@ public void testGetColumnMatrix() { @Test public void testSetColumnMatrix() { - FieldMatrix m = new BlockFieldMatrix(subTestData); - FieldMatrix mColumn3 = new BlockFieldMatrix(subColumn3); + FieldMatrix m = new BlockFieldMatrix<>(subTestData); + FieldMatrix mColumn3 = new BlockFieldMatrix<>(subColumn3); Assert.assertNotSame(mColumn3, m.getColumnMatrix(1)); m.setColumnMatrix(1, mColumn3); Assert.assertEquals(mColumn3, m.getColumnMatrix(1)); @@ -856,9 +856,9 @@ public void testSetColumnMatrix() { public void testGetSetColumnMatrixLarge() { int n = 3 * BlockFieldMatrix.BLOCK_SIZE; FieldMatrix m = - new BlockFieldMatrix(FractionField.getInstance(), n, n); + new BlockFieldMatrix<>(FractionField.getInstance(), n, n); FieldMatrix sub = - new BlockFieldMatrix(FractionField.getInstance(), n, 1).scalarAdd(new Fraction(1)); + new BlockFieldMatrix<>(FractionField.getInstance(), n, 1).scalarAdd(new Fraction(1)); m.setColumnMatrix(2, sub); for (int i = 0; i < n; ++i) { @@ -876,9 +876,9 @@ public void testGetSetColumnMatrixLarge() { @Test public void testGetRowVector() { - FieldMatrix m = new BlockFieldMatrix(subTestData); - FieldVector mRow0 = new ArrayFieldVector(subRow0[0]); - FieldVector mRow3 = new ArrayFieldVector(subRow3[0]); + FieldMatrix m = new BlockFieldMatrix<>(subTestData); + FieldVector mRow0 = new ArrayFieldVector<>(subRow0[0]); + FieldVector mRow3 = new ArrayFieldVector<>(subRow3[0]); Assert.assertEquals(mRow0, m.getRowVector(0)); Assert.assertEquals(mRow3, m.getRowVector(3)); try { @@ -897,8 +897,8 @@ public void testGetRowVector() { @Test public void testSetRowVector() { - FieldMatrix m = new BlockFieldMatrix(subTestData); - FieldVector mRow3 = new ArrayFieldVector(subRow3[0]); + FieldMatrix m = new BlockFieldMatrix<>(subTestData); + FieldVector mRow3 = new ArrayFieldVector<>(subRow3[0]); Assert.assertNotSame(mRow3, m.getRowMatrix(0)); m.setRowVector(0, mRow3); Assert.assertEquals(mRow3, m.getRowVector(0)); @@ -909,7 +909,7 @@ public void testSetRowVector() { // expected } try { - m.setRowVector(0, new ArrayFieldVector(FractionField.getInstance(), 5)); + m.setRowVector(0, new ArrayFieldVector<>(FractionField.getInstance(), 5)); Assert.fail("Expecting MatrixDimensionMismatchException"); } catch (MatrixDimensionMismatchException ex) { // expected @@ -919,8 +919,8 @@ public void testSetRowVector() { @Test public void testGetSetRowVectorLarge() { int n = 3 * BlockFieldMatrix.BLOCK_SIZE; - FieldMatrix m = new BlockFieldMatrix(FractionField.getInstance(), n, n); - FieldVector sub = new ArrayFieldVector(n, new Fraction(1)); + FieldMatrix m = new BlockFieldMatrix<>(FractionField.getInstance(), n, n); + FieldVector sub = new ArrayFieldVector<>(n, new Fraction(1)); m.setRowVector(2, sub); for (int i = 0; i < n; ++i) { @@ -938,7 +938,7 @@ public void testGetSetRowVectorLarge() { @Test public void testGetColumnVector() { - FieldMatrix m = new BlockFieldMatrix(subTestData); + FieldMatrix m = new BlockFieldMatrix<>(subTestData); FieldVector mColumn1 = columnToVector(subColumn1); FieldVector mColumn3 = columnToVector(subColumn3); Assert.assertEquals(mColumn1, m.getColumnVector(1)); @@ -959,7 +959,7 @@ public void testGetColumnVector() { @Test public void testSetColumnVector() { - FieldMatrix m = new BlockFieldMatrix(subTestData); + FieldMatrix m = new BlockFieldMatrix<>(subTestData); FieldVector mColumn3 = columnToVector(subColumn3); Assert.assertNotSame(mColumn3, m.getColumnVector(1)); m.setColumnVector(1, mColumn3); @@ -971,7 +971,7 @@ public void testSetColumnVector() { // expected } try { - m.setColumnVector(0, new ArrayFieldVector(FractionField.getInstance(), 5)); + m.setColumnVector(0, new ArrayFieldVector<>(FractionField.getInstance(), 5)); Assert.fail("Expecting MatrixDimensionMismatchException"); } catch (MatrixDimensionMismatchException ex) { // expected @@ -981,8 +981,8 @@ public void testSetColumnVector() { @Test public void testGetSetColumnVectorLarge() { int n = 3 * BlockFieldMatrix.BLOCK_SIZE; - FieldMatrix m = new BlockFieldMatrix(FractionField.getInstance(), n, n); - FieldVector sub = new ArrayFieldVector(n, new Fraction(1)); + FieldMatrix m = new BlockFieldMatrix<>(FractionField.getInstance(), n, n); + FieldVector sub = new ArrayFieldVector<>(n, new Fraction(1)); m.setColumnVector(2, sub); for (int i = 0; i < n; ++i) { @@ -1003,12 +1003,12 @@ private FieldVector columnToVector(Fraction[][] column) { for (int i = 0; i < data.length; ++i) { data[i] = column[i][0]; } - return new ArrayFieldVector(data, false); + return new ArrayFieldVector<>(data, false); } @Test public void testGetRow() { - FieldMatrix m = new BlockFieldMatrix(subTestData); + FieldMatrix m = new BlockFieldMatrix<>(subTestData); checkArrays(subRow0[0], m.getRow(0)); checkArrays(subRow3[0], m.getRow(3)); try { @@ -1027,7 +1027,7 @@ public void testGetRow() { @Test public void testSetRow() { - FieldMatrix m = new BlockFieldMatrix(subTestData); + FieldMatrix m = new BlockFieldMatrix<>(subTestData); Assert.assertTrue(subRow3[0][0] != m.getRow(0)[0]); m.setRow(0, subRow3[0]); checkArrays(subRow3[0], m.getRow(0)); @@ -1048,7 +1048,7 @@ public void testSetRow() { @Test public void testGetSetRowLarge() { int n = 3 * BlockFieldMatrix.BLOCK_SIZE; - FieldMatrix m = new BlockFieldMatrix(FractionField.getInstance(), n, n); + FieldMatrix m = new BlockFieldMatrix<>(FractionField.getInstance(), n, n); Fraction[] sub = new Fraction[n]; Arrays.fill(sub, new Fraction(1)); @@ -1068,7 +1068,7 @@ public void testGetSetRowLarge() { @Test public void testGetColumn() { - FieldMatrix m = new BlockFieldMatrix(subTestData); + FieldMatrix m = new BlockFieldMatrix<>(subTestData); Fraction[] mColumn1 = columnToArray(subColumn1); Fraction[] mColumn3 = columnToArray(subColumn3); checkArrays(mColumn1, m.getColumn(1)); @@ -1089,7 +1089,7 @@ public void testGetColumn() { @Test public void testSetColumn() { - FieldMatrix m = new BlockFieldMatrix(subTestData); + FieldMatrix m = new BlockFieldMatrix<>(subTestData); Fraction[] mColumn3 = columnToArray(subColumn3); Assert.assertTrue(mColumn3[0] != m.getColumn(1)[0]); m.setColumn(1, mColumn3); @@ -1111,7 +1111,7 @@ public void testSetColumn() { @Test public void testGetSetColumnLarge() { int n = 3 * BlockFieldMatrix.BLOCK_SIZE; - FieldMatrix m = new BlockFieldMatrix(FractionField.getInstance(), n, n); + FieldMatrix m = new BlockFieldMatrix<>(FractionField.getInstance(), n, n); Fraction[] sub = new Fraction[n]; Arrays.fill(sub, new Fraction(1)); @@ -1146,7 +1146,7 @@ private void checkArrays(Fraction[] expected, Fraction[] actual) { @Test public void testEqualsAndHashCode() { - BlockFieldMatrix m = new BlockFieldMatrix(testData); + BlockFieldMatrix m = new BlockFieldMatrix<>(testData); BlockFieldMatrix m1 = (BlockFieldMatrix) m.copy(); BlockFieldMatrix mt = (BlockFieldMatrix) m.transpose(); Assert.assertTrue(m.hashCode() != mt.hashCode()); @@ -1155,36 +1155,36 @@ public void testEqualsAndHashCode() { Assert.assertEquals(m, m1); Assert.assertFalse(m.equals(null)); Assert.assertFalse(m.equals(mt)); - Assert.assertFalse(m.equals(new BlockFieldMatrix(bigSingular))); + Assert.assertFalse(m.equals(new BlockFieldMatrix<>(bigSingular))); } @Test public void testToString() { - BlockFieldMatrix m = new BlockFieldMatrix(testData); + BlockFieldMatrix m = new BlockFieldMatrix<>(testData); Assert.assertEquals("BlockFieldMatrix{{1,2,3},{2,5,3},{1,0,8}}", m.toString()); } @Test public void testSetSubMatrix() { - BlockFieldMatrix m = new BlockFieldMatrix(testData); + BlockFieldMatrix m = new BlockFieldMatrix<>(testData); m.setSubMatrix(detData2,1,1); - FieldMatrix expected = new BlockFieldMatrix + FieldMatrix expected = new BlockFieldMatrix<> (new Fraction[][] {{new Fraction(1),new Fraction(2),new Fraction(3)},{new Fraction(2),new Fraction(1),new Fraction(3)},{new Fraction(1),new Fraction(2),new Fraction(4)}}); Assert.assertEquals(expected, m); m.setSubMatrix(detData2,0,0); - expected = new BlockFieldMatrix + expected = new BlockFieldMatrix<> (new Fraction[][] {{new Fraction(1),new Fraction(3),new Fraction(3)},{new Fraction(2),new Fraction(4),new Fraction(3)},{new Fraction(1),new Fraction(2),new Fraction(4)}}); Assert.assertEquals(expected, m); m.setSubMatrix(testDataPlus2,0,0); - expected = new BlockFieldMatrix + expected = new BlockFieldMatrix<> (new Fraction[][] {{new Fraction(3),new Fraction(4),new Fraction(5)},{new Fraction(4),new Fraction(7),new Fraction(5)},{new Fraction(3),new Fraction(2),new Fraction(10)}}); Assert.assertEquals(expected, m); // javadoc example BlockFieldMatrix matrix = - new BlockFieldMatrix(new Fraction[][] { + new BlockFieldMatrix<>(new Fraction[][] { {new Fraction(1), new Fraction(2), new Fraction(3), new Fraction(4)}, {new Fraction(5), new Fraction(6), new Fraction(7), new Fraction(8)}, {new Fraction(9), new Fraction(0), new Fraction(1) , new Fraction(2)} @@ -1194,7 +1194,7 @@ public void testSetSubMatrix() { {new Fraction(5), new Fraction(6)} }, 1, 1); expected = - new BlockFieldMatrix(new Fraction[][] { + new BlockFieldMatrix<>(new Fraction[][] { {new Fraction(1), new Fraction(2), new Fraction(3),new Fraction(4)}, {new Fraction(5), new Fraction(3), new Fraction(4), new Fraction(8)}, {new Fraction(9), new Fraction(5) ,new Fraction(6), new Fraction(2)} @@ -1252,13 +1252,13 @@ public void testWalk() { int rows = 150; int columns = 75; - FieldMatrix m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); + FieldMatrix m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInRowOrder(new SetVisitor()); GetVisitor getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); + m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInRowOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1272,13 +1272,13 @@ public void testWalk() { Assert.assertEquals(new Fraction(0), m.getEntry(rows - 1, j)); } - m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); + m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInColumnOrder(new SetVisitor()); getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); + m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInColumnOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1292,13 +1292,13 @@ public void testWalk() { Assert.assertEquals(new Fraction(0), m.getEntry(rows - 1, j)); } - m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); + m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor()); getVisitor = new GetVisitor(); m.walkInRowOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); + m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInRowOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1312,13 +1312,13 @@ public void testWalk() { Assert.assertEquals(new Fraction(0), m.getEntry(rows - 1, j)); } - m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); + m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor()); getVisitor = new GetVisitor(); m.walkInColumnOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); + m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInColumnOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1336,7 +1336,7 @@ public void testWalk() { @Test public void testSerial() { - BlockFieldMatrix m = new BlockFieldMatrix(testData); + BlockFieldMatrix m = new BlockFieldMatrix<>(testData); Assert.assertEquals(m,TestUtils.serializeAndRecover(m)); } @@ -1368,7 +1368,7 @@ public int getCount() { private BlockFieldMatrix createRandomMatrix(Random r, int rows, int columns) { BlockFieldMatrix m = - new BlockFieldMatrix(FractionField.getInstance(), rows, columns); + new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); for (int i = 0; i < rows; ++i) { for (int j = 0; j < columns; ++j) { int p = r.nextInt(20) - 10; diff --git a/src/test/java/org/apache/commons/math4/linear/FieldLUDecompositionTest.java b/src/test/java/org/apache/commons/math4/linear/FieldLUDecompositionTest.java index 528fdeb9e7..0aa8c06811 100644 --- a/src/test/java/org/apache/commons/math4/linear/FieldLUDecompositionTest.java +++ b/src/test/java/org/apache/commons/math4/linear/FieldLUDecompositionTest.java @@ -60,8 +60,8 @@ public class FieldLUDecompositionTest { @Test public void testDimensions() { FieldMatrix matrix = - new Array2DRowFieldMatrix(FractionField.getInstance(), testData); - FieldLUDecomposition LU = new FieldLUDecomposition(matrix); + new Array2DRowFieldMatrix<>(FractionField.getInstance(), testData); + FieldLUDecomposition LU = new FieldLUDecomposition<>(matrix); Assert.assertEquals(testData.length, LU.getL().getRowDimension()); Assert.assertEquals(testData.length, LU.getL().getColumnDimension()); Assert.assertEquals(testData.length, LU.getU().getRowDimension()); @@ -76,7 +76,7 @@ public void testDimensions() { public void testNonSquare() { try { // we don't use FractionField.getInstance() for testing purposes - new FieldLUDecomposition(new Array2DRowFieldMatrix(new Fraction[][] { + new FieldLUDecomposition<>(new Array2DRowFieldMatrix<>(new Fraction[][] { { Fraction.ZERO, Fraction.ZERO }, { Fraction.ZERO, Fraction.ZERO }, { Fraction.ZERO, Fraction.ZERO } @@ -90,39 +90,39 @@ public void testNonSquare() { /** test PA = LU */ @Test public void testPAEqualLU() { - FieldMatrix matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), testData); - FieldLUDecomposition lu = new FieldLUDecomposition(matrix); + FieldMatrix matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), testData); + FieldLUDecomposition lu = new FieldLUDecomposition<>(matrix); FieldMatrix l = lu.getL(); FieldMatrix u = lu.getU(); FieldMatrix p = lu.getP(); TestUtils.assertEquals(p.multiply(matrix), l.multiply(u)); - matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), testDataMinus); - lu = new FieldLUDecomposition(matrix); + matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), testDataMinus); + lu = new FieldLUDecomposition<>(matrix); l = lu.getL(); u = lu.getU(); p = lu.getP(); TestUtils.assertEquals(p.multiply(matrix), l.multiply(u)); - matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), 17, 17); + matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), 17, 17); for (int i = 0; i < matrix.getRowDimension(); ++i) { matrix.setEntry(i, i, Fraction.ONE); } - lu = new FieldLUDecomposition(matrix); + lu = new FieldLUDecomposition<>(matrix); l = lu.getL(); u = lu.getU(); p = lu.getP(); TestUtils.assertEquals(p.multiply(matrix), l.multiply(u)); - matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), singular); - lu = new FieldLUDecomposition(matrix); + matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), singular); + lu = new FieldLUDecomposition<>(matrix); Assert.assertFalse(lu.getSolver().isNonSingular()); Assert.assertNull(lu.getL()); Assert.assertNull(lu.getU()); Assert.assertNull(lu.getP()); - matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), bigSingular); - lu = new FieldLUDecomposition(matrix); + matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), bigSingular); + lu = new FieldLUDecomposition<>(matrix); Assert.assertFalse(lu.getSolver().isNonSingular()); Assert.assertNull(lu.getL()); Assert.assertNull(lu.getU()); @@ -133,8 +133,8 @@ public void testPAEqualLU() { /** test that L is lower triangular with unit diagonal */ @Test public void testLLowerTriangular() { - FieldMatrix matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), testData); - FieldMatrix l = new FieldLUDecomposition(matrix).getL(); + FieldMatrix matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), testData); + FieldMatrix l = new FieldLUDecomposition<>(matrix).getL(); for (int i = 0; i < l.getRowDimension(); i++) { Assert.assertEquals(Fraction.ONE, l.getEntry(i, i)); for (int j = i + 1; j < l.getColumnDimension(); j++) { @@ -146,8 +146,8 @@ public void testLLowerTriangular() { /** test that U is upper triangular */ @Test public void testUUpperTriangular() { - FieldMatrix matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), testData); - FieldMatrix u = new FieldLUDecomposition(matrix).getU(); + FieldMatrix matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), testData); + FieldMatrix u = new FieldLUDecomposition<>(matrix).getU(); for (int i = 0; i < u.getRowDimension(); i++) { for (int j = 0; j < i; j++) { Assert.assertEquals(Fraction.ZERO, u.getEntry(i, j)); @@ -158,12 +158,12 @@ public void testUUpperTriangular() { /** test that P is a permutation matrix */ @Test public void testPPermutation() { - FieldMatrix matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), testData); - FieldMatrix p = new FieldLUDecomposition(matrix).getP(); + FieldMatrix matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), testData); + FieldMatrix p = new FieldLUDecomposition<>(matrix).getP(); FieldMatrix ppT = p.multiply(p.transpose()); FieldMatrix id = - new Array2DRowFieldMatrix(FractionField.getInstance(), + new Array2DRowFieldMatrix<>(FractionField.getInstance(), p.getRowDimension(), p.getRowDimension()); for (int i = 0; i < id.getRowDimension(); ++i) { id.setEntry(i, i, Fraction.ONE); @@ -215,11 +215,11 @@ public void testPPermutation() { @Test public void testSingular() { FieldLUDecomposition lu = - new FieldLUDecomposition(new Array2DRowFieldMatrix(FractionField.getInstance(), testData)); + new FieldLUDecomposition<>(new Array2DRowFieldMatrix<>(FractionField.getInstance(), testData)); Assert.assertTrue(lu.getSolver().isNonSingular()); - lu = new FieldLUDecomposition(new Array2DRowFieldMatrix(FractionField.getInstance(), singular)); + lu = new FieldLUDecomposition<>(new Array2DRowFieldMatrix<>(FractionField.getInstance(), singular)); Assert.assertFalse(lu.getSolver().isNonSingular()); - lu = new FieldLUDecomposition(new Array2DRowFieldMatrix(FractionField.getInstance(), bigSingular)); + lu = new FieldLUDecomposition<>(new Array2DRowFieldMatrix<>(FractionField.getInstance(), bigSingular)); Assert.assertFalse(lu.getSolver().isNonSingular()); } @@ -227,18 +227,18 @@ public void testSingular() { @Test public void testMatricesValues1() { FieldLUDecomposition lu = - new FieldLUDecomposition(new Array2DRowFieldMatrix(FractionField.getInstance(), testData)); - FieldMatrix lRef = new Array2DRowFieldMatrix(FractionField.getInstance(), new Fraction[][] { + new FieldLUDecomposition<>(new Array2DRowFieldMatrix<>(FractionField.getInstance(), testData)); + FieldMatrix lRef = new Array2DRowFieldMatrix<>(FractionField.getInstance(), new Fraction[][] { { new Fraction(1), new Fraction(0), new Fraction(0) }, { new Fraction(2), new Fraction(1), new Fraction(0) }, { new Fraction(1), new Fraction(-2), new Fraction(1) } }); - FieldMatrix uRef = new Array2DRowFieldMatrix(FractionField.getInstance(), new Fraction[][] { + FieldMatrix uRef = new Array2DRowFieldMatrix<>(FractionField.getInstance(), new Fraction[][] { { new Fraction(1), new Fraction(2), new Fraction(3) }, { new Fraction(0), new Fraction(1), new Fraction(-3) }, { new Fraction(0), new Fraction(0), new Fraction(-1) } }); - FieldMatrix pRef = new Array2DRowFieldMatrix(FractionField.getInstance(), new Fraction[][] { + FieldMatrix pRef = new Array2DRowFieldMatrix<>(FractionField.getInstance(), new Fraction[][] { { new Fraction(1), new Fraction(0), new Fraction(0) }, { new Fraction(0), new Fraction(1), new Fraction(0) }, { new Fraction(0), new Fraction(0), new Fraction(1) } @@ -268,18 +268,18 @@ public void testMatricesValues1() { @Test public void testMatricesValues2() { FieldLUDecomposition lu = - new FieldLUDecomposition(new Array2DRowFieldMatrix(FractionField.getInstance(), luData)); - FieldMatrix lRef = new Array2DRowFieldMatrix(FractionField.getInstance(), new Fraction[][] { + new FieldLUDecomposition<>(new Array2DRowFieldMatrix<>(FractionField.getInstance(), luData)); + FieldMatrix lRef = new Array2DRowFieldMatrix<>(FractionField.getInstance(), new Fraction[][] { { new Fraction(1), new Fraction(0), new Fraction(0) }, { new Fraction(3), new Fraction(1), new Fraction(0) }, { new Fraction(1), new Fraction(0), new Fraction(1) } }); - FieldMatrix uRef = new Array2DRowFieldMatrix(FractionField.getInstance(), new Fraction[][] { + FieldMatrix uRef = new Array2DRowFieldMatrix<>(FractionField.getInstance(), new Fraction[][] { { new Fraction(2), new Fraction(3), new Fraction(3) }, { new Fraction(0), new Fraction(-3), new Fraction(-1) }, { new Fraction(0), new Fraction(0), new Fraction(4) } }); - FieldMatrix pRef = new Array2DRowFieldMatrix(FractionField.getInstance(), new Fraction[][] { + FieldMatrix pRef = new Array2DRowFieldMatrix<>(FractionField.getInstance(), new Fraction[][] { { new Fraction(1), new Fraction(0), new Fraction(0) }, { new Fraction(0), new Fraction(0), new Fraction(1) }, { new Fraction(0), new Fraction(1), new Fraction(0) } diff --git a/src/test/java/org/apache/commons/math4/linear/FieldLUSolverTest.java b/src/test/java/org/apache/commons/math4/linear/FieldLUSolverTest.java index 03662d8636..70ad9716bf 100644 --- a/src/test/java/org/apache/commons/math4/linear/FieldLUSolverTest.java +++ b/src/test/java/org/apache/commons/math4/linear/FieldLUSolverTest.java @@ -58,7 +58,7 @@ public static FieldMatrix createFractionMatrix(final int[][] data) { final int numRows = data.length; final int numCols = data[0].length; final Array2DRowFieldMatrix m; - m = new Array2DRowFieldMatrix(FractionField.getInstance(), + m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), numRows, numCols); for (int i = 0; i < numRows; i++) { for (int j = 0; j < numCols; j++) { @@ -72,13 +72,13 @@ public static FieldMatrix createFractionMatrix(final int[][] data) { @Test public void testSingular() { FieldDecompositionSolver solver; - solver = new FieldLUDecomposition(createFractionMatrix(testData)) + solver = new FieldLUDecomposition<>(createFractionMatrix(testData)) .getSolver(); Assert.assertTrue(solver.isNonSingular()); - solver = new FieldLUDecomposition(createFractionMatrix(singular)) + solver = new FieldLUDecomposition<>(createFractionMatrix(singular)) .getSolver(); Assert.assertFalse(solver.isNonSingular()); - solver = new FieldLUDecomposition(createFractionMatrix(bigSingular)) + solver = new FieldLUDecomposition<>(createFractionMatrix(bigSingular)) .getSolver(); Assert.assertFalse(solver.isNonSingular()); } @@ -87,7 +87,7 @@ public void testSingular() { @Test public void testSolveDimensionErrors() { FieldDecompositionSolver solver; - solver = new FieldLUDecomposition(createFractionMatrix(testData)) + solver = new FieldLUDecomposition<>(createFractionMatrix(testData)) .getSolver(); FieldMatrix b = createFractionMatrix(new int[2][2]); try { @@ -108,7 +108,7 @@ public void testSolveDimensionErrors() { @Test public void testSolveSingularityErrors() { FieldDecompositionSolver solver; - solver = new FieldLUDecomposition(createFractionMatrix(singular)) + solver = new FieldLUDecomposition<>(createFractionMatrix(singular)) .getSolver(); FieldMatrix b = createFractionMatrix(new int[2][2]); try { @@ -129,7 +129,7 @@ public void testSolveSingularityErrors() { @Test public void testSolve() { FieldDecompositionSolver solver; - solver = new FieldLUDecomposition(createFractionMatrix(testData)) + solver = new FieldLUDecomposition<>(createFractionMatrix(testData)) .getSolver(); FieldMatrix b = createFractionMatrix(new int[][] { { 1, 0 }, { 2, -5 }, { 3, 1 } @@ -159,7 +159,7 @@ public void testSolve() { // using SparseFieldVector for (int j = 0; j < b.getColumnDimension(); j++) { final SparseFieldVector bj; - bj = new SparseFieldVector(FractionField.getInstance(), + bj = new SparseFieldVector<>(FractionField.getInstance(), b.getColumn(j)); final FieldVector xj = solver.solve(bj); for (int i = 0; i < xj.getDimension(); i++) { @@ -179,6 +179,6 @@ public void testDeterminant() { } private double getDeterminant(final FieldMatrix m) { - return new FieldLUDecomposition(m).getDeterminant().doubleValue(); + return new FieldLUDecomposition<>(m).getDeterminant().doubleValue(); } } diff --git a/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java b/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java index 4fb5bf4671..bd4ccf55e9 100644 --- a/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java +++ b/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java @@ -109,8 +109,8 @@ public final class FieldMatrixImplTest { /** test dimensions */ @Test public void testDimensions() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); - Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix(testData2); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); + Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix<>(testData2); Assert.assertEquals("testData row dimension",3,m.getRowDimension()); Assert.assertEquals("testData column dimension",3,m.getColumnDimension()); Assert.assertTrue("testData is square",m.isSquare()); @@ -122,19 +122,19 @@ public void testDimensions() { /** test copy functions */ @Test public void testCopyFunctions() { - Array2DRowFieldMatrix m1 = new Array2DRowFieldMatrix(testData); - Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix(m1.getData()); + Array2DRowFieldMatrix m1 = new Array2DRowFieldMatrix<>(testData); + Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix<>(m1.getData()); Assert.assertEquals(m2,m1); - Array2DRowFieldMatrix m3 = new Array2DRowFieldMatrix(testData); - Array2DRowFieldMatrix m4 = new Array2DRowFieldMatrix(m3.getData(), false); + Array2DRowFieldMatrix m3 = new Array2DRowFieldMatrix<>(testData); + Array2DRowFieldMatrix m4 = new Array2DRowFieldMatrix<>(m3.getData(), false); Assert.assertEquals(m4,m3); } /** test add */ @Test public void testAdd() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); - Array2DRowFieldMatrix mInv = new Array2DRowFieldMatrix(testDataInv); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); + Array2DRowFieldMatrix mInv = new Array2DRowFieldMatrix<>(testDataInv); FieldMatrix mPlusMInv = m.add(mInv); Fraction[][] sumEntries = mPlusMInv.getData(); for (int row = 0; row < m.getRowDimension(); row++) { @@ -147,8 +147,8 @@ public void testAdd() { /** test add failure */ @Test public void testAddFail() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); - Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix(testData2); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); + Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix<>(testData2); try { m.add(m2); Assert.fail("MathIllegalArgumentException expected"); @@ -160,11 +160,11 @@ public void testAddFail() { /** test m-n = m + -n */ @Test public void testPlusMinus() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); - Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix(testDataInv); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); + Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix<>(testDataInv); TestUtils.assertEquals(m.subtract(m2),m2.scalarMultiply(new Fraction(-1)).add(m)); try { - m.subtract(new Array2DRowFieldMatrix(testData2)); + m.subtract(new Array2DRowFieldMatrix<>(testData2)); Assert.fail("Expecting illegalArgumentException"); } catch (MathIllegalArgumentException ex) { // ignored @@ -174,17 +174,17 @@ public void testPlusMinus() { /** test multiply */ @Test public void testMultiply() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); - Array2DRowFieldMatrix mInv = new Array2DRowFieldMatrix(testDataInv); - Array2DRowFieldMatrix identity = new Array2DRowFieldMatrix(id); - Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix(testData2); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); + Array2DRowFieldMatrix mInv = new Array2DRowFieldMatrix<>(testDataInv); + Array2DRowFieldMatrix identity = new Array2DRowFieldMatrix<>(id); + Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix<>(testData2); TestUtils.assertEquals(m.multiply(mInv), identity); TestUtils.assertEquals(mInv.multiply(m), identity); TestUtils.assertEquals(m.multiply(identity), m); TestUtils.assertEquals(identity.multiply(mInv), mInv); TestUtils.assertEquals(m2.multiply(identity), m2); try { - m.multiply(new Array2DRowFieldMatrix(bigSingular)); + m.multiply(new Array2DRowFieldMatrix<>(bigSingular)); Assert.fail("Expecting illegalArgumentException"); } catch (MathIllegalArgumentException ex) { // ignored @@ -199,18 +199,18 @@ public void testMultiply() { @Test public void testMultiply2() { - FieldMatrix m3 = new Array2DRowFieldMatrix(d3); - FieldMatrix m4 = new Array2DRowFieldMatrix(d4); - FieldMatrix m5 = new Array2DRowFieldMatrix(d5); + FieldMatrix m3 = new Array2DRowFieldMatrix<>(d3); + FieldMatrix m4 = new Array2DRowFieldMatrix<>(d4); + FieldMatrix m5 = new Array2DRowFieldMatrix<>(d5); TestUtils.assertEquals(m3.multiply(m4), m5); } @Test public void testPower() { - FieldMatrix m = new Array2DRowFieldMatrix(testData); - FieldMatrix mInv = new Array2DRowFieldMatrix(testDataInv); - FieldMatrix mPlusInv = new Array2DRowFieldMatrix(testDataPlusInv); - FieldMatrix identity = new Array2DRowFieldMatrix(id); + FieldMatrix m = new Array2DRowFieldMatrix<>(testData); + FieldMatrix mInv = new Array2DRowFieldMatrix<>(testDataInv); + FieldMatrix mPlusInv = new Array2DRowFieldMatrix<>(testDataPlusInv); + FieldMatrix identity = new Array2DRowFieldMatrix<>(id); TestUtils.assertEquals(m.power(0), identity); TestUtils.assertEquals(mInv.power(0), identity); @@ -236,7 +236,7 @@ public void testPower() { } try { - FieldMatrix mNotSquare = new Array2DRowFieldMatrix(testData2T); + FieldMatrix mNotSquare = new Array2DRowFieldMatrix<>(testData2T); mNotSquare.power(2); Assert.fail("Expecting NonSquareMatrixException"); } catch (NonSquareMatrixException ex) { @@ -254,9 +254,9 @@ public void testPower() { /** test trace */ @Test public void testTrace() { - FieldMatrix m = new Array2DRowFieldMatrix(id); + FieldMatrix m = new Array2DRowFieldMatrix<>(id); Assert.assertEquals("identity trace",new Fraction(3),m.getTrace()); - m = new Array2DRowFieldMatrix(testData2); + m = new Array2DRowFieldMatrix<>(testData2); try { m.getTrace(); Assert.fail("Expecting NonSquareMatrixException"); @@ -268,17 +268,17 @@ public void testTrace() { /** test sclarAdd */ @Test public void testScalarAdd() { - FieldMatrix m = new Array2DRowFieldMatrix(testData); - TestUtils.assertEquals(new Array2DRowFieldMatrix(testDataPlus2), m.scalarAdd(new Fraction(2))); + FieldMatrix m = new Array2DRowFieldMatrix<>(testData); + TestUtils.assertEquals(new Array2DRowFieldMatrix<>(testDataPlus2), m.scalarAdd(new Fraction(2))); } /** test operate */ @Test public void testOperate() { - FieldMatrix m = new Array2DRowFieldMatrix(id); + FieldMatrix m = new Array2DRowFieldMatrix<>(id); TestUtils.assertEquals(testVector, m.operate(testVector)); - TestUtils.assertEquals(testVector, m.operate(new ArrayFieldVector(testVector)).toArray()); - m = new Array2DRowFieldMatrix(bigSingular); + TestUtils.assertEquals(testVector, m.operate(new ArrayFieldVector<>(testVector)).toArray()); + m = new Array2DRowFieldMatrix<>(bigSingular); try { m.operate(testVector); Assert.fail("Expecting illegalArgumentException"); @@ -290,7 +290,7 @@ public void testOperate() { /** test issue MATH-209 */ @Test public void testMath209() { - FieldMatrix a = new Array2DRowFieldMatrix(new Fraction[][] { + FieldMatrix a = new Array2DRowFieldMatrix<>(new Fraction[][] { { new Fraction(1), new Fraction(2) }, { new Fraction(3), new Fraction(4) }, { new Fraction(5), new Fraction(6) } }, false); Fraction[] b = a.operate(new Fraction[] { new Fraction(1), new Fraction(1) }); @@ -303,23 +303,23 @@ public void testMath209() { /** test transpose */ @Test public void testTranspose() { - FieldMatrix m = new Array2DRowFieldMatrix(testData); - FieldMatrix mIT = new FieldLUDecomposition(m).getSolver().getInverse().transpose(); - FieldMatrix mTI = new FieldLUDecomposition(m.transpose()).getSolver().getInverse(); + FieldMatrix m = new Array2DRowFieldMatrix<>(testData); + FieldMatrix mIT = new FieldLUDecomposition<>(m).getSolver().getInverse().transpose(); + FieldMatrix mTI = new FieldLUDecomposition<>(m.transpose()).getSolver().getInverse(); TestUtils.assertEquals(mIT, mTI); - m = new Array2DRowFieldMatrix(testData2); - FieldMatrix mt = new Array2DRowFieldMatrix(testData2T); + m = new Array2DRowFieldMatrix<>(testData2); + FieldMatrix mt = new Array2DRowFieldMatrix<>(testData2T); TestUtils.assertEquals(mt, m.transpose()); } /** test preMultiply by vector */ @Test public void testPremultiplyVector() { - FieldMatrix m = new Array2DRowFieldMatrix(testData); + FieldMatrix m = new Array2DRowFieldMatrix<>(testData); TestUtils.assertEquals(m.preMultiply(testVector), preMultTest); - TestUtils.assertEquals(m.preMultiply(new ArrayFieldVector(testVector).toArray()), + TestUtils.assertEquals(m.preMultiply(new ArrayFieldVector<>(testVector).toArray()), preMultTest); - m = new Array2DRowFieldMatrix(bigSingular); + m = new Array2DRowFieldMatrix<>(bigSingular); try { m.preMultiply(testVector); Assert.fail("expecting MathIllegalArgumentException"); @@ -330,20 +330,20 @@ public void testPremultiplyVector() { @Test public void testPremultiply() { - FieldMatrix m3 = new Array2DRowFieldMatrix(d3); - FieldMatrix m4 = new Array2DRowFieldMatrix(d4); - FieldMatrix m5 = new Array2DRowFieldMatrix(d5); + FieldMatrix m3 = new Array2DRowFieldMatrix<>(d3); + FieldMatrix m4 = new Array2DRowFieldMatrix<>(d4); + FieldMatrix m5 = new Array2DRowFieldMatrix<>(d5); TestUtils.assertEquals(m4.preMultiply(m3), m5); - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); - Array2DRowFieldMatrix mInv = new Array2DRowFieldMatrix(testDataInv); - Array2DRowFieldMatrix identity = new Array2DRowFieldMatrix(id); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); + Array2DRowFieldMatrix mInv = new Array2DRowFieldMatrix<>(testDataInv); + Array2DRowFieldMatrix identity = new Array2DRowFieldMatrix<>(id); TestUtils.assertEquals(m.preMultiply(mInv), identity); TestUtils.assertEquals(mInv.preMultiply(m), identity); TestUtils.assertEquals(m.preMultiply(identity), m); TestUtils.assertEquals(identity.preMultiply(mInv), mInv); try { - m.preMultiply(new Array2DRowFieldMatrix(bigSingular)); + m.preMultiply(new Array2DRowFieldMatrix<>(bigSingular)); Assert.fail("Expecting illegalArgumentException"); } catch (MathIllegalArgumentException ex) { // ignored @@ -352,7 +352,7 @@ public void testPremultiply() { @Test public void testGetVectors() { - FieldMatrix m = new Array2DRowFieldMatrix(testData); + FieldMatrix m = new Array2DRowFieldMatrix<>(testData); TestUtils.assertEquals(m.getRow(0), testDataRow1); TestUtils.assertEquals(m.getColumn(2), testDataCol3); try { @@ -371,7 +371,7 @@ public void testGetVectors() { @Test public void testGetEntry() { - FieldMatrix m = new Array2DRowFieldMatrix(testData); + FieldMatrix m = new Array2DRowFieldMatrix<>(testData); Assert.assertEquals("get entry", m.getEntry(0,1), new Fraction(2)); try { m.getEntry(10, 4); @@ -389,20 +389,20 @@ public void testExamples() { {new Fraction(1),new Fraction(2),new Fraction(3)}, {new Fraction(2),new Fraction(5),new Fraction(3)} }; - FieldMatrix m = new Array2DRowFieldMatrix(matrixData); + FieldMatrix m = new Array2DRowFieldMatrix<>(matrixData); // One more with three rows, two columns Fraction[][] matrixData2 = { {new Fraction(1),new Fraction(2)}, {new Fraction(2),new Fraction(5)}, {new Fraction(1), new Fraction(7)} }; - FieldMatrix n = new Array2DRowFieldMatrix(matrixData2); + FieldMatrix n = new Array2DRowFieldMatrix<>(matrixData2); // Now multiply m by n FieldMatrix p = m.multiply(n); Assert.assertEquals(2, p.getRowDimension()); Assert.assertEquals(2, p.getColumnDimension()); // Invert p - FieldMatrix pInverse = new FieldLUDecomposition(p).getSolver().getInverse(); + FieldMatrix pInverse = new FieldLUDecomposition<>(p).getSolver().getInverse(); Assert.assertEquals(2, pInverse.getRowDimension()); Assert.assertEquals(2, pInverse.getColumnDimension()); @@ -412,14 +412,14 @@ public void testExamples() { {new Fraction(-1), new Fraction(7), new Fraction(6)}, {new Fraction(4), new Fraction(-3), new Fraction(-5)} }; - FieldMatrix coefficients = new Array2DRowFieldMatrix(coefficientsData); + FieldMatrix coefficients = new Array2DRowFieldMatrix<>(coefficientsData); Fraction[] constants = { new Fraction(1), new Fraction(-2), new Fraction(1) }; Fraction[] solution; - solution = new FieldLUDecomposition(coefficients) + solution = new FieldLUDecomposition<>(coefficients) .getSolver() - .solve(new ArrayFieldVector(constants, false)).toArray(); + .solve(new ArrayFieldVector<>(constants, false)).toArray(); Assert.assertEquals(new Fraction(2).multiply(solution[0]). add(new Fraction(3).multiply(solution[1])). subtract(new Fraction(2).multiply(solution[2])), constants[0]); @@ -435,7 +435,7 @@ public void testExamples() { // test submatrix accessors @Test public void testGetSubMatrix() { - FieldMatrix m = new Array2DRowFieldMatrix(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); checkGetSubMatrix(m, subRows23Cols00, 2 , 3 , 0, 0); checkGetSubMatrix(m, subRows00Cols33, 0 , 0 , 3, 3); checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3); @@ -458,7 +458,7 @@ private void checkGetSubMatrix(FieldMatrix m, Fraction[][] reference, try { FieldMatrix sub = m.getSubMatrix(startRow, endRow, startColumn, endColumn); if (reference != null) { - Assert.assertEquals(new Array2DRowFieldMatrix(reference), sub); + Assert.assertEquals(new Array2DRowFieldMatrix<>(reference), sub); } else { Assert.fail("Expecting OutOfRangeException or NotStrictlyPositiveException" + " or NumberIsTooSmallException or NoDataException"); @@ -487,7 +487,7 @@ private void checkGetSubMatrix(FieldMatrix m, Fraction[][] reference, try { FieldMatrix sub = m.getSubMatrix(selectedRows, selectedColumns); if (reference != null) { - Assert.assertEquals(new Array2DRowFieldMatrix(reference), sub); + Assert.assertEquals(new Array2DRowFieldMatrix<>(reference), sub); } else { Assert.fail("Expecting OutOfRangeException or NotStrictlyPositiveException" + " or NumberIsTooSmallException or NoDataException"); @@ -513,7 +513,7 @@ private void checkGetSubMatrix(FieldMatrix m, Fraction[][] reference, @Test public void testCopySubMatrix() { - FieldMatrix m = new Array2DRowFieldMatrix(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); checkCopy(m, subRows23Cols00, 2 , 3 , 0, 0); checkCopy(m, subRows00Cols33, 0 , 0 , 3, 3); checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3); @@ -540,7 +540,7 @@ private void checkCopy(FieldMatrix m, Fraction[][] reference, new Fraction[reference.length][reference[0].length]; m.copySubMatrix(startRow, endRow, startColumn, endColumn, sub); if (reference != null) { - Assert.assertEquals(new Array2DRowFieldMatrix(reference), new Array2DRowFieldMatrix(sub)); + Assert.assertEquals(new Array2DRowFieldMatrix<>(reference), new Array2DRowFieldMatrix<>(sub)); } else { Assert.fail("Expecting OutOfRangeException or NumberIsTooSmallException or NoDataException"); } @@ -567,7 +567,7 @@ private void checkCopy(FieldMatrix m, Fraction[][] reference, new Fraction[reference.length][reference[0].length]; m.copySubMatrix(selectedRows, selectedColumns, sub); if (reference != null) { - Assert.assertEquals(new Array2DRowFieldMatrix(reference), new Array2DRowFieldMatrix(sub)); + Assert.assertEquals(new Array2DRowFieldMatrix<>(reference), new Array2DRowFieldMatrix<>(sub)); } else { Assert.fail("Expecting OutOfRangeException or NumberIsTooSmallException or NoDataException"); } @@ -588,9 +588,9 @@ private void checkCopy(FieldMatrix m, Fraction[][] reference, @Test public void testGetRowMatrix() { - FieldMatrix m = new Array2DRowFieldMatrix(subTestData); - FieldMatrix mRow0 = new Array2DRowFieldMatrix(subRow0); - FieldMatrix mRow3 = new Array2DRowFieldMatrix(subRow3); + FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); + FieldMatrix mRow0 = new Array2DRowFieldMatrix<>(subRow0); + FieldMatrix mRow3 = new Array2DRowFieldMatrix<>(subRow3); Assert.assertEquals("Row0", mRow0, m.getRowMatrix(0)); Assert.assertEquals("Row3", mRow3, @@ -611,8 +611,8 @@ public void testGetRowMatrix() { @Test public void testSetRowMatrix() { - FieldMatrix m = new Array2DRowFieldMatrix(subTestData); - FieldMatrix mRow3 = new Array2DRowFieldMatrix(subRow3); + FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); + FieldMatrix mRow3 = new Array2DRowFieldMatrix<>(subRow3); Assert.assertNotSame(mRow3, m.getRowMatrix(0)); m.setRowMatrix(0, mRow3); Assert.assertEquals(mRow3, m.getRowMatrix(0)); @@ -632,9 +632,9 @@ public void testSetRowMatrix() { @Test public void testGetColumnMatrix() { - FieldMatrix m = new Array2DRowFieldMatrix(subTestData); - FieldMatrix mColumn1 = new Array2DRowFieldMatrix(subColumn1); - FieldMatrix mColumn3 = new Array2DRowFieldMatrix(subColumn3); + FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); + FieldMatrix mColumn1 = new Array2DRowFieldMatrix<>(subColumn1); + FieldMatrix mColumn3 = new Array2DRowFieldMatrix<>(subColumn3); Assert.assertEquals("Column1", mColumn1, m.getColumnMatrix(1)); Assert.assertEquals("Column3", mColumn3, @@ -655,8 +655,8 @@ public void testGetColumnMatrix() { @Test public void testSetColumnMatrix() { - FieldMatrix m = new Array2DRowFieldMatrix(subTestData); - FieldMatrix mColumn3 = new Array2DRowFieldMatrix(subColumn3); + FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); + FieldMatrix mColumn3 = new Array2DRowFieldMatrix<>(subColumn3); Assert.assertNotSame(mColumn3, m.getColumnMatrix(1)); m.setColumnMatrix(1, mColumn3); Assert.assertEquals(mColumn3, m.getColumnMatrix(1)); @@ -676,9 +676,9 @@ public void testSetColumnMatrix() { @Test public void testGetRowVector() { - FieldMatrix m = new Array2DRowFieldMatrix(subTestData); - FieldVector mRow0 = new ArrayFieldVector(subRow0[0]); - FieldVector mRow3 = new ArrayFieldVector(subRow3[0]); + FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); + FieldVector mRow0 = new ArrayFieldVector<>(subRow0[0]); + FieldVector mRow3 = new ArrayFieldVector<>(subRow3[0]); Assert.assertEquals("Row0", mRow0, m.getRowVector(0)); Assert.assertEquals("Row3", mRow3, m.getRowVector(3)); try { @@ -697,8 +697,8 @@ public void testGetRowVector() { @Test public void testSetRowVector() { - FieldMatrix m = new Array2DRowFieldMatrix(subTestData); - FieldVector mRow3 = new ArrayFieldVector(subRow3[0]); + FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); + FieldVector mRow3 = new ArrayFieldVector<>(subRow3[0]); Assert.assertNotSame(mRow3, m.getRowMatrix(0)); m.setRowVector(0, mRow3); Assert.assertEquals(mRow3, m.getRowVector(0)); @@ -709,7 +709,7 @@ public void testSetRowVector() { // expected } try { - m.setRowVector(0, new ArrayFieldVector(FractionField.getInstance(), 5)); + m.setRowVector(0, new ArrayFieldVector<>(FractionField.getInstance(), 5)); Assert.fail("Expecting MatrixDimensionMismatchException"); } catch (MatrixDimensionMismatchException ex) { // expected @@ -718,7 +718,7 @@ public void testSetRowVector() { @Test public void testGetColumnVector() { - FieldMatrix m = new Array2DRowFieldMatrix(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); FieldVector mColumn1 = columnToVector(subColumn1); FieldVector mColumn3 = columnToVector(subColumn3); Assert.assertEquals("Column1", mColumn1, m.getColumnVector(1)); @@ -739,7 +739,7 @@ public void testGetColumnVector() { @Test public void testSetColumnVector() { - FieldMatrix m = new Array2DRowFieldMatrix(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); FieldVector mColumn3 = columnToVector(subColumn3); Assert.assertNotSame(mColumn3, m.getColumnVector(1)); m.setColumnVector(1, mColumn3); @@ -751,7 +751,7 @@ public void testSetColumnVector() { // expected } try { - m.setColumnVector(0, new ArrayFieldVector(FractionField.getInstance(), 5)); + m.setColumnVector(0, new ArrayFieldVector<>(FractionField.getInstance(), 5)); Assert.fail("Expecting MatrixDimensionMismatchException"); } catch (MatrixDimensionMismatchException ex) { // expected @@ -763,12 +763,12 @@ private FieldVector columnToVector(Fraction[][] column) { for (int i = 0; i < data.length; ++i) { data[i] = column[i][0]; } - return new ArrayFieldVector(data, false); + return new ArrayFieldVector<>(data, false); } @Test public void testGetRow() { - FieldMatrix m = new Array2DRowFieldMatrix(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); checkArrays(subRow0[0], m.getRow(0)); checkArrays(subRow3[0], m.getRow(3)); try { @@ -787,7 +787,7 @@ public void testGetRow() { @Test public void testSetRow() { - FieldMatrix m = new Array2DRowFieldMatrix(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); Assert.assertTrue(subRow3[0][0] != m.getRow(0)[0]); m.setRow(0, subRow3[0]); checkArrays(subRow3[0], m.getRow(0)); @@ -807,7 +807,7 @@ public void testSetRow() { @Test public void testGetColumn() { - FieldMatrix m = new Array2DRowFieldMatrix(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); Fraction[] mColumn1 = columnToArray(subColumn1); Fraction[] mColumn3 = columnToArray(subColumn3); checkArrays(mColumn1, m.getColumn(1)); @@ -828,7 +828,7 @@ public void testGetColumn() { @Test public void testSetColumn() { - FieldMatrix m = new Array2DRowFieldMatrix(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); Fraction[] mColumn3 = columnToArray(subColumn3); Assert.assertTrue(mColumn3[0] != m.getColumn(1)[0]); m.setColumn(1, mColumn3); @@ -864,7 +864,7 @@ private void checkArrays(Fraction[] expected, Fraction[] actual) { @Test public void testEqualsAndHashCode() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); Array2DRowFieldMatrix m1 = (Array2DRowFieldMatrix) m.copy(); Array2DRowFieldMatrix mt = (Array2DRowFieldMatrix) m.transpose(); Assert.assertTrue(m.hashCode() != mt.hashCode()); @@ -873,22 +873,22 @@ public void testEqualsAndHashCode() { Assert.assertEquals(m, m1); Assert.assertFalse(m.equals(null)); Assert.assertFalse(m.equals(mt)); - Assert.assertFalse(m.equals(new Array2DRowFieldMatrix(bigSingular))); + Assert.assertFalse(m.equals(new Array2DRowFieldMatrix<>(bigSingular))); } @Test public void testToString() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); Assert.assertEquals("Array2DRowFieldMatrix{{1,2,3},{2,5,3},{1,0,8}}", m.toString()); - m = new Array2DRowFieldMatrix(FractionField.getInstance()); + m = new Array2DRowFieldMatrix<>(FractionField.getInstance()); Assert.assertEquals("Array2DRowFieldMatrix{}", m.toString()); } @Test public void testSetSubMatrix() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); m.setSubMatrix(detData2,1,1); - FieldMatrix expected = new Array2DRowFieldMatrix + FieldMatrix expected = new Array2DRowFieldMatrix<> (new Fraction[][] { {new Fraction(1),new Fraction(2),new Fraction(3)}, {new Fraction(2),new Fraction(1),new Fraction(3)}, @@ -897,7 +897,7 @@ public void testSetSubMatrix() { Assert.assertEquals(expected, m); m.setSubMatrix(detData2,0,0); - expected = new Array2DRowFieldMatrix + expected = new Array2DRowFieldMatrix<> (new Fraction[][] { {new Fraction(1),new Fraction(3),new Fraction(3)}, {new Fraction(2),new Fraction(4),new Fraction(3)}, @@ -906,7 +906,7 @@ public void testSetSubMatrix() { Assert.assertEquals(expected, m); m.setSubMatrix(testDataPlus2,0,0); - expected = new Array2DRowFieldMatrix + expected = new Array2DRowFieldMatrix<> (new Fraction[][] { {new Fraction(3),new Fraction(4),new Fraction(5)}, {new Fraction(4),new Fraction(7),new Fraction(5)}, @@ -942,7 +942,7 @@ public void testSetSubMatrix() { } catch (NullArgumentException e) { // expected } - Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix(FractionField.getInstance()); + Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix<>(FractionField.getInstance()); try { m2.setSubMatrix(testData,0,1); Assert.fail("expecting MathIllegalStateException"); @@ -980,13 +980,13 @@ public void testWalk() { int columns = 75; FieldMatrix m = - new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); + new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInRowOrder(new SetVisitor()); GetVisitor getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); + m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInRowOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1000,13 +1000,13 @@ public void testWalk() { Assert.assertEquals(new Fraction(0), m.getEntry(rows - 1, j)); } - m = new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); + m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInColumnOrder(new SetVisitor()); getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); + m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInColumnOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1020,13 +1020,13 @@ public void testWalk() { Assert.assertEquals(new Fraction(0), m.getEntry(rows - 1, j)); } - m = new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); + m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor()); getVisitor = new GetVisitor(); m.walkInRowOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); + m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInRowOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1040,13 +1040,13 @@ public void testWalk() { Assert.assertEquals(new Fraction(0), m.getEntry(rows - 1, j)); } - m = new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); + m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor()); getVisitor = new GetVisitor(); m.walkInColumnOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); + m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInColumnOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1063,7 +1063,7 @@ public void testWalk() { @Test public void testSerial() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); Assert.assertEquals(m,TestUtils.serializeAndRecover(m)); } @@ -1148,6 +1148,6 @@ protected FieldMatrix permuteRows(FieldMatrix matrix, int[] out[i][j] = matrix.getEntry(permutation[i], j); } } - return new Array2DRowFieldMatrix(out); + return new Array2DRowFieldMatrix<>(out); } } diff --git a/src/test/java/org/apache/commons/math4/linear/MatrixUtilsTest.java b/src/test/java/org/apache/commons/math4/linear/MatrixUtilsTest.java index b547cdc038..c8bd3f9106 100644 --- a/src/test/java/org/apache/commons/math4/linear/MatrixUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/linear/MatrixUtilsTest.java @@ -104,9 +104,9 @@ public void testCreateRealMatrix() { @Test public void testcreateFieldMatrix() { - Assert.assertEquals(new Array2DRowFieldMatrix(asFraction(testData)), + Assert.assertEquals(new Array2DRowFieldMatrix<>(asFraction(testData)), MatrixUtils.createFieldMatrix(asFraction(testData))); - Assert.assertEquals(new Array2DRowFieldMatrix(FractionField.getInstance(), fractionColMatrix), + Assert.assertEquals(new Array2DRowFieldMatrix<>(FractionField.getInstance(), fractionColMatrix), MatrixUtils.createFieldMatrix(fractionColMatrix)); try { MatrixUtils.createFieldMatrix(asFraction(new double[][] {{1}, {1,2}})); // ragged @@ -149,9 +149,9 @@ public void testCreateRowRealMatrix() { @Test public void testCreateRowFieldMatrix() { Assert.assertEquals(MatrixUtils.createRowFieldMatrix(asFraction(row)), - new Array2DRowFieldMatrix(asFraction(rowMatrix))); + new Array2DRowFieldMatrix<>(asFraction(rowMatrix))); Assert.assertEquals(MatrixUtils.createRowFieldMatrix(fractionRow), - new Array2DRowFieldMatrix(fractionRowMatrix)); + new Array2DRowFieldMatrix<>(fractionRowMatrix)); try { MatrixUtils.createRowFieldMatrix(new Fraction[] {}); // empty Assert.fail("Expecting MathIllegalArgumentException"); @@ -187,9 +187,9 @@ public void testCreateColumnRealMatrix() { @Test public void testCreateColumnFieldMatrix() { Assert.assertEquals(MatrixUtils.createColumnFieldMatrix(asFraction(col)), - new Array2DRowFieldMatrix(asFraction(colMatrix))); + new Array2DRowFieldMatrix<>(asFraction(colMatrix))); Assert.assertEquals(MatrixUtils.createColumnFieldMatrix(fractionCol), - new Array2DRowFieldMatrix(fractionColMatrix)); + new Array2DRowFieldMatrix<>(fractionColMatrix)); try { MatrixUtils.createColumnFieldMatrix(new Fraction[] {}); // empty @@ -268,7 +268,7 @@ public void testBigFractionConverter() { { new BigFraction(2), new BigFraction(5), new BigFraction(3) }, { new BigFraction(1), new BigFraction(0), new BigFraction(8) } }; - FieldMatrix m = new Array2DRowFieldMatrix(bfData, false); + FieldMatrix m = new Array2DRowFieldMatrix<>(bfData, false); RealMatrix converted = MatrixUtils.bigFractionMatrixToRealMatrix(m); RealMatrix reference = new Array2DRowRealMatrix(testData, false); Assert.assertEquals(0.0, converted.subtract(reference).getNorm(), 0.0); @@ -281,7 +281,7 @@ public void testFractionConverter() { { new Fraction(2), new Fraction(5), new Fraction(3) }, { new Fraction(1), new Fraction(0), new Fraction(8) } }; - FieldMatrix m = new Array2DRowFieldMatrix(fData, false); + FieldMatrix m = new Array2DRowFieldMatrix<>(fData, false); RealMatrix converted = MatrixUtils.fractionMatrixToRealMatrix(m); RealMatrix reference = new Array2DRowRealMatrix(testData, false); Assert.assertEquals(0.0, converted.subtract(reference).getNorm(), 0.0); diff --git a/src/test/java/org/apache/commons/math4/linear/SparseFieldMatrixTest.java b/src/test/java/org/apache/commons/math4/linear/SparseFieldMatrixTest.java index 176b227aa2..0266b305d1 100644 --- a/src/test/java/org/apache/commons/math4/linear/SparseFieldMatrixTest.java +++ b/src/test/java/org/apache/commons/math4/linear/SparseFieldMatrixTest.java @@ -209,7 +209,7 @@ public void testMultiply() { SparseFieldMatrix m2 = createSparseMatrix(testData2); assertClose("inverse multiply", m.multiply(mInv), identity, entryTolerance); - assertClose("inverse multiply", m.multiply(new Array2DRowFieldMatrix(FractionField.getInstance(), testDataInv)), identity, + assertClose("inverse multiply", m.multiply(new Array2DRowFieldMatrix<>(FractionField.getInstance(), testDataInv)), identity, entryTolerance); assertClose("inverse multiply", mInv.multiply(m), identity, entryTolerance); @@ -270,7 +270,7 @@ public void testOperate() { assertClose("identity operate", testVector, m.operate(testVector), entryTolerance); assertClose("identity operate", testVector, m.operate( - new ArrayFieldVector(testVector)).toArray(), entryTolerance); + new ArrayFieldVector<>(testVector)).toArray(), entryTolerance); m = createSparseMatrix(bigSingular); try { m.operate(testVector); @@ -296,8 +296,8 @@ public void testMath209() { @Test public void testTranspose() { FieldMatrix m = createSparseMatrix(testData); - FieldMatrix mIT = new FieldLUDecomposition(m).getSolver().getInverse().transpose(); - FieldMatrix mTI = new FieldLUDecomposition(m.transpose()).getSolver().getInverse(); + FieldMatrix mIT = new FieldLUDecomposition<>(m).getSolver().getInverse().transpose(); + FieldMatrix mTI = new FieldLUDecomposition<>(m.transpose()).getSolver().getInverse(); assertClose("inverse-transpose", mIT, mTI, normTolerance); m = createSparseMatrix(testData2); FieldMatrix mt = createSparseMatrix(testData2T); @@ -311,7 +311,7 @@ public void testPremultiplyVector() { assertClose("premultiply", m.preMultiply(testVector), preMultTest, normTolerance); assertClose("premultiply", m.preMultiply( - new ArrayFieldVector(testVector).toArray()), preMultTest, normTolerance); + new ArrayFieldVector<>(testVector).toArray()), preMultTest, normTolerance); m = createSparseMatrix(bigSingular); try { m.preMultiply(testVector); @@ -392,7 +392,7 @@ public void testExamples() { Assert.assertEquals(2, p.getRowDimension()); Assert.assertEquals(2, p.getColumnDimension()); // Invert p - FieldMatrix pInverse = new FieldLUDecomposition(p).getSolver().getInverse(); + FieldMatrix pInverse = new FieldLUDecomposition<>(p).getSolver().getInverse(); Assert.assertEquals(2, pInverse.getRowDimension()); Assert.assertEquals(2, pInverse.getColumnDimension()); @@ -402,9 +402,9 @@ public void testExamples() { FieldMatrix coefficients = createSparseMatrix(coefficientsData); Fraction[] constants = { new Fraction(1), new Fraction(-2), new Fraction(1) }; Fraction[] solution; - solution = new FieldLUDecomposition(coefficients) + solution = new FieldLUDecomposition<>(coefficients) .getSolver() - .solve(new ArrayFieldVector(constants, false)).toArray(); + .solve(new ArrayFieldVector<>(constants, false)).toArray(); Assert.assertEquals((new Fraction(2).multiply((solution[0])).add(new Fraction(3).multiply(solution[1])).subtract(new Fraction(2).multiply(solution[2]))).doubleValue(), constants[0].doubleValue(), 1E-12); Assert.assertEquals(((new Fraction(-1).multiply(solution[0])).add(new Fraction(7).multiply(solution[1])).add(new Fraction(6).multiply(solution[2]))).doubleValue(), @@ -525,8 +525,8 @@ public void testGetColumnMatrix() { @Test public void testGetRowVector() { FieldMatrix m = createSparseMatrix(subTestData); - FieldVector mRow0 = new ArrayFieldVector(subRow0[0]); - FieldVector mRow3 = new ArrayFieldVector(subRow3[0]); + FieldVector mRow0 = new ArrayFieldVector<>(subRow0[0]); + FieldVector mRow3 = new ArrayFieldVector<>(subRow3[0]); Assert.assertEquals("Row0", mRow0, m.getRowVector(0)); Assert.assertEquals("Row3", mRow3, m.getRowVector(3)); try { @@ -569,7 +569,7 @@ private FieldVector columnToVector(Fraction[][] column) { for (int i = 0; i < data.length; ++i) { data[i] = column[i][0]; } - return new ArrayFieldVector(data, false); + return new ArrayFieldVector<>(data, false); } @Test @@ -653,7 +653,7 @@ public void testSetSubMatrix() { // expected } try { - new SparseFieldMatrix(field, 0, 0); + new SparseFieldMatrix<>(field, 0, 0); Assert.fail("expecting MathIllegalArgumentException"); } catch (MathIllegalArgumentException e) { // expected @@ -702,7 +702,7 @@ protected void assertClose(String msg, Fraction[] m, Fraction[] n, } private SparseFieldMatrix createSparseMatrix(Fraction[][] data) { - SparseFieldMatrix matrix = new SparseFieldMatrix(field, data.length, data[0].length); + SparseFieldMatrix matrix = new SparseFieldMatrix<>(field, data.length, data[0].length); for (int row = 0; row < data.length; row++) { for (int col = 0; col < data[row].length; col++) { matrix.setEntry(row, col, data[row][col]); diff --git a/src/test/java/org/apache/commons/math4/linear/SparseFieldVectorTest.java b/src/test/java/org/apache/commons/math4/linear/SparseFieldVectorTest.java index 3a607f4637..5df1142e21 100644 --- a/src/test/java/org/apache/commons/math4/linear/SparseFieldVectorTest.java +++ b/src/test/java/org/apache/commons/math4/linear/SparseFieldVectorTest.java @@ -58,7 +58,7 @@ public class SparseFieldVectorTest { @Test public void testMapFunctions() throws FractionConversionException { - SparseFieldVector v1 = new SparseFieldVector(field,vec1); + SparseFieldVector v1 = new SparseFieldVector<>(field,vec1); //octave = v1 .+ 2.0 FieldVector v_mapAdd = v1.mapAdd(new Fraction(2)); @@ -120,17 +120,17 @@ public void testMapFunctions() throws FractionConversionException { @Test public void testBasicFunctions() throws FractionConversionException { - SparseFieldVector v1 = new SparseFieldVector(field,vec1); - SparseFieldVector v2 = new SparseFieldVector(field,vec2); + SparseFieldVector v1 = new SparseFieldVector<>(field,vec1); + SparseFieldVector v2 = new SparseFieldVector<>(field,vec2); - FieldVector v2_t = new ArrayFieldVectorTest.FieldVectorTestImpl(vec2); + FieldVector v2_t = new ArrayFieldVectorTest.FieldVectorTestImpl<>(vec2); //octave = v1 + v2 FieldVector v_add = v1.add(v2); Fraction[] result_add = {new Fraction(5), new Fraction(7), new Fraction(9)}; Assert.assertArrayEquals("compare vect" ,v_add.toArray(),result_add); - FieldVector vt2 = new ArrayFieldVectorTest.FieldVectorTestImpl(vec2); + FieldVector vt2 = new ArrayFieldVectorTest.FieldVectorTestImpl<>(vec2); FieldVector v_add_i = v1.add(vt2); Fraction[] result_add_i = {new Fraction(5), new Fraction(7), new Fraction(9)}; Assert.assertArrayEquals("compare vect" ,v_add_i.toArray(),result_add_i); @@ -181,12 +181,12 @@ public void testBasicFunctions() throws FractionConversionException { @Test public void testOuterProduct() { final SparseFieldVector u - = new SparseFieldVector(FractionField.getInstance(), + = new SparseFieldVector<>(FractionField.getInstance(), new Fraction[] {new Fraction(1), new Fraction(2), new Fraction(-3)}); final SparseFieldVector v - = new SparseFieldVector(FractionField.getInstance(), + = new SparseFieldVector<>(FractionField.getInstance(), new Fraction[] {new Fraction(4), new Fraction(-2)}); @@ -203,7 +203,7 @@ public void testOuterProduct() { @Test public void testMisc() { - SparseFieldVector v1 = new SparseFieldVector(field,vec1); + SparseFieldVector v1 = new SparseFieldVector<>(field,vec1); String out1 = v1.toString(); Assert.assertTrue("some output ", out1.length()!=0); @@ -220,11 +220,11 @@ public void testMisc() { @Test public void testPredicates() { - SparseFieldVector v = new SparseFieldVector(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2) }); + SparseFieldVector v = new SparseFieldVector<>(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2) }); v.setEntry(0, field.getZero()); - Assert.assertEquals(v, new SparseFieldVector(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2) })); - Assert.assertNotSame(v, new SparseFieldVector(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2), new Fraction(3) })); + Assert.assertEquals(v, new SparseFieldVector<>(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2) })); + Assert.assertNotSame(v, new SparseFieldVector<>(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2), new Fraction(3) })); } @@ -260,7 +260,7 @@ public void testWalkInDefaultOrderPreservingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector(field, data); + final SparseFieldVector v = new SparseFieldVector<>(field, data); final FieldVectorPreservingVisitor visitor; visitor = new FieldVectorPreservingVisitor() { @@ -347,7 +347,7 @@ public void testWalkInDefaultOrderPreservingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector(field, data); + final SparseFieldVector v = new SparseFieldVector<>(field, data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorPreservingVisitor visitor; @@ -385,7 +385,7 @@ public void testWalkInOptimizedOrderPreservingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector(field, data); + final SparseFieldVector v = new SparseFieldVector<>(field, data); final FieldVectorPreservingVisitor visitor; visitor = new FieldVectorPreservingVisitor() { private final boolean[] visited = new boolean[data.length]; @@ -474,7 +474,7 @@ public void testWalkInOptimizedOrderPreservingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector(field, data); + final SparseFieldVector v = new SparseFieldVector<>(field, data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorPreservingVisitor visitor; @@ -514,7 +514,7 @@ public void testWalkInDefaultOrderChangingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector(field, data); + final SparseFieldVector v = new SparseFieldVector<>(field, data); final FieldVectorChangingVisitor visitor; visitor = new FieldVectorChangingVisitor() { @@ -605,7 +605,7 @@ public void testWalkInDefaultOrderChangingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector(field, data); + final SparseFieldVector v = new SparseFieldVector<>(field, data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorChangingVisitor visitor; @@ -647,7 +647,7 @@ public void testWalkInOptimizedOrderChangingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector(field, data); + final SparseFieldVector v = new SparseFieldVector<>(field, data); final FieldVectorChangingVisitor visitor; visitor = new FieldVectorChangingVisitor() { private final boolean[] visited = new boolean[data.length]; @@ -740,7 +740,7 @@ public void testWalkInOptimizedOrderChangingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector(field, data); + final SparseFieldVector v = new SparseFieldVector<>(field, data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorChangingVisitor visitor; @@ -781,6 +781,6 @@ private SparseFieldVector create(int n) { for (int i = 0; i < n; ++i) { t[i] = Fraction.ZERO; } - return new SparseFieldVector(field, t); + return new SparseFieldVector<>(field, t); } } diff --git a/src/test/java/org/apache/commons/math4/linear/UnmodifiableRealVectorAbstractTest.java b/src/test/java/org/apache/commons/math4/linear/UnmodifiableRealVectorAbstractTest.java index 9930801435..121789e38b 100644 --- a/src/test/java/org/apache/commons/math4/linear/UnmodifiableRealVectorAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/linear/UnmodifiableRealVectorAbstractTest.java @@ -53,7 +53,7 @@ public abstract class UnmodifiableRealVectorAbstractTest { * The list of methods which are excluded from the general test * {@link #testAllButExcluded()}. */ - protected static final Set EXCLUDE = new HashSet(); + protected static final Set EXCLUDE = new HashSet<>(); /** The random number generator (always initialized with the same seed. */ protected static final Random RANDOM; diff --git a/src/test/java/org/apache/commons/math4/ml/clustering/DBSCANClustererTest.java b/src/test/java/org/apache/commons/math4/ml/clustering/DBSCANClustererTest.java index 0820fbc586..e3413a709a 100644 --- a/src/test/java/org/apache/commons/math4/ml/clustering/DBSCANClustererTest.java +++ b/src/test/java/org/apache/commons/math4/ml/clustering/DBSCANClustererTest.java @@ -99,7 +99,7 @@ public void testCluster() { }; final DBSCANClusterer transformer = - new DBSCANClusterer(2.0, 5); + new DBSCANClusterer<>(2.0, 5); final List> clusters = transformer.cluster(Arrays.asList(points)); final List clusterOne = @@ -152,7 +152,7 @@ public void testSingleLink() { }; - final DBSCANClusterer clusterer = new DBSCANClusterer(3, 3); + final DBSCANClusterer clusterer = new DBSCANClusterer<>(3, 3); List> clusters = clusterer.cluster(Arrays.asList(points)); Assert.assertEquals(1, clusters.size()); @@ -164,13 +164,13 @@ public void testSingleLink() { @Test public void testGetEps() { - final DBSCANClusterer transformer = new DBSCANClusterer(2.0, 5); + final DBSCANClusterer transformer = new DBSCANClusterer<>(2.0, 5); Assert.assertEquals(2.0, transformer.getEps(), 0.0); } @Test public void testGetMinPts() { - final DBSCANClusterer transformer = new DBSCANClusterer(2.0, 5); + final DBSCANClusterer transformer = new DBSCANClusterer<>(2.0, 5); Assert.assertEquals(5, transformer.getMinPts()); } @@ -186,7 +186,7 @@ public void testNegativeMinPts() { @Test(expected = NullArgumentException.class) public void testNullDataset() { - DBSCANClusterer clusterer = new DBSCANClusterer(2.0, 5); + DBSCANClusterer clusterer = new DBSCANClusterer<>(2.0, 5); clusterer.cluster(null); } diff --git a/src/test/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClustererTest.java b/src/test/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClustererTest.java index a46c01ea77..dd5ca3623d 100644 --- a/src/test/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClustererTest.java +++ b/src/test/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClustererTest.java @@ -43,7 +43,7 @@ public class FuzzyKMeansClustererTest { @Test public void testCluster() { - final List points = new ArrayList(); + final List points = new ArrayList<>(); // create 10 data points: [1], ... [10] for (int i = 1; i <= 10; i++) { @@ -52,7 +52,7 @@ public void testCluster() { } final FuzzyKMeansClusterer transformer = - new FuzzyKMeansClusterer(3, 2.0); + new FuzzyKMeansClusterer<>(3, 2.0); final List> clusters = transformer.cluster(points); // we expect 3 clusters: @@ -90,7 +90,7 @@ public void testTooSmallFuzzynessFactor() { @Test(expected = NullArgumentException.class) public void testNullDataset() { - final FuzzyKMeansClusterer clusterer = new FuzzyKMeansClusterer(3, 2.0); + final FuzzyKMeansClusterer clusterer = new FuzzyKMeansClusterer<>(3, 2.0); clusterer.cluster(null); } @@ -99,7 +99,7 @@ public void testGetters() { final DistanceMeasure measure = new CanberraDistance(); final RandomGenerator random = new JDKRandomGenerator(); final FuzzyKMeansClusterer clusterer = - new FuzzyKMeansClusterer(3, 2.0, 100, measure, 1e-6, random); + new FuzzyKMeansClusterer<>(3, 2.0, 100, measure, 1e-6, random); Assert.assertEquals(3, clusterer.getK()); Assert.assertEquals(2.0, clusterer.getFuzziness(), 1e-6); @@ -111,11 +111,11 @@ public void testGetters() { @Test public void testSingleCluster() { - final List points = new ArrayList(); + final List points = new ArrayList<>(); points.add(new DoublePoint(new double[] { 1, 1 })); final FuzzyKMeansClusterer transformer = - new FuzzyKMeansClusterer(1, 2.0); + new FuzzyKMeansClusterer<>(1, 2.0); final List> clusters = transformer.cluster(points); Assert.assertEquals(1, clusters.size()); @@ -123,14 +123,14 @@ public void testSingleCluster() { @Test public void testClusterCenterEqualsPoints() { - final List points = new ArrayList(); + final List points = new ArrayList<>(); points.add(new DoublePoint(new double[] { 1, 1 })); points.add(new DoublePoint(new double[] { 1.00001, 1.00001 })); points.add(new DoublePoint(new double[] { 2, 2 })); points.add(new DoublePoint(new double[] { 3, 3 })); final FuzzyKMeansClusterer transformer = - new FuzzyKMeansClusterer(3, 2.0); + new FuzzyKMeansClusterer<>(3, 2.0); final List> clusters = transformer.cluster(points); Assert.assertEquals(3, clusters.size()); diff --git a/src/test/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClustererTest.java b/src/test/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClustererTest.java index 39ef2c53f4..56f262d55e 100644 --- a/src/test/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClustererTest.java +++ b/src/test/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClustererTest.java @@ -52,7 +52,7 @@ public void setUp() { @Test public void testPerformClusterAnalysisDegenerate() { KMeansPlusPlusClusterer transformer = - new KMeansPlusPlusClusterer(1, 1); + new KMeansPlusPlusClusterer<>(1, 1); DoublePoint[] points = new DoublePoint[] { new DoublePoint(new int[] { 1959, 325100 }), @@ -102,7 +102,7 @@ public void testCertainSpace() { for (int n = 2; n < 27; ++n) { KMeansPlusPlusClusterer transformer = - new KMeansPlusPlusClusterer(n, 100, new EuclideanDistance(), random, strategy); + new KMeansPlusPlusClusterer<>(n, 100, new EuclideanDistance(), random, strategy); List> clusters = transformer.cluster(Arrays.asList(breakingPoints)); @@ -143,7 +143,7 @@ public void testSmallDistances() { DoublePoint repeatedPoint = new DoublePoint(repeatedArray); DoublePoint uniquePoint = new DoublePoint(uniqueArray); - Collection points = new ArrayList(); + Collection points = new ArrayList<>(); final int NUM_REPEATED_POINTS = 10 * 1000; for (int i = 0; i < NUM_REPEATED_POINTS; ++i) { points.add(repeatedPoint); @@ -158,7 +158,7 @@ public void testSmallDistances() { random.setSeed(RANDOM_SEED); KMeansPlusPlusClusterer clusterer = - new KMeansPlusPlusClusterer(NUM_CLUSTERS, NUM_ITERATIONS, + new KMeansPlusPlusClusterer<>(NUM_CLUSTERS, NUM_ITERATIONS, new CloseDistance(), random); List> clusters = clusterer.cluster(points); @@ -178,7 +178,7 @@ public void testSmallDistances() { @Test(expected=NumberIsTooSmallException.class) public void testPerformClusterAnalysisToManyClusters() { KMeansPlusPlusClusterer transformer = - new KMeansPlusPlusClusterer(3, 1, new EuclideanDistance(), random); + new KMeansPlusPlusClusterer<>(3, 1, new EuclideanDistance(), random); DoublePoint[] points = new DoublePoint[] { new DoublePoint(new int[] { diff --git a/src/test/java/org/apache/commons/math4/ml/clustering/MultiKMeansPlusPlusClustererTest.java b/src/test/java/org/apache/commons/math4/ml/clustering/MultiKMeansPlusPlusClustererTest.java index d7071129c3..12816d7085 100644 --- a/src/test/java/org/apache/commons/math4/ml/clustering/MultiKMeansPlusPlusClustererTest.java +++ b/src/test/java/org/apache/commons/math4/ml/clustering/MultiKMeansPlusPlusClustererTest.java @@ -34,7 +34,7 @@ public class MultiKMeansPlusPlusClustererTest { @Test public void dimension2() { MultiKMeansPlusPlusClusterer transformer = - new MultiKMeansPlusPlusClusterer( + new MultiKMeansPlusPlusClusterer<>( new KMeansPlusPlusClusterer(3, 10), 5); DoublePoint[] points = new DoublePoint[] { diff --git a/src/test/java/org/apache/commons/math4/ml/clustering/evaluation/SumOfClusterVariancesTest.java b/src/test/java/org/apache/commons/math4/ml/clustering/evaluation/SumOfClusterVariancesTest.java index 0b20f8b05b..37c59a605f 100644 --- a/src/test/java/org/apache/commons/math4/ml/clustering/evaluation/SumOfClusterVariancesTest.java +++ b/src/test/java/org/apache/commons/math4/ml/clustering/evaluation/SumOfClusterVariancesTest.java @@ -38,7 +38,7 @@ public class SumOfClusterVariancesTest { @Before public void setUp() { - evaluator = new SumOfClusterVariances(new EuclideanDistance()); + evaluator = new SumOfClusterVariances<>(new EuclideanDistance()); } @Test @@ -55,9 +55,9 @@ public void testScore() { new DoublePoint(new double[] { 10 }) }; - final List> clusters = new ArrayList>(); + final List> clusters = new ArrayList<>(); - final Cluster cluster1 = new Cluster(); + final Cluster cluster1 = new Cluster<>(); for (DoublePoint p : points1) { cluster1.addPoint(p); } @@ -65,7 +65,7 @@ public void testScore() { assertEquals(1.0/3.0, evaluator.score(clusters), 1e-6); - final Cluster cluster2 = new Cluster(); + final Cluster cluster2 = new Cluster<>(); for (DoublePoint p : points2) { cluster2.addPoint(p); } diff --git a/src/test/java/org/apache/commons/math4/ml/neuralnet/MapUtilsTest.java b/src/test/java/org/apache/commons/math4/ml/neuralnet/MapUtilsTest.java index f716fc8d11..4404aacbc6 100644 --- a/src/test/java/org/apache/commons/math4/ml/neuralnet/MapUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/ml/neuralnet/MapUtilsTest.java @@ -49,8 +49,8 @@ public void testFindClosestNeuron() { final Network net = new NeuronString(3, false, initArray).getNetwork(); final DistanceMeasure dist = new EuclideanDistance(); - final Set allBest = new HashSet(); - final Set best = new HashSet(); + final Set allBest = new HashSet<>(); + final Set best = new HashSet<>(); double[][] features; // The following tests ensures that @@ -97,7 +97,7 @@ public void testFindClosestNeuron() { @Test public void testSort() { - final Set list = new HashSet(); + final Set list = new HashSet<>(); for (int i = 0; i < 4; i++) { list.add(new Neuron(i, new double[] { i - 0.5 })); diff --git a/src/test/java/org/apache/commons/math4/ml/neuralnet/oned/NeuronStringTest.java b/src/test/java/org/apache/commons/math4/ml/neuralnet/oned/NeuronStringTest.java index e7654fdc01..5871956bbd 100644 --- a/src/test/java/org/apache/commons/math4/ml/neuralnet/oned/NeuronStringTest.java +++ b/src/test/java/org/apache/commons/math4/ml/neuralnet/oned/NeuronStringTest.java @@ -139,7 +139,7 @@ public void testCircleNetwork() { public void testGetNeighboursWithExclude() { final FeatureInitializer[] initArray = { init }; final Network net = new NeuronString(5, true, initArray).getNetwork(); - final Collection exclude = new ArrayList(); + final Collection exclude = new ArrayList<>(); exclude.add(net.getNeuron(1)); final Collection neighbours = net.getNeighbours(net.getNeuron(0), exclude); diff --git a/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenTrainingTaskTest.java b/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenTrainingTaskTest.java index dd669d58d2..373a5bd902 100644 --- a/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenTrainingTaskTest.java +++ b/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenTrainingTaskTest.java @@ -112,7 +112,7 @@ public void testTravellerSalesmanSquareTourParallelSolver() throws ExecutionExce final ExecutorService service = Executors.newCachedThreadPool(); final int numProcs = Runtime.getRuntime().availableProcessors(); final Runnable[] tasks = solver.createParallelTasks(numProcs, 5000); - final List> execOutput = new ArrayList>(); + final List> execOutput = new ArrayList<>(); // Run tasks. for (Runnable r : tasks) { execOutput.add(service.submit(r)); @@ -165,7 +165,7 @@ private String travelCoordinatesTable(TravellingSalesmanSolver solver) { * @return the total distance. */ private Collection uniqueCities(City[] cityList) { - final Set unique = new HashSet(); + final Set unique = new HashSet<>(); for (City c : cityList) { unique.add(c); } diff --git a/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/TravellingSalesmanSolver.java b/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/TravellingSalesmanSolver.java index fea0f162ba..37a9b2df24 100644 --- a/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/TravellingSalesmanSolver.java +++ b/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/TravellingSalesmanSolver.java @@ -58,7 +58,7 @@ public class TravellingSalesmanSolver { /** RNG. */ private final RandomGenerator random; /** Set of cities. */ - private final Set cities = new HashSet(); + private final Set cities = new HashSet<>(); /** SOFM. */ private final Network net; /** Distance function. */ @@ -176,7 +176,7 @@ private static double computeUpdateRatio(Network net) { * @return the iterator. */ private Iterator createRandomIterator(final long numSamples) { - final List cityList = new ArrayList(); + final List cityList = new ArrayList<>(); cityList.addAll(cities); return new Iterator() { @@ -204,7 +204,7 @@ public void remove() { */ private List getNeuronList() { // Sequence of coordinates. - final List list = new ArrayList(); + final List list = new ArrayList<>(); // First neuron. Neuron current = net.getNeuron(FIRST_NEURON_ID); @@ -230,7 +230,7 @@ private List getNeuronList() { */ public List getCoordinatesList() { // Sequence of coordinates. - final List coordinatesList = new ArrayList(); + final List coordinatesList = new ArrayList<>(); for (Neuron n : getNeuronList()) { coordinatesList.add(n.getFeatures()); diff --git a/src/test/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2DTest.java b/src/test/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2DTest.java index d233b24fb8..833717514d 100644 --- a/src/test/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2DTest.java +++ b/src/test/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2DTest.java @@ -574,7 +574,7 @@ public void testConcentricNeighbourhood() { initArray).getNetwork(); Collection neighbours; - Collection exclude = new HashSet(); + Collection exclude = new HashSet<>(); // Level-1 neighbourhood. neighbours = net.getNeighbours(net.getNeuron(12)); @@ -623,7 +623,7 @@ public void testConcentricNeighbourhood2() { initArray).getNetwork(); Collection neighbours; - Collection exclude = new HashSet(); + Collection exclude = new HashSet<>(); // Level-1 neighbourhood. neighbours = net.getNeighbours(net.getNeuron(8)); @@ -854,13 +854,13 @@ public void testIterator() { 3, true, SquareNeighbourhood.VON_NEUMANN, initArray); - final Set fromMap = new HashSet(); + final Set fromMap = new HashSet<>(); for (Neuron n : map) { fromMap.add(n); } final Network net = map.getNetwork(); - final Set fromNet = new HashSet(); + final Set fromNet = new HashSet<>(); for (Neuron n : net) { fromNet.add(n); } diff --git a/src/test/java/org/apache/commons/math4/ode/ContinuousOutputFieldModelTest.java b/src/test/java/org/apache/commons/math4/ode/ContinuousOutputFieldModelTest.java index 870ee1e2f2..b50d0b9e45 100644 --- a/src/test/java/org/apache/commons/math4/ode/ContinuousOutputFieldModelTest.java +++ b/src/test/java/org/apache/commons/math4/ode/ContinuousOutputFieldModelTest.java @@ -42,12 +42,12 @@ public void testBoundaries() { } private > void doTestBoundaries(final Field field) { - TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); + TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); - FirstOrderFieldIntegrator integ = new DormandPrince54FieldIntegrator(field, minStep, maxStep, 1.0e-8, 1.0e-8); + FirstOrderFieldIntegrator integ = new DormandPrince54FieldIntegrator<>(field, minStep, maxStep, 1.0e-8, 1.0e-8); integ.addStepHandler(new ContinuousOutputFieldModel()); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); ContinuousOutputFieldModel cm = (ContinuousOutputFieldModel) integ.getStepHandlers().iterator().next(); cm.getInterpolatedState(pb.getInitialState().getTime().multiply(2).subtract(pb.getFinalTime())); cm.getInterpolatedState(pb.getFinalTime().multiply(2).subtract(pb.getInitialState().getTime())); @@ -61,13 +61,13 @@ public void testRandomAccess() { private > void doTestRandomAccess(final Field field) { - TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); + TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); - FirstOrderFieldIntegrator integ = new DormandPrince54FieldIntegrator(field, minStep, maxStep, 1.0e-8, 1.0e-8); - ContinuousOutputFieldModel cm = new ContinuousOutputFieldModel(); + FirstOrderFieldIntegrator integ = new DormandPrince54FieldIntegrator<>(field, minStep, maxStep, 1.0e-8, 1.0e-8); + ContinuousOutputFieldModel cm = new ContinuousOutputFieldModel<>(); integ.addStepHandler(cm); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Random random = new Random(347588535632l); T maxError = field.getZero(); @@ -117,32 +117,32 @@ public void init(T t0, T[] y0, T finalTime) { }; // integrate backward from π to 0; - ContinuousOutputFieldModel cm1 = new ContinuousOutputFieldModel(); + ContinuousOutputFieldModel cm1 = new ContinuousOutputFieldModel<>(); FirstOrderFieldIntegrator integ1 = - new DormandPrince853FieldIntegrator(field, 0, 1.0, 1.0e-8, 1.0e-8); + new DormandPrince853FieldIntegrator<>(field, 0, 1.0, 1.0e-8, 1.0e-8); integ1.addStepHandler(cm1); T t0 = field.getZero().add(FastMath.PI); T[] y0 = MathArrays.buildArray(field, 2); y0[0] = field.getOne().negate(); y0[1] = field.getZero(); - integ1.integrate(new FieldExpandableODE(problem), - new FieldODEState(t0, y0), + integ1.integrate(new FieldExpandableODE<>(problem), + new FieldODEState<>(t0, y0), field.getZero()); // integrate backward from 2π to π - ContinuousOutputFieldModel cm2 = new ContinuousOutputFieldModel(); + ContinuousOutputFieldModel cm2 = new ContinuousOutputFieldModel<>(); FirstOrderFieldIntegrator integ2 = - new DormandPrince853FieldIntegrator(field, 0, 0.1, 1.0e-12, 1.0e-12); + new DormandPrince853FieldIntegrator<>(field, 0, 0.1, 1.0e-12, 1.0e-12); integ2.addStepHandler(cm2); t0 = field.getZero().add(2.0 * FastMath.PI); y0[0] = field.getOne(); y0[1] = field.getZero(); - integ2.integrate(new FieldExpandableODE(problem), - new FieldODEState(t0, y0), + integ2.integrate(new FieldExpandableODE<>(problem), + new FieldODEState<>(t0, y0), field.getZero().add(FastMath.PI)); // merge the two half circles - ContinuousOutputFieldModel cm = new ContinuousOutputFieldModel(); + ContinuousOutputFieldModel cm = new ContinuousOutputFieldModel<>(); cm.append(cm2); cm.append(new ContinuousOutputFieldModel()); cm.append(cm1); @@ -164,7 +164,7 @@ public void testErrorConditions() { } private > void doTestErrorConditions(final Field field) { - ContinuousOutputFieldModel cm = new ContinuousOutputFieldModel(); + ContinuousOutputFieldModel cm = new ContinuousOutputFieldModel<>(); cm.handleStep(buildInterpolator(field, 0, 1, new double[] { 0.0, 1.0, -2.0 }), true); // dimension mismatch @@ -184,7 +184,7 @@ private > void doTestErrorConditions(final Field> boolean checkAppendError(Field field, ContinuousOutputFieldModel cm, double t0, double t1, double[] y) { try { - ContinuousOutputFieldModel otherCm = new ContinuousOutputFieldModel(); + ContinuousOutputFieldModel otherCm = new ContinuousOutputFieldModel<>(); otherCm.handleStep(buildInterpolator(field, t0, t1, y), true); cm.append(otherCm); } catch(DimensionMismatchException dme) { @@ -201,9 +201,9 @@ private > FieldStepInterpolator buildInterpolat for (int i = 0; i < y.length; ++i) { fieldY[i] = field.getZero().add(y[i]); } - final FieldODEStateAndDerivative s0 = new FieldODEStateAndDerivative(field.getZero().add(t0), fieldY, fieldY); - final FieldODEStateAndDerivative s1 = new FieldODEStateAndDerivative(field.getZero().add(t1), fieldY, fieldY); - final FieldEquationsMapper mapper = new FieldExpandableODE(new FirstOrderFieldDifferentialEquations() { + final FieldODEStateAndDerivative s0 = new FieldODEStateAndDerivative<>(field.getZero().add(t0), fieldY, fieldY); + final FieldODEStateAndDerivative s1 = new FieldODEStateAndDerivative<>(field.getZero().add(t1), fieldY, fieldY); + final FieldEquationsMapper mapper = new FieldExpandableODE<>(new FirstOrderFieldDifferentialEquations() { public int getDimension() { return s0.getStateDimension(); } @@ -213,7 +213,7 @@ public T[] computeDerivatives(T t, T[] y) { return y; } }).getMapper(); - return new DummyFieldStepInterpolator(t1 >= t0, s0, s1, s0, s1, mapper); + return new DummyFieldStepInterpolator<>(t1 >= t0, s0, s1, s0, s1, mapper); } public void checkValue(double value, double reference) { diff --git a/src/test/java/org/apache/commons/math4/ode/FieldExpandableODETest.java b/src/test/java/org/apache/commons/math4/ode/FieldExpandableODETest.java index 79070d03b6..20fc11f356 100644 --- a/src/test/java/org/apache/commons/math4/ode/FieldExpandableODETest.java +++ b/src/test/java/org/apache/commons/math4/ode/FieldExpandableODETest.java @@ -39,8 +39,8 @@ public void testOnlyMainEquation() { } private > void doTestOnlyMainEquation(final Field field) { - FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE(main); + FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE<>(main); Assert.assertEquals(main.getDimension(), equation.getMapper().getTotalDimension()); Assert.assertEquals(1, equation.getMapper().getNumberOfEquations()); T t0 = field.getZero().add(10); @@ -70,11 +70,11 @@ public void testMainAndSecondary() { private > void doTestMainAndSecondary(final Field field) { - FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE(main); - FieldSecondaryEquations secondary1 = new Linear(field, 3, main.getDimension()); + FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE<>(main); + FieldSecondaryEquations secondary1 = new Linear<>(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); - FieldSecondaryEquations secondary2 = new Linear(field, 5, main.getDimension() + secondary1.getDimension()); + FieldSecondaryEquations secondary2 = new Linear<>(field, 5, main.getDimension() + secondary1.getDimension()); int i2 = equation.addSecondaryEquations(secondary2); Assert.assertEquals(main.getDimension() + secondary1.getDimension() + secondary2.getDimension(), equation.getMapper().getTotalDimension()); @@ -127,11 +127,11 @@ public void testMap() { private > void doTestMap(final Field field) { - FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE(main); - FieldSecondaryEquations secondary1 = new Linear(field, 3, main.getDimension()); + FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE<>(main); + FieldSecondaryEquations secondary1 = new Linear<>(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); - FieldSecondaryEquations secondary2 = new Linear(field, 5, main.getDimension() + secondary1.getDimension()); + FieldSecondaryEquations secondary2 = new Linear<>(field, 5, main.getDimension() + secondary1.getDimension()); int i2 = equation.addSecondaryEquations(secondary2); Assert.assertEquals(main.getDimension() + secondary1.getDimension() + secondary2.getDimension(), equation.getMapper().getTotalDimension()); @@ -215,9 +215,9 @@ public void testExtractDimensionMismatch() { private > void doTestExtractDimensionMismatch(final Field field) throws DimensionMismatchException { - FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE(main); - FieldSecondaryEquations secondary1 = new Linear(field, 3, main.getDimension()); + FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE<>(main); + FieldSecondaryEquations secondary1 = new Linear<>(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); T[] tooShort = MathArrays.buildArray(field, main.getDimension()); equation.getMapper().extractEquationData(i1, tooShort); @@ -231,9 +231,9 @@ public void testInsertTooShortComplete() { private > void doTestInsertTooShortComplete(final Field field) throws DimensionMismatchException { - FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE(main); - FieldSecondaryEquations secondary1 = new Linear(field, 3, main.getDimension()); + FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE<>(main); + FieldSecondaryEquations secondary1 = new Linear<>(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); T[] equationData = MathArrays.buildArray(field, secondary1.getDimension()); T[] tooShort = MathArrays.buildArray(field, main.getDimension()); @@ -248,9 +248,9 @@ public void testInsertWrongEquationData() { private > void doTestInsertWrongEquationData(final Field field) throws DimensionMismatchException { - FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE(main); - FieldSecondaryEquations secondary1 = new Linear(field, 3, main.getDimension()); + FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE<>(main); + FieldSecondaryEquations secondary1 = new Linear<>(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); T[] wrongEquationData = MathArrays.buildArray(field, secondary1.getDimension() + 1); T[] complete = MathArrays.buildArray(field, equation.getMapper().getTotalDimension()); @@ -265,8 +265,8 @@ public void testNegativeIndex() { private > void doTestNegativeIndex(final Field field) throws MathIllegalArgumentException { - FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE(main); + FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE<>(main); T[] complete = MathArrays.buildArray(field, equation.getMapper().getTotalDimension()); equation.getMapper().extractEquationData(-1, complete); } @@ -279,8 +279,8 @@ public void testTooLargeIndex() { private > void doTestTooLargeIndex(final Field field) throws MathIllegalArgumentException { - FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE(main); + FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE<>(main); T[] complete = MathArrays.buildArray(field, equation.getMapper().getTotalDimension()); equation.getMapper().extractEquationData(+1, complete); } diff --git a/src/test/java/org/apache/commons/math4/ode/TestFieldProblem4.java b/src/test/java/org/apache/commons/math4/ode/TestFieldProblem4.java index cc797776e4..01db18f6a6 100644 --- a/src/test/java/org/apache/commons/math4/ode/TestFieldProblem4.java +++ b/src/test/java/org/apache/commons/math4/ode/TestFieldProblem4.java @@ -67,8 +67,8 @@ public FieldEventHandler[] getEventsHandlers() { @SuppressWarnings("unchecked") FieldEventHandler[] handlers = (FieldEventHandler[]) Array.newInstance(FieldEventHandler.class, 2); - handlers[0] = new Bounce(); - handlers[1] = new Stop(); + handlers[0] = new Bounce<>(); + handlers[1] = new Stop<>(); return handlers; } @@ -130,7 +130,7 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { T[] y = state.getState(); y[0] = y[0].negate(); y[1] = y[1].negate(); - return new FieldODEState(state.getTime(), y); + return new FieldODEState<>(state.getTime(), y); } } diff --git a/src/test/java/org/apache/commons/math4/ode/TestFieldProblemAbstract.java b/src/test/java/org/apache/commons/math4/ode/TestFieldProblemAbstract.java index 9d1b78b11c..cf404d677c 100644 --- a/src/test/java/org/apache/commons/math4/ode/TestFieldProblemAbstract.java +++ b/src/test/java/org/apache/commons/math4/ode/TestFieldProblemAbstract.java @@ -114,7 +114,7 @@ public int getDimension() { * @return initial state */ public FieldODEState getInitialState() { - return new FieldODEState(t0, y0); + return new FieldODEState<>(t0, y0); } /** diff --git a/src/test/java/org/apache/commons/math4/ode/events/OverlappingEventsTest.java b/src/test/java/org/apache/commons/math4/ode/events/OverlappingEventsTest.java index e489e4e22b..38f1cf33e1 100644 --- a/src/test/java/org/apache/commons/math4/ode/events/OverlappingEventsTest.java +++ b/src/test/java/org/apache/commons/math4/ode/events/OverlappingEventsTest.java @@ -90,8 +90,8 @@ public void test(int eventType) double t = 0.0; double tEnd = 10.0; double[] y = {0.0, 0.0}; - List events1 = new ArrayList(); - List events2 = new ArrayList(); + List events1 = new ArrayList<>(); + List events2 = new ArrayList<>(); while (t < tEnd) { t = integrator.integrate(this, t, y, tEnd, y); //System.out.println("t=" + t + ",\t\ty=[" + y[0] + "," + y[1] + "]"); diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java index 61372f51e8..aceede07eb 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java @@ -152,8 +152,8 @@ public T[] computeDerivatives(T t, T[] y) { EmbeddedRungeKuttaFieldIntegrator integrator = createIntegrator(field, 0.0, 1.0, 1.0e-10, 1.0e-10); try { - integrator.integrate(new FieldExpandableODE(equations), - new FieldODEState(field.getOne().negate(), + integrator.integrate(new FieldExpandableODE<>(equations), + new FieldODEState<>(field.getOne().negate(), MathArrays.buildArray(field, 1)), field.getZero()); Assert.fail("an exception should have been thrown"); @@ -162,8 +162,8 @@ public T[] computeDerivatives(T t, T[] y) { } try { - integrator.integrate(new FieldExpandableODE(equations), - new FieldODEState(field.getZero(), + integrator.integrate(new FieldExpandableODE<>(equations), + new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, 1)), field.getOne()); Assert.fail("an exception should have been thrown"); @@ -182,7 +182,7 @@ protected static class LocalException extends RuntimeException { protected > void doTestMinStep(final Field field) throws NumberIsTooSmallException { - TestFieldProblem1 pb = new TestFieldProblem1(field); + TestFieldProblem1 pb = new TestFieldProblem1<>(field); double minStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.1).getReal(); double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double[] vecAbsoluteTolerance = { 1.0e-15, 1.0e-16 }; @@ -190,9 +190,9 @@ protected > void doTestMinStep(final Field fiel FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); } @@ -206,7 +206,7 @@ protected > void doTestIncreasingTolerance(final F int previousCalls = Integer.MAX_VALUE; for (int i = -12; i < -2; ++i) { - TestFieldProblem1 pb = new TestFieldProblem1(field); + TestFieldProblem1 pb = new TestFieldProblem1<>(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = FastMath.pow(10.0, i); @@ -214,9 +214,9 @@ protected > void doTestIncreasingTolerance(final F FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertTrue(handler.getMaximalValueError().getReal() < (factor * scalAbsoluteTolerance)); Assert.assertEquals(0, handler.getMaximalTimeError().getReal(), epsilon); @@ -237,7 +237,7 @@ protected > void doTestEvents(final Field field final double epsilonMaxValue, final String name) { - TestFieldProblem4 pb = new TestFieldProblem4(field); + TestFieldProblem4 pb = new TestFieldProblem4<>(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -245,7 +245,7 @@ protected > void doTestEvents(final Field field FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); FieldEventHandler[] functions = pb.getEventsHandlers(); double convergence = 1.0e-8 * maxStep; @@ -253,7 +253,7 @@ protected > void doTestEvents(final Field field integ.addEventHandler(functions[l], Double.POSITIVE_INFINITY, convergence, 1000); } Assert.assertEquals(functions.length, integ.getEventHandlers().size()); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); Assert.assertEquals(0, handler.getMaximalTimeError().getReal(), convergence); @@ -269,7 +269,7 @@ protected > void doTestEvents(final Field field protected > void doTestEventsErrors(final Field field) throws LocalException { - final TestFieldProblem1 pb = new TestFieldProblem1(field); + final TestFieldProblem1 pb = new TestFieldProblem1<>(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -277,7 +277,7 @@ protected > void doTestEventsErrors(final Field FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); integ.addEventHandler(new FieldEventHandler() { @@ -299,7 +299,7 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { } }, Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); } @@ -308,7 +308,7 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { protected > void doTestEventsNoConvergence(final Field field){ - final TestFieldProblem1 pb = new TestFieldProblem1(field); + final TestFieldProblem1 pb = new TestFieldProblem1<>(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -316,7 +316,7 @@ protected > void doTestEventsNoConvergence(final F FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); integ.addEventHandler(new FieldEventHandler() { @@ -336,7 +336,7 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { }, Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 3); try { - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); } catch (MaxCountExceededException mcee) { // Expected. @@ -348,13 +348,13 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { public abstract void testSanityChecks(); protected > void doTestSanityChecks(Field field) { - TestFieldProblem3 pb = new TestFieldProblem3(field); + TestFieldProblem3 pb = new TestFieldProblem3<>(field); try { EmbeddedRungeKuttaFieldIntegrator integrator = createIntegrator(field, 0, pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(), new double[4], new double[4]); - integrator.integrate(new FieldExpandableODE(pb), - new FieldODEState(pb.getInitialState().getTime(), + integrator.integrate(new FieldExpandableODE<>(pb), + new FieldODEState<>(pb.getInitialState().getTime(), MathArrays.buildArray(field, 6)), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); @@ -365,7 +365,7 @@ protected > void doTestSanityChecks(Field field createIntegrator(field, 0, pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(), new double[2], new double[4]); - integrator.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integrator.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); } catch(DimensionMismatchException ie) { } @@ -374,7 +374,7 @@ protected > void doTestSanityChecks(Field field createIntegrator(field, 0, pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(), new double[4], new double[4]); - integrator.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getInitialState().getTime()); + integrator.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getInitialState().getTime()); Assert.fail("an exception should have been thrown"); } catch(NumberIsTooSmallException ie) { } @@ -391,7 +391,7 @@ protected > void doTestBackward(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem5 pb = new TestFieldProblem5(field); + TestFieldProblem5 pb = new TestFieldProblem5<>(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).abs().getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -400,9 +400,9 @@ protected > void doTestBackward(Field field, EmbeddedRungeKuttaFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getLastError().getReal(), epsilonLast); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); @@ -416,7 +416,7 @@ protected > void doTestBackward(Field field, protected > void doTestKepler(Field field, double epsilon) { - final TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); + final TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double[] vecAbsoluteTolerance = { 1.0e-8, 1.0e-8, 1.0e-10, 1.0e-10 }; @@ -424,8 +424,8 @@ protected > void doTestKepler(Field field, doub FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); - integ.addStepHandler(new KeplerHandler(pb, epsilon)); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.addStepHandler(new KeplerHandler<>(pb, epsilon)); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); } private static class KeplerHandler> implements FieldStepHandler { @@ -486,8 +486,8 @@ protected > void doTestPartialDerivatives(final do t.subtract(t0).multiply(0.001).getReal(), t.subtract(t0).getReal(), 1.0e-12, 1.0e-12); FieldODEStateAndDerivative result = - integrator.integrate(new FieldExpandableODE(sinCos), - new FieldODEState(t0, y0), + integrator.integrate(new FieldExpandableODE<>(sinCos), + new FieldODEState<>(t0, y0), t); // check values diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java index d79a19f150..80b682856f 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java @@ -151,8 +151,8 @@ public T[] computeDerivatives(T t, T[] y) { y0[i] = field.getOne().add(i); } - FieldODEStateAndDerivative result = integrator.integrate(new FieldExpandableODE(ode), - new FieldODEState(t0, y0), + FieldODEStateAndDerivative result = integrator.integrate(new FieldExpandableODE<>(ode), + new FieldODEState<>(t0, y0), tEvent); Assert.assertEquals(tEvent.getReal(), result.getTime().getReal(), epsilonT); T[] y = result.getState(); @@ -180,8 +180,8 @@ public Action eventOccurred(FieldODEStateAndDerivative state, boolean increas return Action.CONTINUE; } }, Double.POSITIVE_INFINITY, 1.0e-20, 100); - result = integrator.integrate(new FieldExpandableODE(ode), - new FieldODEState(t0, y0), + result = integrator.integrate(new FieldExpandableODE<>(ode), + new FieldODEState<>(t0, y0), tEvent.add(120)); Assert.assertEquals(tEvent.add(120).getReal(), result.getTime().getReal(), epsilonT); y = result.getState(); @@ -201,17 +201,17 @@ protected > void doTestSanityChecks(Field field MaxCountExceededException, NoBracketingException { RungeKuttaFieldIntegrator integrator = createIntegrator(field, field.getZero().add(0.01)); try { - TestFieldProblem1 pb = new TestFieldProblem1(field); - integrator.integrate(new FieldExpandableODE(pb), - new FieldODEState(field.getZero(), MathArrays.buildArray(field, pb.getDimension() + 10)), + TestFieldProblem1 pb = new TestFieldProblem1<>(field); + integrator.integrate(new FieldExpandableODE<>(pb), + new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, pb.getDimension() + 10)), field.getOne()); Assert.fail("an exception should have been thrown"); } catch(DimensionMismatchException ie) { } try { - TestFieldProblem1 pb = new TestFieldProblem1(field); - integrator.integrate(new FieldExpandableODE(pb), - new FieldODEState(field.getZero(), MathArrays.buildArray(field, pb.getDimension())), + TestFieldProblem1 pb = new TestFieldProblem1<>(field); + integrator.integrate(new FieldExpandableODE<>(pb), + new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, pb.getDimension())), field.getZero()); Assert.fail("an exception should have been thrown"); } catch(NumberIsTooSmallException ie) { @@ -231,12 +231,12 @@ protected > void doTestDecreasingSteps(Field fi @SuppressWarnings("unchecked") TestFieldProblemAbstract[] allProblems = (TestFieldProblemAbstract[]) Array.newInstance(TestFieldProblemAbstract.class, 6); - allProblems[0] = new TestFieldProblem1(field); - allProblems[1] = new TestFieldProblem2(field); - allProblems[2] = new TestFieldProblem3(field); - allProblems[3] = new TestFieldProblem4(field); - allProblems[4] = new TestFieldProblem5(field); - allProblems[5] = new TestFieldProblem6(field); + allProblems[0] = new TestFieldProblem1<>(field); + allProblems[1] = new TestFieldProblem2<>(field); + allProblems[2] = new TestFieldProblem3<>(field); + allProblems[3] = new TestFieldProblem4<>(field); + allProblems[4] = new TestFieldProblem5<>(field); + allProblems[5] = new TestFieldProblem6<>(field); for (TestFieldProblemAbstract pb : allProblems) { T previousValueError = null; @@ -246,7 +246,7 @@ protected > void doTestDecreasingSteps(Field fi T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(FastMath.pow(2.0, -i)); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); FieldEventHandler[] functions = pb.getEventsHandlers(); for (int l = 0; l < functions.length; ++l) { @@ -254,7 +254,7 @@ protected > void doTestDecreasingSteps(Field fi Double.POSITIVE_INFINITY, 1.0e-6 * step.getReal(), 1000); } Assert.assertEquals(functions.length, integ.getEventHandlers().size()); - FieldODEStateAndDerivative stop = integ.integrate(new FieldExpandableODE(pb), + FieldODEStateAndDerivative stop = integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); if (functions.length == 0) { @@ -292,13 +292,13 @@ protected > void doTestSmallStep(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem1 pb = new TestFieldProblem1(field); + TestFieldProblem1 pb = new TestFieldProblem1<>(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.001); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getLastError().getReal(), epsilonLast); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); @@ -318,13 +318,13 @@ protected > void doTestBigStep(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem1 pb = new TestFieldProblem1(field); + TestFieldProblem1 pb = new TestFieldProblem1<>(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.2); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertTrue(handler.getLastError().getReal() > belowLast); Assert.assertTrue(handler.getMaximalValueError().getReal() > belowMaxValue); @@ -344,13 +344,13 @@ protected > void doTestBackward(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem5 pb = new TestFieldProblem5(field); + TestFieldProblem5 pb = new TestFieldProblem5<>(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.001).abs(); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getLastError().getReal(), epsilonLast); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); @@ -366,12 +366,12 @@ protected > void doTestKepler(Field field, doub throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - final TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); + final TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.0003); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - integ.addStepHandler(new KeplerHandler(pb, expectedMaxError, epsilon)); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.addStepHandler(new KeplerHandler<>(pb, expectedMaxError, epsilon)); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); } private static class KeplerHandler> implements FieldStepHandler { @@ -424,7 +424,7 @@ public void handleStep(FieldStepInterpolator interpolator, boolean isLast) { public void init(FieldODEStateAndDerivative s0, T t) { } }); - integ.integrate(new FieldExpandableODE(new FirstOrderFieldDifferentialEquations() { + integ.integrate(new FieldExpandableODE<>(new FirstOrderFieldDifferentialEquations() { public void init(T t0, T[] y0, T t) { } public T[] computeDerivatives(T t, T[] y) { @@ -435,7 +435,7 @@ public T[] computeDerivatives(T t, T[] y) { public int getDimension() { return 1; } - }), new FieldODEState(field.getZero(), MathArrays.buildArray(field, 1)), field.getZero().add(5.0)); + }), new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, 1)), field.getZero().add(5.0)); } @Test @@ -443,7 +443,7 @@ public int getDimension() { protected > void doTestSingleStep(final Field field, final double epsilon) { - final TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); + final TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); T h = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.0003); RungeKuttaFieldIntegrator integ = createIntegrator(field, field.getZero().add(Double.NaN)); @@ -489,7 +489,7 @@ public T[] computeDerivatives(T t, T[] y) { }; - integ.integrate(new FieldExpandableODE(equations), new FieldODEState(t0, y0), t); + integ.integrate(new FieldExpandableODE<>(equations), new FieldODEState<>(t0, y0), t); } @@ -497,14 +497,14 @@ public T[] computeDerivatives(T t, T[] y) { public abstract void testUnstableDerivative(); protected > void doTestUnstableDerivative(Field field, double epsilon) { - final StepFieldProblem stepProblem = new StepFieldProblem(field, + final StepFieldProblem stepProblem = new StepFieldProblem<>(field, field.getZero().add(0.0), field.getZero().add(1.0), field.getZero().add(2.0)); RungeKuttaFieldIntegrator integ = createIntegrator(field, field.getZero().add(0.3)); integ.addEventHandler(stepProblem, 1.0, 1.0e-12, 1000); - FieldODEStateAndDerivative result = integ.integrate(new FieldExpandableODE(stepProblem), - new FieldODEState(field.getZero(), MathArrays.buildArray(field, 1)), + FieldODEStateAndDerivative result = integ.integrate(new FieldExpandableODE<>(stepProblem), + new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, 1)), field.getZero().add(10.0)); Assert.assertEquals(8.0, result.getState()[0].getReal(), epsilon); } @@ -513,7 +513,7 @@ protected > void doTestUnstableDerivative(Field public abstract void testDerivativesConsistency(); protected > void doTestDerivativesConsistency(final Field field, double epsilon) { - TestFieldProblem3 pb = new TestFieldProblem3(field); + TestFieldProblem3 pb = new TestFieldProblem3<>(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.001); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); StepInterpolatorTestUtils.checkDerivativesConsistency(integ, pb, 1.0e-10); @@ -546,8 +546,8 @@ protected > void doTestPartialDerivatives(final do RungeKuttaFieldIntegrator integrator = createIntegrator(omega.getField(), t.subtract(t0).multiply(0.001)); FieldODEStateAndDerivative result = - integrator.integrate(new FieldExpandableODE(sinCos), - new FieldODEState(t0, y0), + integrator.integrate(new FieldExpandableODE<>(sinCos), + new FieldODEState<>(t0, y0), t); // check values diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegratorTest.java index ed69ccd69b..15d05a8aac 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegratorTest.java @@ -31,14 +31,14 @@ public class AdamsBashforthFieldIntegratorTest extends AdamsFieldIntegratorAbstr protected > AdamsFieldIntegrator createIntegrator(Field field, final int nSteps, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance) { - return new AdamsBashforthFieldIntegrator(field, nSteps, minStep, maxStep, + return new AdamsBashforthFieldIntegrator<>(field, nSteps, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); } protected > AdamsFieldIntegrator createIntegrator(Field field, final int nSteps, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) { - return new AdamsBashforthFieldIntegrator(field, nSteps, minStep, maxStep, + return new AdamsBashforthFieldIntegrator<>(field, nSteps, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); } diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldIntegratorAbstractTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldIntegratorAbstractTest.java index 340dd4888f..1f786bcd83 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldIntegratorAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldIntegratorAbstractTest.java @@ -54,7 +54,7 @@ public abstract class AdamsFieldIntegratorAbstractTest { public abstract void testMinStep(); protected > void doDimensionCheck(final Field field) { - TestFieldProblem1 pb = new TestFieldProblem1(field); + TestFieldProblem1 pb = new TestFieldProblem1<>(field); double minStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.1).getReal(); double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); @@ -64,9 +64,9 @@ protected > void doDimensionCheck(final Field f FirstOrderFieldIntegrator integ = createIntegrator(field, 4, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); } @@ -78,7 +78,7 @@ protected > void doTestIncreasingTolerance(final F int previousCalls = Integer.MAX_VALUE; for (int i = -12; i < -2; ++i) { - TestFieldProblem1 pb = new TestFieldProblem1(field); + TestFieldProblem1 pb = new TestFieldProblem1<>(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = FastMath.pow(10.0, i); @@ -87,9 +87,9 @@ protected > void doTestIncreasingTolerance(final F FirstOrderFieldIntegrator integ = createIntegrator(field, 4, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertTrue(handler.getMaximalValueError().getReal() > ratioMin * scalAbsoluteTolerance); Assert.assertTrue(handler.getMaximalValueError().getReal() < ratioMax * scalAbsoluteTolerance); @@ -108,14 +108,14 @@ protected > void doTestIncreasingTolerance(final F protected > void doExceedMaxEvaluations(final Field field, final int max) { - TestFieldProblem1 pb = new TestFieldProblem1(field); + TestFieldProblem1 pb = new TestFieldProblem1<>(field); double range = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); FirstOrderFieldIntegrator integ = createIntegrator(field, 2, 0, range, 1.0e-12, 1.0e-12); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); integ.setMaxEvaluations(max); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); } @@ -128,13 +128,13 @@ protected > void doBackward(final Field field, final double epsilonMaxTime, final String name) { - TestFieldProblem5 pb = new TestFieldProblem5(field); + TestFieldProblem5 pb = new TestFieldProblem5<>(field); double range = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); AdamsFieldIntegrator integ = createIntegrator(field, 4, 0, range, 1.0e-12, 1.0e-12); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0.0, handler.getLastError().getReal(), epsilonLast); Assert.assertEquals(0.0, handler.getMaximalValueError().getReal(), epsilonMaxValue); @@ -149,15 +149,15 @@ protected > void doPolynomial(final Field field final int nLimit, final double epsilonBad, final double epsilonGood) { - TestFieldProblem6 pb = new TestFieldProblem6(field); + TestFieldProblem6 pb = new TestFieldProblem6<>(field); double range = pb.getFinalTime().subtract(pb.getInitialState().getTime()).abs().getReal(); for (int nSteps = 2; nSteps < 8; ++nSteps) { AdamsFieldIntegrator integ = createIntegrator(field, nSteps, 1.0e-6 * range, 0.1 * range, 1.0e-4, 1.0e-4); - integ.setStarterIntegrator(new PerfectStarter(pb, nSteps)); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + integ.setStarterIntegrator(new PerfectStarter<>(pb, nSteps)); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); if (nSteps < nLimit) { Assert.assertTrue(handler.getMaximalValueError().getReal() > epsilonBad); } else { @@ -171,7 +171,7 @@ protected > void doPolynomial(final Field field public abstract void testStartFailure(); protected > void doTestStartFailure(final Field field) { - TestFieldProblem1 pb = new TestFieldProblem1(field); + TestFieldProblem1 pb = new TestFieldProblem1<>(field); double minStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.0001).getReal(); double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = 1.0e-6; @@ -180,10 +180,10 @@ protected > void doTestStartFailure(final Field MultistepFieldIntegrator integ = createIntegrator(field, 6, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - integ.setStarterIntegrator(new DormandPrince853FieldIntegrator(field, maxStep * 0.5, maxStep, 0.1, 0.1)); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + integ.setStarterIntegrator(new DormandPrince853FieldIntegrator<>(field, maxStep * 0.5, maxStep, 0.1, 0.1)); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); } @@ -194,7 +194,7 @@ private static class PerfectStarter> extends Abstr public PerfectStarter(final TestFieldProblemAbstract problem, final int nbSteps) { super(problem.getField(), "perfect-starter"); - this.interpolator = new PerfectInterpolator(problem); + this.interpolator = new PerfectInterpolator<>(problem); this.nbSteps = nbSteps; } @@ -252,7 +252,7 @@ public FieldODEStateAndDerivative getCurrentState() { public FieldODEStateAndDerivative getInterpolatedState(T time) { T[] y = problem.computeTheoreticalState(time); T[] yDot = problem.computeDerivatives(time, y); - return new FieldODEStateAndDerivative(time, y, yDot); + return new FieldODEStateAndDerivative<>(time, y, yDot); } } diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegratorTest.java index 51eb7efda4..84a0f7d24d 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegratorTest.java @@ -31,14 +31,14 @@ public class AdamsMoultonFieldIntegratorTest extends AdamsFieldIntegratorAbstrac protected > AdamsFieldIntegrator createIntegrator(Field field, final int nSteps, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance) { - return new AdamsMoultonFieldIntegrator(field, nSteps, minStep, maxStep, + return new AdamsMoultonFieldIntegrator<>(field, nSteps, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); } protected > AdamsFieldIntegrator createIntegrator(Field field, final int nSteps, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) { - return new AdamsMoultonFieldIntegrator(field, nSteps, minStep, maxStep, + return new AdamsMoultonFieldIntegrator<>(field, nSteps, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); } diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungKuttaFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungKuttaFieldStepInterpolatorTest.java index bbe30c2ccf..f484baacb9 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungKuttaFieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungKuttaFieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class ClassicalRungKuttaFieldStepInterpolatorTest extends RungeKuttaField FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new ClassicalRungeKuttaFieldStepInterpolator(field, forward, yDotK, + return new ClassicalRungeKuttaFieldStepInterpolator<>(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class ClassicalRungKuttaFieldStepInterpolatorTest extends RungeKuttaField protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new ClassicalRungeKuttaFieldIntegrator(field, field.getOne()); + return new ClassicalRungeKuttaFieldIntegrator<>(field, field.getOne()); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegratorTest.java index 3cd0e3558e..ebc996256d 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegratorTest.java @@ -26,7 +26,7 @@ public class ClassicalRungeKuttaFieldIntegratorTest extends RungeKuttaFieldInteg protected > RungeKuttaFieldIntegrator createIntegrator(Field field, T step) { - return new ClassicalRungeKuttaFieldIntegrator(field, step); + return new ClassicalRungeKuttaFieldIntegrator<>(field, step); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegratorTest.java index da908035b2..28267e0457 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegratorTest.java @@ -27,13 +27,13 @@ public class DormandPrince54FieldIntegratorTest extends EmbeddedRungeKuttaFieldI protected > EmbeddedRungeKuttaFieldIntegrator createIntegrator(Field field, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance) { - return new DormandPrince54FieldIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); + return new DormandPrince54FieldIntegrator<>(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); } protected > EmbeddedRungeKuttaFieldIntegrator createIntegrator(Field field, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) { - return new DormandPrince54FieldIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); + return new DormandPrince54FieldIntegrator<>(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolatorTest.java index 9b6d607078..b10501fb87 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class DormandPrince54FieldStepInterpolatorTest extends RungeKuttaFieldSte FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new DormandPrince54FieldStepInterpolator(field, forward, yDotK, + return new DormandPrince54FieldStepInterpolator<>(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class DormandPrince54FieldStepInterpolatorTest extends RungeKuttaFieldSte protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new DormandPrince54FieldIntegrator(field, 0, 1, 1, 1); + return new DormandPrince54FieldIntegrator<>(field, 0, 1, 1, 1); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegratorTest.java index bc73968059..258ccc7d74 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegratorTest.java @@ -27,13 +27,13 @@ public class DormandPrince853FieldIntegratorTest extends EmbeddedRungeKuttaField protected > EmbeddedRungeKuttaFieldIntegrator createIntegrator(Field field, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance) { - return new DormandPrince853FieldIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); + return new DormandPrince853FieldIntegrator<>(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); } protected > EmbeddedRungeKuttaFieldIntegrator createIntegrator(Field field, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) { - return new DormandPrince853FieldIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); + return new DormandPrince853FieldIntegrator<>(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolatorTest.java index 5591b4d8df..69dbec4a9b 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class DormandPrince853FieldStepInterpolatorTest extends RungeKuttaFieldSt FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new DormandPrince853FieldStepInterpolator(field, forward, yDotK, + return new DormandPrince853FieldStepInterpolator<>(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class DormandPrince853FieldStepInterpolatorTest extends RungeKuttaFieldSt protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new DormandPrince853FieldIntegrator(field, 0, 1, 1, 1); + return new DormandPrince853FieldIntegrator<>(field, 0, 1, 1, 1); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java index 045e77de7e..edb9501284 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java @@ -152,8 +152,8 @@ public T[] computeDerivatives(T t, T[] y) { EmbeddedRungeKuttaFieldIntegrator integrator = createIntegrator(field, 0.0, 1.0, 1.0e-10, 1.0e-10); try { - integrator.integrate(new FieldExpandableODE(equations), - new FieldODEState(field.getOne().negate(), + integrator.integrate(new FieldExpandableODE<>(equations), + new FieldODEState<>(field.getOne().negate(), MathArrays.buildArray(field, 1)), field.getZero()); Assert.fail("an exception should have been thrown"); @@ -162,8 +162,8 @@ public T[] computeDerivatives(T t, T[] y) { } try { - integrator.integrate(new FieldExpandableODE(equations), - new FieldODEState(field.getZero(), + integrator.integrate(new FieldExpandableODE<>(equations), + new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, 1)), field.getOne()); Assert.fail("an exception should have been thrown"); @@ -182,7 +182,7 @@ protected static class LocalException extends RuntimeException { protected > void doTestMinStep(final Field field) throws NumberIsTooSmallException { - TestFieldProblem1 pb = new TestFieldProblem1(field); + TestFieldProblem1 pb = new TestFieldProblem1<>(field); double minStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.1).getReal(); double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double[] vecAbsoluteTolerance = { 1.0e-15, 1.0e-16 }; @@ -190,9 +190,9 @@ protected > void doTestMinStep(final Field fiel FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); } @@ -206,7 +206,7 @@ protected > void doTestIncreasingTolerance(final F int previousCalls = Integer.MAX_VALUE; for (int i = -12; i < -2; ++i) { - TestFieldProblem1 pb = new TestFieldProblem1(field); + TestFieldProblem1 pb = new TestFieldProblem1<>(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = FastMath.pow(10.0, i); @@ -214,9 +214,9 @@ protected > void doTestIncreasingTolerance(final F FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertTrue(handler.getMaximalValueError().getReal() < (factor * scalAbsoluteTolerance)); Assert.assertEquals(0, handler.getMaximalTimeError().getReal(), epsilon); @@ -237,7 +237,7 @@ protected > void doTestEvents(final Field field final double epsilonMaxValue, final String name) { - TestFieldProblem4 pb = new TestFieldProblem4(field); + TestFieldProblem4 pb = new TestFieldProblem4<>(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -245,7 +245,7 @@ protected > void doTestEvents(final Field field FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); FieldEventHandler[] functions = pb.getEventsHandlers(); double convergence = 1.0e-8 * maxStep; @@ -253,7 +253,7 @@ protected > void doTestEvents(final Field field integ.addEventHandler(functions[l], Double.POSITIVE_INFINITY, convergence, 1000); } Assert.assertEquals(functions.length, integ.getEventHandlers().size()); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); Assert.assertEquals(0, handler.getMaximalTimeError().getReal(), convergence); @@ -269,7 +269,7 @@ protected > void doTestEvents(final Field field protected > void doTestEventsErrors(final Field field) throws LocalException { - final TestFieldProblem1 pb = new TestFieldProblem1(field); + final TestFieldProblem1 pb = new TestFieldProblem1<>(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -277,7 +277,7 @@ protected > void doTestEventsErrors(final Field FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); integ.addEventHandler(new FieldEventHandler() { @@ -299,7 +299,7 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { } }, Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); } @@ -308,7 +308,7 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { protected > void doTestEventsNoConvergence(final Field field){ - final TestFieldProblem1 pb = new TestFieldProblem1(field); + final TestFieldProblem1 pb = new TestFieldProblem1<>(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -316,7 +316,7 @@ protected > void doTestEventsNoConvergence(final F FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); integ.addEventHandler(new FieldEventHandler() { @@ -336,7 +336,7 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { }, Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 3); try { - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); } catch (MaxCountExceededException mcee) { // Expected. @@ -348,13 +348,13 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { public abstract void testSanityChecks(); protected > void doTestSanityChecks(Field field) { - TestFieldProblem3 pb = new TestFieldProblem3(field); + TestFieldProblem3 pb = new TestFieldProblem3<>(field); try { EmbeddedRungeKuttaFieldIntegrator integrator = createIntegrator(field, 0, pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(), new double[4], new double[4]); - integrator.integrate(new FieldExpandableODE(pb), - new FieldODEState(pb.getInitialState().getTime(), + integrator.integrate(new FieldExpandableODE<>(pb), + new FieldODEState<>(pb.getInitialState().getTime(), MathArrays.buildArray(field, 6)), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); @@ -365,7 +365,7 @@ protected > void doTestSanityChecks(Field field createIntegrator(field, 0, pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(), new double[2], new double[4]); - integrator.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integrator.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); } catch(DimensionMismatchException ie) { } @@ -374,7 +374,7 @@ protected > void doTestSanityChecks(Field field createIntegrator(field, 0, pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(), new double[4], new double[4]); - integrator.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getInitialState().getTime()); + integrator.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getInitialState().getTime()); Assert.fail("an exception should have been thrown"); } catch(NumberIsTooSmallException ie) { } @@ -391,7 +391,7 @@ protected > void doTestBackward(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem5 pb = new TestFieldProblem5(field); + TestFieldProblem5 pb = new TestFieldProblem5<>(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).abs().getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -400,9 +400,9 @@ protected > void doTestBackward(Field field, EmbeddedRungeKuttaFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getLastError().getReal(), epsilonLast); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); @@ -416,7 +416,7 @@ protected > void doTestBackward(Field field, protected > void doTestKepler(Field field, double epsilon) { - final TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); + final TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double[] vecAbsoluteTolerance = { 1.0e-8, 1.0e-8, 1.0e-10, 1.0e-10 }; @@ -424,8 +424,8 @@ protected > void doTestKepler(Field field, doub FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); - integ.addStepHandler(new KeplerHandler(pb, epsilon)); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.addStepHandler(new KeplerHandler<>(pb, epsilon)); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); } private static class KeplerHandler> implements FieldStepHandler { @@ -486,8 +486,8 @@ protected void doTestPartialDerivatives(final double epsilonY, t.subtract(t0).multiply(0.001).getReal(), t.subtract(t0).getReal(), 1.0e-12, 1.0e-12); FieldODEStateAndDerivative result = - integrator.integrate(new FieldExpandableODE(sinCos), - new FieldODEState(t0, y0), + integrator.integrate(new FieldExpandableODE<>(sinCos), + new FieldODEState<>(t0, y0), t); // check values diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegratorTest.java index 9a48986819..d492cab4c9 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegratorTest.java @@ -26,7 +26,7 @@ public class EulerFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstractT protected > RungeKuttaFieldIntegrator createIntegrator(Field field, T step) { - return new EulerFieldIntegrator(field, step); + return new EulerFieldIntegrator<>(field, step); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolatorTest.java index c5d1c3b727..9f7f1ffe6d 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolatorTest.java @@ -33,7 +33,7 @@ public class EulerFieldStepInterpolatorTest extends RungeKuttaFieldStepInterpola FieldODEStateAndDerivative globalCurrentState, FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new EulerFieldStepInterpolator(field, forward, yDotK, + return new EulerFieldStepInterpolator<>(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -41,7 +41,7 @@ public class EulerFieldStepInterpolatorTest extends RungeKuttaFieldStepInterpola protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new EulerFieldIntegrator(field, field.getOne()); + return new EulerFieldIntegrator<>(field, field.getOne()); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegratorTest.java index 877321beb5..7100cbf952 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegratorTest.java @@ -26,7 +26,7 @@ public class GillFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstractTe protected > RungeKuttaFieldIntegrator createIntegrator(Field field, T step) { - return new GillFieldIntegrator(field, step); + return new GillFieldIntegrator<>(field, step); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolatorTest.java index 87a9b10cac..3c7d21c7eb 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class GillFieldStepInterpolatorTest extends RungeKuttaFieldStepInterpolat FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new GillFieldStepInterpolator(field, forward, yDotK, + return new GillFieldStepInterpolator<>(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class GillFieldStepInterpolatorTest extends RungeKuttaFieldStepInterpolat protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new GillFieldIntegrator(field, field.getOne()); + return new GillFieldIntegrator<>(field, field.getOne()); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegratorTest.java index 0630fcc176..6263e7c037 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegratorTest.java @@ -27,13 +27,13 @@ public class HighamHall54FieldIntegratorTest extends EmbeddedRungeKuttaFieldInte protected > EmbeddedRungeKuttaFieldIntegrator createIntegrator(Field field, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance) { - return new HighamHall54FieldIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); + return new HighamHall54FieldIntegrator<>(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); } protected > EmbeddedRungeKuttaFieldIntegrator createIntegrator(Field field, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) { - return new HighamHall54FieldIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); + return new HighamHall54FieldIntegrator<>(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolatorTest.java index 12c9473f16..7559e98754 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class HighamHall54FieldStepInterpolatorTest extends RungeKuttaFieldStepIn FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new HighamHall54FieldStepInterpolator(field, forward, yDotK, + return new HighamHall54FieldStepInterpolator<>(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class HighamHall54FieldStepInterpolatorTest extends RungeKuttaFieldStepIn protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new HighamHall54FieldIntegrator(field, 0, 1, 1, 1); + return new HighamHall54FieldIntegrator<>(field, 0, 1, 1, 1); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegratorTest.java index 9f459cfe6e..31db1769c5 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegratorTest.java @@ -30,7 +30,7 @@ public class LutherFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstract protected > RungeKuttaFieldIntegrator createIntegrator(Field field, T step) { - return new LutherFieldIntegrator(field, step); + return new LutherFieldIntegrator<>(field, step); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolatorTest.java index e35e1ecadf..1a0d5e2f0d 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class LutherFieldStepInterpolatorTest extends RungeKuttaFieldStepInterpol FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new LutherFieldStepInterpolator(field, forward, yDotK, + return new LutherFieldStepInterpolator<>(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class LutherFieldStepInterpolatorTest extends RungeKuttaFieldStepInterpol protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new LutherFieldIntegrator(field, field.getOne()); + return new LutherFieldIntegrator<>(field, field.getOne()); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegratorTest.java index d983146c52..0f64075d14 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegratorTest.java @@ -26,7 +26,7 @@ public class MidpointFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstra protected > RungeKuttaFieldIntegrator createIntegrator(Field field, T step) { - return new MidpointFieldIntegrator(field, step); + return new MidpointFieldIntegrator<>(field, step); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolatorTest.java index b1008e58bf..ef0aa9cca3 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class MidpointFieldStepInterpolatorTest extends RungeKuttaFieldStepInterp FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new MidpointFieldStepInterpolator(field, forward, yDotK, + return new MidpointFieldStepInterpolator<>(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class MidpointFieldStepInterpolatorTest extends RungeKuttaFieldStepInterp protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new MidpointFieldIntegrator(field, field.getOne()); + return new MidpointFieldIntegrator<>(field, field.getOne()); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java index 788f732add..a6d480cef0 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java @@ -151,8 +151,8 @@ public T[] computeDerivatives(T t, T[] y) { y0[i] = field.getOne().add(i); } - FieldODEStateAndDerivative result = integrator.integrate(new FieldExpandableODE(ode), - new FieldODEState(t0, y0), + FieldODEStateAndDerivative result = integrator.integrate(new FieldExpandableODE<>(ode), + new FieldODEState<>(t0, y0), tEvent); Assert.assertEquals(tEvent.getReal(), result.getTime().getReal(), epsilonT); T[] y = result.getState(); @@ -180,8 +180,8 @@ public Action eventOccurred(FieldODEStateAndDerivative state, boolean increas return Action.CONTINUE; } }, Double.POSITIVE_INFINITY, 1.0e-20, 100); - result = integrator.integrate(new FieldExpandableODE(ode), - new FieldODEState(t0, y0), + result = integrator.integrate(new FieldExpandableODE<>(ode), + new FieldODEState<>(t0, y0), tEvent.add(120)); Assert.assertEquals(tEvent.add(120).getReal(), result.getTime().getReal(), epsilonT); y = result.getState(); @@ -201,17 +201,17 @@ protected > void doTestSanityChecks(Field field MaxCountExceededException, NoBracketingException { RungeKuttaFieldIntegrator integrator = createIntegrator(field, field.getZero().add(0.01)); try { - TestFieldProblem1 pb = new TestFieldProblem1(field); - integrator.integrate(new FieldExpandableODE(pb), - new FieldODEState(field.getZero(), MathArrays.buildArray(field, pb.getDimension() + 10)), + TestFieldProblem1 pb = new TestFieldProblem1<>(field); + integrator.integrate(new FieldExpandableODE<>(pb), + new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, pb.getDimension() + 10)), field.getOne()); Assert.fail("an exception should have been thrown"); } catch(DimensionMismatchException ie) { } try { - TestFieldProblem1 pb = new TestFieldProblem1(field); - integrator.integrate(new FieldExpandableODE(pb), - new FieldODEState(field.getZero(), MathArrays.buildArray(field, pb.getDimension())), + TestFieldProblem1 pb = new TestFieldProblem1<>(field); + integrator.integrate(new FieldExpandableODE<>(pb), + new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, pb.getDimension())), field.getZero()); Assert.fail("an exception should have been thrown"); } catch(NumberIsTooSmallException ie) { @@ -231,12 +231,12 @@ protected > void doTestDecreasingSteps(Field fi @SuppressWarnings("unchecked") TestFieldProblemAbstract[] allProblems = (TestFieldProblemAbstract[]) Array.newInstance(TestFieldProblemAbstract.class, 6); - allProblems[0] = new TestFieldProblem1(field); - allProblems[1] = new TestFieldProblem2(field); - allProblems[2] = new TestFieldProblem3(field); - allProblems[3] = new TestFieldProblem4(field); - allProblems[4] = new TestFieldProblem5(field); - allProblems[5] = new TestFieldProblem6(field); + allProblems[0] = new TestFieldProblem1<>(field); + allProblems[1] = new TestFieldProblem2<>(field); + allProblems[2] = new TestFieldProblem3<>(field); + allProblems[3] = new TestFieldProblem4<>(field); + allProblems[4] = new TestFieldProblem5<>(field); + allProblems[5] = new TestFieldProblem6<>(field); for (TestFieldProblemAbstract pb : allProblems) { T previousValueError = null; @@ -246,7 +246,7 @@ protected > void doTestDecreasingSteps(Field fi T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(FastMath.pow(2.0, -i)); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); FieldEventHandler[] functions = pb.getEventsHandlers(); for (int l = 0; l < functions.length; ++l) { @@ -254,7 +254,7 @@ protected > void doTestDecreasingSteps(Field fi Double.POSITIVE_INFINITY, 1.0e-6 * step.getReal(), 1000); } Assert.assertEquals(functions.length, integ.getEventHandlers().size()); - FieldODEStateAndDerivative stop = integ.integrate(new FieldExpandableODE(pb), + FieldODEStateAndDerivative stop = integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); if (functions.length == 0) { @@ -292,13 +292,13 @@ protected > void doTestSmallStep(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem1 pb = new TestFieldProblem1(field); + TestFieldProblem1 pb = new TestFieldProblem1<>(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.001); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getLastError().getReal(), epsilonLast); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); @@ -318,13 +318,13 @@ protected > void doTestBigStep(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem1 pb = new TestFieldProblem1(field); + TestFieldProblem1 pb = new TestFieldProblem1<>(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.2); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertTrue(handler.getLastError().getReal() > belowLast); Assert.assertTrue(handler.getMaximalValueError().getReal() > belowMaxValue); @@ -344,13 +344,13 @@ protected > void doTestBackward(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem5 pb = new TestFieldProblem5(field); + TestFieldProblem5 pb = new TestFieldProblem5<>(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.001).abs(); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getLastError().getReal(), epsilonLast); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); @@ -366,12 +366,12 @@ protected > void doTestKepler(Field field, doub throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - final TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); + final TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.0003); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - integ.addStepHandler(new KeplerHandler(pb, expectedMaxError, epsilon)); - integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); + integ.addStepHandler(new KeplerHandler<>(pb, expectedMaxError, epsilon)); + integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); } private static class KeplerHandler> implements FieldStepHandler { @@ -424,7 +424,7 @@ public void handleStep(FieldStepInterpolator interpolator, boolean isLast) { public void init(FieldODEStateAndDerivative s0, T t) { } }); - integ.integrate(new FieldExpandableODE(new FirstOrderFieldDifferentialEquations() { + integ.integrate(new FieldExpandableODE<>(new FirstOrderFieldDifferentialEquations() { public void init(T t0, T[] y0, T t) { } public T[] computeDerivatives(T t, T[] y) { @@ -435,7 +435,7 @@ public T[] computeDerivatives(T t, T[] y) { public int getDimension() { return 1; } - }), new FieldODEState(field.getZero(), MathArrays.buildArray(field, 1)), field.getZero().add(5.0)); + }), new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, 1)), field.getZero().add(5.0)); } @Test @@ -443,7 +443,7 @@ public int getDimension() { protected > void doTestSingleStep(final Field field, final double epsilon) { - final TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); + final TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); T h = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.0003); RungeKuttaFieldIntegrator integ = createIntegrator(field, field.getZero().add(Double.NaN)); @@ -489,7 +489,7 @@ public T[] computeDerivatives(T t, T[] y) { }; - integ.integrate(new FieldExpandableODE(equations), new FieldODEState(t0, y0), t); + integ.integrate(new FieldExpandableODE<>(equations), new FieldODEState<>(t0, y0), t); } @@ -497,14 +497,14 @@ public T[] computeDerivatives(T t, T[] y) { public abstract void testUnstableDerivative(); protected > void doTestUnstableDerivative(Field field, double epsilon) { - final StepFieldProblem stepProblem = new StepFieldProblem(field, + final StepFieldProblem stepProblem = new StepFieldProblem<>(field, field.getZero().add(0.0), field.getZero().add(1.0), field.getZero().add(2.0)); RungeKuttaFieldIntegrator integ = createIntegrator(field, field.getZero().add(0.3)); integ.addEventHandler(stepProblem, 1.0, 1.0e-12, 1000); - FieldODEStateAndDerivative result = integ.integrate(new FieldExpandableODE(stepProblem), - new FieldODEState(field.getZero(), MathArrays.buildArray(field, 1)), + FieldODEStateAndDerivative result = integ.integrate(new FieldExpandableODE<>(stepProblem), + new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, 1)), field.getZero().add(10.0)); Assert.assertEquals(8.0, result.getState()[0].getReal(), epsilon); } @@ -513,7 +513,7 @@ protected > void doTestUnstableDerivative(Field public abstract void testDerivativesConsistency(); protected > void doTestDerivativesConsistency(final Field field, double epsilon) { - TestFieldProblem3 pb = new TestFieldProblem3(field); + TestFieldProblem3 pb = new TestFieldProblem3<>(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.001); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); StepInterpolatorTestUtils.checkDerivativesConsistency(integ, pb, 1.0e-10); @@ -546,8 +546,8 @@ protected void doTestPartialDerivatives(final double epsilonY, RungeKuttaFieldIntegrator integrator = createIntegrator(omega.getField(), t.subtract(t0).multiply(0.001)); FieldODEStateAndDerivative result = - integrator.integrate(new FieldExpandableODE(sinCos), - new FieldODEState(t0, y0), + integrator.integrate(new FieldExpandableODE<>(sinCos), + new FieldODEState<>(t0, y0), t); // check values diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldStepInterpolatorAbstractTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldStepInterpolatorAbstractTest.java index 0205a8dab2..ca77ac3978 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldStepInterpolatorAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldStepInterpolatorAbstractTest.java @@ -52,7 +52,7 @@ public abstract class RungeKuttaFieldStepInterpolatorAbstractTest { protected > void doInterpolationAtBounds(final Field field, double epsilon) { RungeKuttaFieldStepInterpolator interpolator = setUpInterpolator(field, - new SinCos(field), + new SinCos<>(field), 0.0, new double[] { 0.0, 1.0 }, 0.125); Assert.assertEquals(0.0, interpolator.getPreviousState().getTime().getReal(), 1.0e-15); @@ -77,7 +77,7 @@ protected > void doInterpolationInside(final Field double epsilonSin, double epsilonCos) { RungeKuttaFieldStepInterpolator interpolator = setUpInterpolator(field, - new SinCos(field), + new SinCos<>(field), 0.0, new double[] { 0.0, 1.0 }, 0.0125); int n = 100; @@ -103,7 +103,7 @@ protected > void doNonFieldInterpolatorConsistency double epsilonSin, double epsilonCos, double epsilonSinDot, double epsilonCosDot) { - FirstOrderFieldDifferentialEquations eqn = new SinCos(field); + FirstOrderFieldDifferentialEquations eqn = new SinCos<>(field); RungeKuttaFieldStepInterpolator fieldInterpolator = setUpInterpolator(field, eqn, 0.0, new double[] { 0.0, 1.0 }, 0.125); RungeKuttaStepInterpolator regularInterpolator = convertInterpolator(fieldInterpolator, eqn); @@ -160,7 +160,7 @@ RungeKuttaFieldStepInterpolator setUpInterpolator(final Field field, fieldY[i] = field.getZero().add(y0[i]); } fieldYDotK[0] = eqn.computeDerivatives(t, fieldY); - FieldODEStateAndDerivative s0 = new FieldODEStateAndDerivative(t, fieldY, fieldYDotK[0]); + FieldODEStateAndDerivative s0 = new FieldODEStateAndDerivative<>(t, fieldY, fieldYDotK[0]); // perform one integration step, in order to get consistent derivatives T h = field.getZero().add(t1 - t0); @@ -182,11 +182,11 @@ RungeKuttaFieldStepInterpolator setUpInterpolator(final Field field, fieldY[i] = fieldY[i].add(h.multiply(b[s].multiply(fieldYDotK[s][i]))); } } - FieldODEStateAndDerivative s1 = new FieldODEStateAndDerivative(t, fieldY, + FieldODEStateAndDerivative s1 = new FieldODEStateAndDerivative<>(t, fieldY, eqn.computeDerivatives(t, fieldY)); return createInterpolator(field, t1 > t0, fieldYDotK, s0, s1, s0, s1, - new FieldExpandableODE(eqn).getMapper()); + new FieldExpandableODE<>(eqn).getMapper()); } diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegratorTest.java index fd481ba6e4..1739a28136 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegratorTest.java @@ -26,7 +26,7 @@ public class ThreeEighthesFieldIntegratorTest extends RungeKuttaFieldIntegratorA protected > RungeKuttaFieldIntegrator createIntegrator(Field field, T step) { - return new ThreeEighthesFieldIntegrator(field, step); + return new ThreeEighthesFieldIntegrator<>(field, step); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolatorTest.java index 86ed2f9f85..601a32fb1a 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class ThreeEighthesFieldStepInterpolatorTest extends RungeKuttaFieldStepI FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new ThreeEighthesFieldStepInterpolator(field, forward, yDotK, + return new ThreeEighthesFieldStepInterpolator<>(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class ThreeEighthesFieldStepInterpolatorTest extends RungeKuttaFieldStepI protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new ThreeEighthesFieldIntegrator(field, field.getOne()); + return new ThreeEighthesFieldIntegrator<>(field, field.getOne()); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/sampling/DummyFieldStepInterpolator.java b/src/test/java/org/apache/commons/math4/ode/sampling/DummyFieldStepInterpolator.java index f5467459df..cda8f2c192 100644 --- a/src/test/java/org/apache/commons/math4/ode/sampling/DummyFieldStepInterpolator.java +++ b/src/test/java/org/apache/commons/math4/ode/sampling/DummyFieldStepInterpolator.java @@ -40,7 +40,7 @@ protected AbstractFieldStepInterpolator create(final boolean newForward, final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new DummyFieldStepInterpolator(newForward, + return new DummyFieldStepInterpolator<>(newForward, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); diff --git a/src/test/java/org/apache/commons/math4/ode/sampling/StepInterpolatorTestUtils.java b/src/test/java/org/apache/commons/math4/ode/sampling/StepInterpolatorTestUtils.java index 5c592d3df7..d3d5fcaff9 100644 --- a/src/test/java/org/apache/commons/math4/ode/sampling/StepInterpolatorTestUtils.java +++ b/src/test/java/org/apache/commons/math4/ode/sampling/StepInterpolatorTestUtils.java @@ -137,7 +137,7 @@ public void init(FieldODEStateAndDerivative state0, T t) { }); - integrator.integrate(new FieldExpandableODE(problem), problem.getInitialState(), problem.getFinalTime()); + integrator.integrate(new FieldExpandableODE<>(problem), problem.getInitialState(), problem.getFinalTime()); } } diff --git a/src/test/java/org/apache/commons/math4/ode/sampling/StepNormalizerOutputTestBase.java b/src/test/java/org/apache/commons/math4/ode/sampling/StepNormalizerOutputTestBase.java index 1955321978..6f6bfbec08 100644 --- a/src/test/java/org/apache/commons/math4/ode/sampling/StepNormalizerOutputTestBase.java +++ b/src/test/java/org/apache/commons/math4/ode/sampling/StepNormalizerOutputTestBase.java @@ -255,7 +255,7 @@ private void doTest(StepNormalizerMode mode, StepNormalizerBounds bounds, double[] y = {0.0}; double start = reverse ? getEnd() : getStart(); double end = reverse ? getStart() : getEnd(); - output = new ArrayList(); + output = new ArrayList<>(); integ.integrate(this, start, y, end, y); double[] actual = new double[output.size()]; for(int i = 0; i < actual.length; i++) { diff --git a/src/test/java/org/apache/commons/math4/optim/SimplePointCheckerTest.java b/src/test/java/org/apache/commons/math4/optim/SimplePointCheckerTest.java index e496e9e2ae..262bb6082d 100644 --- a/src/test/java/org/apache/commons/math4/optim/SimplePointCheckerTest.java +++ b/src/test/java/org/apache/commons/math4/optim/SimplePointCheckerTest.java @@ -32,7 +32,7 @@ public void testIterationCheckPrecondition() { public void testIterationCheck() { final int max = 10; final SimplePointChecker checker - = new SimplePointChecker(1e-1, 1e-2, max); + = new SimplePointChecker<>(1e-1, 1e-2, max); Assert.assertTrue(checker.converged(max, null, null)); Assert.assertTrue(checker.converged(max + 1, null, null)); } @@ -40,7 +40,7 @@ public void testIterationCheck() { @Test public void testIterationCheckDisabled() { final SimplePointChecker checker - = new SimplePointChecker(1e-8, 1e-8); + = new SimplePointChecker<>(1e-8, 1e-8); final PointValuePair a = new PointValuePair(new double[] { 1d }, 1d); final PointValuePair b = new PointValuePair(new double[] { 10d }, 10d); diff --git a/src/test/java/org/apache/commons/math4/optim/linear/SimplexSolverTest.java b/src/test/java/org/apache/commons/math4/optim/linear/SimplexSolverTest.java index 987ab6c697..503f782d30 100644 --- a/src/test/java/org/apache/commons/math4/optim/linear/SimplexSolverTest.java +++ b/src/test/java/org/apache/commons/math4/optim/linear/SimplexSolverTest.java @@ -54,7 +54,7 @@ public void testMath842Cycle() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 10, -57, -9, -24}, 0); - ArrayList constraints = new ArrayList(); + ArrayList constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] {0.5, -5.5, -2.5, 9}, Relationship.LEQ, 0)); constraints.add(new LinearConstraint(new double[] {0.5, -1.5, -0.5, 1}, Relationship.LEQ, 0)); @@ -75,7 +75,7 @@ public void testMath828() { LinearObjectiveFunction f = new LinearObjectiveFunction( new double[] { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, 0.0); - ArrayList constraints = new ArrayList(); + ArrayList constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] {0.0, 39.0, 23.0, 96.0, 15.0, 48.0, 9.0, 21.0, 48.0, 36.0, 76.0, 19.0, 88.0, 17.0, 16.0, 36.0,}, Relationship.GEQ, 15.0)); constraints.add(new LinearConstraint(new double[] {0.0, 59.0, 93.0, 12.0, 29.0, 78.0, 73.0, 87.0, 32.0, 70.0, 68.0, 24.0, 11.0, 26.0, 65.0, 25.0,}, Relationship.GEQ, 29.0)); @@ -97,7 +97,7 @@ public void testMath828Cycle() { LinearObjectiveFunction f = new LinearObjectiveFunction( new double[] { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, 0.0); - ArrayList constraints = new ArrayList(); + ArrayList constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] {0.0, 16.0, 14.0, 69.0, 1.0, 85.0, 52.0, 43.0, 64.0, 97.0, 14.0, 74.0, 89.0, 28.0, 94.0, 58.0, 13.0, 22.0, 21.0, 17.0, 30.0, 25.0, 1.0, 59.0, 91.0, 78.0, 12.0, 74.0, 56.0, 3.0, 88.0,}, Relationship.GEQ, 91.0)); constraints.add(new LinearConstraint(new double[] {0.0, 60.0, 40.0, 81.0, 71.0, 72.0, 46.0, 45.0, 38.0, 48.0, 40.0, 17.0, 33.0, 85.0, 64.0, 32.0, 84.0, 3.0, 54.0, 44.0, 71.0, 67.0, 90.0, 95.0, 54.0, 99.0, 99.0, 29.0, 52.0, 98.0, 9.0,}, Relationship.GEQ, 54.0)); @@ -120,7 +120,7 @@ GoalType.MINIMIZE, new NonNegativeConstraint(true), public void testMath781() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 2, 6, 7 }, 0); - ArrayList constraints = new ArrayList(); + ArrayList constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 1, 2, 1 }, Relationship.LEQ, 2)); constraints.add(new LinearConstraint(new double[] { -1, 1, 1 }, Relationship.LEQ, -1)); constraints.add(new LinearConstraint(new double[] { 2, -3, 1 }, Relationship.LEQ, -1)); @@ -139,7 +139,7 @@ public void testMath781() { @Test public void testMath713NegativeVariable() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {1.0, 1.0}, 0.0d); - ArrayList constraints = new ArrayList(); + ArrayList constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] {1, 0}, Relationship.EQ, 1)); double epsilon = 1e-6; @@ -154,7 +154,7 @@ public void testMath713NegativeVariable() { @Test public void testMath434NegativeVariable() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {0.0, 0.0, 1.0}, 0.0d); - ArrayList constraints = new ArrayList(); + ArrayList constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] {1, 1, 0}, Relationship.EQ, 5)); constraints.add(new LinearConstraint(new double[] {0, 0, 1}, Relationship.GEQ, -10)); @@ -174,7 +174,7 @@ public void testMath434UnfeasibleSolution() { double epsilon = 1e-6; LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {1.0, 0.0}, 0.0); - ArrayList constraints = new ArrayList(); + ArrayList constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] {epsilon/2, 0.5}, Relationship.EQ, 0)); constraints.add(new LinearConstraint(new double[] {1e-3, 0.1}, Relationship.EQ, 10)); @@ -189,7 +189,7 @@ public void testMath434PivotRowSelection() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {1.0}, 0.0); double epsilon = 1e-6; - ArrayList constraints = new ArrayList(); + ArrayList constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] {200}, Relationship.GEQ, 1)); constraints.add(new LinearConstraint(new double[] {100}, Relationship.GEQ, 0.499900001)); @@ -205,7 +205,7 @@ public void testMath434PivotRowSelection() { public void testMath434PivotRowSelection2() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {0.0d, 1.0d, 1.0d, 0.0d, 0.0d, 0.0d, 0.0d}, 0.0d); - ArrayList constraints = new ArrayList(); + ArrayList constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] {1.0d, -0.1d, 0.0d, 0.0d, 0.0d, 0.0d, 0.0d}, Relationship.EQ, -0.1d)); constraints.add(new LinearConstraint(new double[] {1.0d, 0.0d, 0.0d, 0.0d, 0.0d, 0.0d, 0.0d}, Relationship.GEQ, -1e-18d)); constraints.add(new LinearConstraint(new double[] {0.0d, 1.0d, 0.0d, 0.0d, 0.0d, 0.0d, 0.0d}, Relationship.GEQ, 0.0d)); @@ -230,7 +230,7 @@ public void testMath434PivotRowSelection2() { @Test public void testMath272() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 2, 2, 1 }, 0); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 1, 1, 0 }, Relationship.GEQ, 1)); constraints.add(new LinearConstraint(new double[] { 1, 0, 1 }, Relationship.GEQ, 1)); constraints.add(new LinearConstraint(new double[] { 0, 1, 0 }, Relationship.GEQ, 1)); @@ -248,7 +248,7 @@ public void testMath272() { @Test public void testMath286() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 0.8, 0.2, 0.7, 0.3, 0.6, 0.4 }, 0 ); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 1, 0, 1, 0, 1, 0 }, Relationship.EQ, 23.0)); constraints.add(new LinearConstraint(new double[] { 0, 1, 0, 1, 0, 1 }, Relationship.EQ, 23.0)); constraints.add(new LinearConstraint(new double[] { 1, 0, 0, 0, 0, 0 }, Relationship.GEQ, 10.0)); @@ -270,7 +270,7 @@ public void testMath286() { @Test public void testDegeneracy() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 0.8, 0.7 }, 0 ); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 1, 1 }, Relationship.LEQ, 18.0)); constraints.add(new LinearConstraint(new double[] { 1, 0 }, Relationship.GEQ, 10.0)); constraints.add(new LinearConstraint(new double[] { 0, 1 }, Relationship.GEQ, 8.0)); @@ -284,7 +284,7 @@ public void testDegeneracy() { @Test public void testMath288() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 7, 3, 0, 0 }, 0 ); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 3, 0, -5, 0 }, Relationship.LEQ, 0.0)); constraints.add(new LinearConstraint(new double[] { 2, 0, 0, -5 }, Relationship.LEQ, 0.0)); constraints.add(new LinearConstraint(new double[] { 0, 3, 0, -5 }, Relationship.LEQ, 0.0)); @@ -300,7 +300,7 @@ public void testMath288() { @Test public void testMath290GEQ() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 1, 5 }, 0 ); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 2, 0 }, Relationship.GEQ, -1.0)); SimplexSolver solver = new SimplexSolver(); PointValuePair solution = solver.optimize(DEFAULT_MAX_ITER, f, new LinearConstraintSet(constraints), @@ -313,7 +313,7 @@ public void testMath290GEQ() { @Test(expected=NoFeasibleSolutionException.class) public void testMath290LEQ() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 1, 5 }, 0 ); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 2, 0 }, Relationship.LEQ, -1.0)); SimplexSolver solver = new SimplexSolver(); solver.optimize(DEFAULT_MAX_ITER, f, new LinearConstraintSet(constraints), @@ -323,7 +323,7 @@ public void testMath290LEQ() { @Test public void testMath293() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 0.8, 0.2, 0.7, 0.3, 0.4, 0.6}, 0 ); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 1, 0, 1, 0, 1, 0 }, Relationship.EQ, 30.0)); constraints.add(new LinearConstraint(new double[] { 0, 1, 0, 1, 0, 1 }, Relationship.EQ, 30.0)); constraints.add(new LinearConstraint(new double[] { 0.8, 0.2, 0.0, 0.0, 0.0, 0.0 }, Relationship.GEQ, 10.0)); @@ -347,7 +347,7 @@ public void testMath293() { double valC = 0.4 * solution1.getPoint()[4] + 0.6 * solution1.getPoint()[5]; f = new LinearObjectiveFunction(new double[] { 0.8, 0.2, 0.7, 0.3, 0.4, 0.6}, 0 ); - constraints = new ArrayList(); + constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 1, 0, 1, 0, 1, 0 }, Relationship.EQ, 30.0)); constraints.add(new LinearConstraint(new double[] { 0, 1, 0, 1, 0, 1 }, Relationship.EQ, 30.0)); constraints.add(new LinearConstraint(new double[] { 0.8, 0.2, 0.0, 0.0, 0.0, 0.0 }, Relationship.GEQ, valA)); @@ -374,7 +374,7 @@ public void testMath930() { } private List createMath930Constraints() { - List constraints = new ArrayList(); + List constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] {1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 0}, Relationship.GEQ, 0.0)); constraints.add(new LinearConstraint(new double[] {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1}, Relationship.GEQ, 0.0)); constraints.add(new LinearConstraint(new double[] {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1}, Relationship.LEQ, 0.0)); @@ -479,7 +479,7 @@ private List createMath930Constraints() { public void testSimplexSolver() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 15, 10 }, 7); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 1, 0 }, Relationship.LEQ, 2)); constraints.add(new LinearConstraint(new double[] { 0, 1 }, Relationship.LEQ, 3)); constraints.add(new LinearConstraint(new double[] { 1, 1 }, Relationship.EQ, 4)); @@ -495,7 +495,7 @@ public void testSimplexSolver() { @Test public void testSingleVariableAndConstraint() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 3 }, 0); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 1 }, Relationship.LEQ, 10)); SimplexSolver solver = new SimplexSolver(); @@ -512,7 +512,7 @@ public void testSingleVariableAndConstraint() { @Test public void testModelWithNoArtificialVars() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 15, 10 }, 0); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 1, 0 }, Relationship.LEQ, 2)); constraints.add(new LinearConstraint(new double[] { 0, 1 }, Relationship.LEQ, 3)); constraints.add(new LinearConstraint(new double[] { 1, 1 }, Relationship.LEQ, 4)); @@ -528,7 +528,7 @@ public void testModelWithNoArtificialVars() { @Test public void testMinimization() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { -2, 1 }, -5); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 1, 2 }, Relationship.LEQ, 6)); constraints.add(new LinearConstraint(new double[] { 3, 2 }, Relationship.LEQ, 12)); constraints.add(new LinearConstraint(new double[] { 0, 1 }, Relationship.GEQ, 0)); @@ -544,7 +544,7 @@ public void testMinimization() { @Test public void testSolutionWithNegativeDecisionVariable() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { -2, 1 }, 0); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 1, 1 }, Relationship.GEQ, 6)); constraints.add(new LinearConstraint(new double[] { 1, 2 }, Relationship.LEQ, 14)); @@ -559,7 +559,7 @@ public void testSolutionWithNegativeDecisionVariable() { @Test(expected = NoFeasibleSolutionException.class) public void testInfeasibleSolution() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 15 }, 0); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 1 }, Relationship.LEQ, 1)); constraints.add(new LinearConstraint(new double[] { 1 }, Relationship.GEQ, 3)); @@ -571,7 +571,7 @@ public void testInfeasibleSolution() { @Test(expected = UnboundedSolutionException.class) public void testUnboundedSolution() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 15, 10 }, 0); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 1, 0 }, Relationship.EQ, 2)); SimplexSolver solver = new SimplexSolver(); @@ -582,7 +582,7 @@ public void testUnboundedSolution() { @Test public void testRestrictVariablesToNonNegative() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 409, 523, 70, 204, 339 }, 0); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 43, 56, 345, 56, 5 }, Relationship.LEQ, 4567456)); constraints.add(new LinearConstraint(new double[] { 12, 45, 7, 56, 23 }, Relationship.LEQ, 56454)); constraints.add(new LinearConstraint(new double[] { 8, 768, 0, 34, 7456 }, Relationship.LEQ, 1923421)); @@ -604,7 +604,7 @@ public void testRestrictVariablesToNonNegative() { public void testEpsilon() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 10, 5, 1 }, 0); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 9, 8, 0 }, Relationship.EQ, 17)); constraints.add(new LinearConstraint(new double[] { 0, 7, 8 }, Relationship.LEQ, 7)); constraints.add(new LinearConstraint(new double[] { 10, 0, 2 }, Relationship.LEQ, 10)); @@ -621,7 +621,7 @@ public void testEpsilon() { @Test public void testTrivialModel() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 1, 1 }, 0); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 1, 1 }, Relationship.EQ, 0)); SimplexSolver solver = new SimplexSolver(); @@ -657,7 +657,7 @@ public void testLargeModel() { 1, 1, 1, 1, 1, 1}; LinearObjectiveFunction f = new LinearObjectiveFunction(objective, 0); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(equationFromString(objective.length, "x0 + x1 + x2 + x3 - x12 = 0")); constraints.add(equationFromString(objective.length, "x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 - x13 = 0")); constraints.add(equationFromString(objective.length, "x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 >= 49")); @@ -765,7 +765,7 @@ public void testSolutionCallback() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 7, 3, 0, 0 }, 0 ); - List constraints = new ArrayList(); + List constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] { 3, 0, -5, 0 }, Relationship.LEQ, 0.0)); constraints.add(new LinearConstraint(new double[] { 2, 0, 0, -5 }, Relationship.LEQ, 0.0)); constraints.add(new LinearConstraint(new double[] { 0, 3, 0, -5 }, Relationship.LEQ, 0.0)); @@ -805,7 +805,7 @@ public void testDimensionMatch() { // x1,x2,x3 >= 0 LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 2, 15, 18 }, 0); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); // this constraint is wrong, the dimension is less than expected one constraints.add(new LinearConstraint(new double[] { -1, 2 - 6 }, Relationship.LEQ, -10)); constraints.add(new LinearConstraint(new double[] { 0, 1, 2 }, Relationship.LEQ, 6)); diff --git a/src/test/java/org/apache/commons/math4/optim/linear/SimplexTableauTest.java b/src/test/java/org/apache/commons/math4/optim/linear/SimplexTableauTest.java index e0c99da4cf..be774c4ccc 100644 --- a/src/test/java/org/apache/commons/math4/optim/linear/SimplexTableauTest.java +++ b/src/test/java/org/apache/commons/math4/optim/linear/SimplexTableauTest.java @@ -65,7 +65,7 @@ public void testDropPhase1Objective() { @Test public void testTableauWithNoArtificialVars() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {15, 10}, 0); - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] {1, 0}, Relationship.LEQ, 2)); constraints.add(new LinearConstraint(new double[] {0, 1}, Relationship.LEQ, 3)); constraints.add(new LinearConstraint(new double[] {1, 1}, Relationship.LEQ, 4)); @@ -94,7 +94,7 @@ private LinearObjectiveFunction createFunction() { } private Collection createConstraints() { - Collection constraints = new ArrayList(); + Collection constraints = new ArrayList<>(); constraints.add(new LinearConstraint(new double[] {1, 0}, Relationship.LEQ, 2)); constraints.add(new LinearConstraint(new double[] {0, 1}, Relationship.LEQ, 3)); constraints.add(new LinearConstraint(new double[] {1, 1}, Relationship.EQ, 4)); diff --git a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/CircleScalar.java b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/CircleScalar.java index 4c2acaa323..0c802543a0 100644 --- a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/CircleScalar.java +++ b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/CircleScalar.java @@ -32,7 +32,7 @@ public class CircleScalar { private ArrayList points; public CircleScalar() { - points = new ArrayList(); + points = new ArrayList<>(); } public void addPoint(double px, double py) { diff --git a/src/test/java/org/apache/commons/math4/primes/PrimesTest.java b/src/test/java/org/apache/commons/math4/primes/PrimesTest.java index 26bcd37f9a..831a86ee61 100644 --- a/src/test/java/org/apache/commons/math4/primes/PrimesTest.java +++ b/src/test/java/org/apache/commons/math4/primes/PrimesTest.java @@ -140,7 +140,7 @@ static int product(List numbers) { } return out; } - static final HashSet PRIMES_SET = new HashSet(); + static final HashSet PRIMES_SET = new HashSet<>(); static { for (int p : PRIMES) { PRIMES_SET.add(p); diff --git a/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java b/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java index 4854979c01..d4d5bc2157 100644 --- a/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java +++ b/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java @@ -62,7 +62,7 @@ public void setUp() { super.setUp(); empiricalDistribution = new EmpiricalDistribution(100); url = getClass().getResource("testData.txt"); - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); try { empiricalDistribution2 = new EmpiricalDistribution(100); BufferedReader in = diff --git a/src/test/java/org/apache/commons/math4/random/RandomDataGeneratorTest.java b/src/test/java/org/apache/commons/math4/random/RandomDataGeneratorTest.java index 2982efb35e..d7d7bb59d9 100644 --- a/src/test/java/org/apache/commons/math4/random/RandomDataGeneratorTest.java +++ b/src/test/java/org/apache/commons/math4/random/RandomDataGeneratorTest.java @@ -483,7 +483,7 @@ public void checkNextPoissonConsistency(double mean) { * [binBounds[binCount - 2], upper = binBounds[binCount - 1]), [upper, +inf) * */ - List binBounds = new ArrayList(); + List binBounds = new ArrayList<>(); binBounds.add(lower); int bound = lower + binWidth; while (bound < upper - binWidth) { @@ -872,14 +872,14 @@ public void testNextSample() { long[] observed = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; double[] expected = { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 }; - HashSet cPop = new HashSet(); // {0,1,2,3,4} + HashSet cPop = new HashSet<>(); // {0,1,2,3,4} for (int i = 0; i < 5; i++) { cPop.add(Integer.toString(i)); } Object[] sets = new Object[10]; // 2-sets from 5 for (int i = 0; i < 10; i++) { - HashSet hs = new HashSet(); + HashSet hs = new HashSet<>(); hs.add(c[i][0]); hs.add(c[i][1]); sets[i] = hs; @@ -898,7 +898,7 @@ public void testNextSample() { testStatistic.chiSquare(expected, observed) < 27.88); // Make sure sample of size = size of collection returns same collection - HashSet hs = new HashSet(); + HashSet hs = new HashSet<>(); hs.add("one"); Object[] one = randomData.nextSample(hs, 1); String oneString = (String) one[0]; @@ -916,7 +916,7 @@ public void testNextSample() { // Make sure we fail for empty collection try { - hs = new HashSet(); + hs = new HashSet<>(); one = randomData.nextSample(hs, 0); Assert.fail("n = k = 0, expecting MathIllegalArgumentException"); } catch (MathIllegalArgumentException ex) { @@ -928,7 +928,7 @@ public void testNextSample() { private int findSample(Object[] u, Object[] samp) { for (int i = 0; i < u.length; i++) { HashSet set = (HashSet) u[i]; - HashSet sampSet = new HashSet(); + HashSet sampSet = new HashSet<>(); for (int j = 0; j < samp.length; j++) { sampSet.add(samp[j]); } diff --git a/src/test/java/org/apache/commons/math4/random/SynchronizedRandomGeneratorTest.java b/src/test/java/org/apache/commons/math4/random/SynchronizedRandomGeneratorTest.java index b66a1272b6..f4ec2cdf72 100644 --- a/src/test/java/org/apache/commons/math4/random/SynchronizedRandomGeneratorTest.java +++ b/src/test/java/org/apache/commons/math4/random/SynchronizedRandomGeneratorTest.java @@ -95,7 +95,7 @@ private double[] doTestMath899(final boolean sync, final RandomGenerator rng = new MersenneTwister(); final RandomGenerator wrapper = sync ? new SynchronizedRandomGenerator(rng) : rng; - final List> tasks = new ArrayList>(); + final List> tasks = new ArrayList<>(); for (int i = 0; i < numGenerators; i++) { tasks.add(new Callable() { @Override diff --git a/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java b/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java index 444c57ae94..7263a1e540 100644 --- a/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java +++ b/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java @@ -367,7 +367,7 @@ public void testMergeCollection() { Frequency h = new Frequency(); h.addValue(THREE_LONG); - List coll = new ArrayList(); + List coll = new ArrayList<>(); coll.add(g); coll.add(h); f.merge(coll); diff --git a/src/test/java/org/apache/commons/math4/stat/data/CertifiedDataAbstractTest.java b/src/test/java/org/apache/commons/math4/stat/data/CertifiedDataAbstractTest.java index 32cfbdd02c..74262b9234 100644 --- a/src/test/java/org/apache/commons/math4/stat/data/CertifiedDataAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/stat/data/CertifiedDataAbstractTest.java @@ -48,7 +48,7 @@ public abstract class CertifiedDataAbstractTest { public void setUp() throws IOException { descriptives = new DescriptiveStatistics(); summaries = new SummaryStatistics(); - certifiedValues = new HashMap(); + certifiedValues = new HashMap<>(); loadData(); } diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatisticsTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatisticsTest.java index 5324ecf4f5..94c980d2be 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatisticsTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatisticsTest.java @@ -147,7 +147,7 @@ public void testAggregate() { for (int i = 0; i < nSamples; i++) { subSampleStats[i] = new SummaryStatistics(); } - Collection aggregate = new ArrayList(); + Collection aggregate = new ArrayList<>(); for (int i = 0; i < nSamples; i++) { for (int j = 0; j < subSamples[i].length; j++) { subSampleStats[i].addValue(subSamples[i][j]); @@ -183,7 +183,7 @@ public void testAggregateStatisticalSummary() { for (int i = 0; i < nSamples; i++) { subSampleStats[i] = new SummaryStatistics(); } - Collection aggregate = new ArrayList(); + Collection aggregate = new ArrayList<>(); for (int i = 0; i < nSamples; i++) { for (int j = 0; j < subSamples[i].length; j++) { subSampleStats[i].addValue(subSamples[i][j]); @@ -213,7 +213,7 @@ public void testAggregateDegenerate() { for (int i = 0; i < 5; i++) { subSampleStats[i] = new SummaryStatistics(); } - Collection aggregate = new ArrayList(); + Collection aggregate = new ArrayList<>(); for (int i = 0; i < 5; i++) { for (int j = 0; j < subSamples[i].length; j++) { subSampleStats[i].addValue(subSamples[i][j]); @@ -242,7 +242,7 @@ public void testAggregateSpecialValues() { for (int i = 0; i < 4; i++) { subSampleStats[i] = new SummaryStatistics(); } - Collection aggregate = new ArrayList(); + Collection aggregate = new ArrayList<>(); for (int i = 0; i < 4; i++) { for (int j = 0; j < subSamples[i].length; j++) { subSampleStats[i].addValue(subSamples[i][j]); diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImpl.java b/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImpl.java index 7bdd8009bb..19b9b9f927 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImpl.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImpl.java @@ -47,7 +47,7 @@ public class ListUnivariateImpl extends DescriptiveStatistics implements Seriali * No argument Constructor */ public ListUnivariateImpl(){ - this(new ArrayList()); + this(new ArrayList<>()); } /** diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImplTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImplTest.java index 964d06618c..2e22fc38ea 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImplTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImplTest.java @@ -49,7 +49,7 @@ public final class ListUnivariateImplTest { /** test stats */ @Test public void testStats() { - List externalList = new ArrayList(); + List externalList = new ArrayList<>(); DescriptiveStatistics u = new ListUnivariateImpl( externalList ); @@ -72,7 +72,7 @@ public void testStats() { @Test public void testN0andN1Conditions() { - List list = new ArrayList(); + List list = new ArrayList<>(); DescriptiveStatistics u = new ListUnivariateImpl( list ); @@ -105,7 +105,7 @@ public void testSkewAndKurtosis() { @Test public void testProductAndGeometricMean() { - ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList()); + ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList<>()); u.setWindowSize(10); u.addValue( 1.0 ); diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/MixedListUnivariateImplTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/MixedListUnivariateImplTest.java index 410a2e1b80..7d3ab049ec 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/MixedListUnivariateImplTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/MixedListUnivariateImplTest.java @@ -59,7 +59,7 @@ public MixedListUnivariateImplTest() { /** test stats */ @Test public void testStats() { - List externalList = new ArrayList(); + List externalList = new ArrayList<>(); DescriptiveStatistics u = new ListUnivariateImpl(externalList,transformers); @@ -82,7 +82,7 @@ public void testStats() { @Test public void testN0andN1Conditions() { - DescriptiveStatistics u = new ListUnivariateImpl(new ArrayList(),transformers); + DescriptiveStatistics u = new ListUnivariateImpl(new ArrayList<>(),transformers); Assert.assertTrue( "Mean of n = 0 set should be NaN", @@ -112,7 +112,7 @@ public void testN0andN1Conditions() { @Test public void testSkewAndKurtosis() { ListUnivariateImpl u = - new ListUnivariateImpl(new ArrayList(), transformers); + new ListUnivariateImpl(new ArrayList<>(), transformers); u.addObject("12.5"); u.addObject(Integer.valueOf(12)); @@ -146,7 +146,7 @@ public void testSkewAndKurtosis() { @Test public void testProductAndGeometricMean() { - ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList(),transformers); + ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList<>(),transformers); u.setWindowSize(10); u.addValue(1.0); diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java index 6f12b1e185..c3542b2911 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java @@ -188,7 +188,7 @@ public void testWeightedConsistency() { // and fill valuesList with values from values array with // values[i] repeated weights[i] times, each i final RealDistribution valueDist = new NormalDistribution(mu, sigma); - List valuesList = new ArrayList(); + List valuesList = new ArrayList<>(); for (int i = 0; i < len; i++) { double value = valueDist.sample(); values[i] = value; diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentileTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentileTest.java index dfdcd4ece9..bab2ec7083 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentileTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentileTest.java @@ -209,7 +209,7 @@ public void testMarkers2() { public void testHashCodeInMarkers() { PSquarePercentile p = new PSquarePercentile(95); PSquarePercentile p2 = new PSquarePercentile(95); - Set s = new HashSet(); + Set s = new HashSet<>(); s.add(p); s.add(p2); Assert.assertEquals(1, s.size()); @@ -237,7 +237,7 @@ public void testHashCodeInMarkers() { 95.1959, 95.1442, 95.0610, 95.1591, 95.1195, 95.1772, 95.0925, 95.1990, 95.1682 }), 0.0); Assert.assertTrue(m1.equals(m2)); - Set setMarkers = new LinkedHashSet(); + Set setMarkers = new LinkedHashSet<>(); Assert.assertTrue(setMarkers.add(m1)); Assert.assertFalse(setMarkers.add(m2)); Assert.assertEquals(1, setMarkers.size()); diff --git a/src/test/java/org/apache/commons/math4/stat/inference/OneWayAnovaTest.java b/src/test/java/org/apache/commons/math4/stat/inference/OneWayAnovaTest.java index 3442382c35..cf35f3067a 100644 --- a/src/test/java/org/apache/commons/math4/stat/inference/OneWayAnovaTest.java +++ b/src/test/java/org/apache/commons/math4/stat/inference/OneWayAnovaTest.java @@ -47,7 +47,7 @@ public class OneWayAnovaTest { @Test public void testAnovaFValue() { // Target comparison values computed using R version 2.6.0 (Linux version) - List threeClasses = new ArrayList(); + List threeClasses = new ArrayList<>(); threeClasses.add(classA); threeClasses.add(classB); threeClasses.add(classC); @@ -55,14 +55,14 @@ public void testAnovaFValue() { Assert.assertEquals("ANOVA F-value", 24.67361709460624, testStatistic.anovaFValue(threeClasses), 1E-12); - List twoClasses = new ArrayList(); + List twoClasses = new ArrayList<>(); twoClasses.add(classA); twoClasses.add(classB); Assert.assertEquals("ANOVA F-value", 0.0150579150579, testStatistic.anovaFValue(twoClasses), 1E-12); - List emptyContents = new ArrayList(); + List emptyContents = new ArrayList<>(); emptyContents.add(emptyArray); emptyContents.add(classC); try { @@ -72,7 +72,7 @@ public void testAnovaFValue() { // expected } - List tooFew = new ArrayList(); + List tooFew = new ArrayList<>(); tooFew.add(classA); try { testStatistic.anovaFValue(tooFew); @@ -86,7 +86,7 @@ public void testAnovaFValue() { @Test public void testAnovaPValue() { // Target comparison values computed using R version 2.6.0 (Linux version) - List threeClasses = new ArrayList(); + List threeClasses = new ArrayList<>(); threeClasses.add(classA); threeClasses.add(classB); threeClasses.add(classC); @@ -94,7 +94,7 @@ public void testAnovaPValue() { Assert.assertEquals("ANOVA P-value", 6.959446E-06, testStatistic.anovaPValue(threeClasses), 1E-12); - List twoClasses = new ArrayList(); + List twoClasses = new ArrayList<>(); twoClasses.add(classA); twoClasses.add(classB); @@ -106,7 +106,7 @@ public void testAnovaPValue() { @Test public void testAnovaPValueSummaryStatistics() { // Target comparison values computed using R version 2.6.0 (Linux version) - List threeClasses = new ArrayList(); + List threeClasses = new ArrayList<>(); SummaryStatistics statsA = new SummaryStatistics(); for (double a : classA) { statsA.addValue(a); @@ -126,7 +126,7 @@ public void testAnovaPValueSummaryStatistics() { Assert.assertEquals("ANOVA P-value", 6.959446E-06, testStatistic.anovaPValue(threeClasses, true), 1E-12); - List twoClasses = new ArrayList(); + List twoClasses = new ArrayList<>(); twoClasses.add(statsA); twoClasses.add(statsB); @@ -138,14 +138,14 @@ public void testAnovaPValueSummaryStatistics() { @Test public void testAnovaTest() { // Target comparison values computed using R version 2.3.1 (Linux version) - List threeClasses = new ArrayList(); + List threeClasses = new ArrayList<>(); threeClasses.add(classA); threeClasses.add(classB); threeClasses.add(classC); Assert.assertTrue("ANOVA Test P<0.01", testStatistic.anovaTest(threeClasses, 0.01)); - List twoClasses = new ArrayList(); + List twoClasses = new ArrayList<>(); twoClasses.add(classA); twoClasses.add(classB); diff --git a/src/test/java/org/apache/commons/math4/stat/inference/TestUtilsTest.java b/src/test/java/org/apache/commons/math4/stat/inference/TestUtilsTest.java index b22131e2dc..59914e050a 100644 --- a/src/test/java/org/apache/commons/math4/stat/inference/TestUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/stat/inference/TestUtilsTest.java @@ -457,7 +457,7 @@ public void testPaired() { private double[] classC = {110.0, 115.0, 111.0, 117.0, 128.0}; - private List classes = new ArrayList(); + private List classes = new ArrayList<>(); private OneWayAnova oneWayAnova = new OneWayAnova(); @Test diff --git a/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java b/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java index fece225154..1dd31cecc4 100644 --- a/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java @@ -125,7 +125,7 @@ public void testGcd() { @Test public void testGcdConsistency() { int[] primeList = {19, 23, 53, 67, 73, 79, 101, 103, 111, 131}; - ArrayList primes = new ArrayList(); + ArrayList primes = new ArrayList<>(); for (int i = 0; i < primeList.length; i++) { primes.add(Integer.valueOf(primeList[i])); } diff --git a/src/test/java/org/apache/commons/math4/util/CombinatoricsUtilsTest.java b/src/test/java/org/apache/commons/math4/util/CombinatoricsUtilsTest.java index 0ad8a02e59..faaf786669 100644 --- a/src/test/java/org/apache/commons/math4/util/CombinatoricsUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/util/CombinatoricsUtilsTest.java @@ -38,7 +38,7 @@ public class CombinatoricsUtilsTest { /** cached binomial coefficients */ - private static final List> binomialCache = new ArrayList>(); + private static final List> binomialCache = new ArrayList<>(); /** Verify that b(0,0) = 1 */ @Test diff --git a/src/test/java/org/apache/commons/math4/util/FastMathStrictComparisonTest.java b/src/test/java/org/apache/commons/math4/util/FastMathStrictComparisonTest.java index 77a0c7cb16..d38d42e5b5 100644 --- a/src/test/java/org/apache/commons/math4/util/FastMathStrictComparisonTest.java +++ b/src/test/java/org/apache/commons/math4/util/FastMathStrictComparisonTest.java @@ -212,7 +212,7 @@ private static void setupMethodCall(Method mathMethod, Method fastMethod, @Parameters public static List data() throws Exception { String singleMethod = System.getProperty("testMethod"); - List list = new ArrayList(); + List list = new ArrayList<>(); for(Method mathMethod : StrictMath.class.getDeclaredMethods()) { method: if (Modifier.isPublic(mathMethod.getModifiers())){// Only test public methods diff --git a/src/test/java/org/apache/commons/math4/util/IntegerSequenceTest.java b/src/test/java/org/apache/commons/math4/util/IntegerSequenceTest.java index 25eec4f153..4b29906a16 100644 --- a/src/test/java/org/apache/commons/math4/util/IntegerSequenceTest.java +++ b/src/test/java/org/apache/commons/math4/util/IntegerSequenceTest.java @@ -33,7 +33,7 @@ public void testRangeMultipleIterations() { final int max = 7; final int step = 2; - final List seq = new ArrayList(); + final List seq = new ArrayList<>(); final IntegerSequence.Range r = IntegerSequence.range(start, max, step); final int numTimes = 3; @@ -53,7 +53,7 @@ public void testIncreasingRange() { final int max = 7; final int step = 2; - final List seq = new ArrayList(); + final List seq = new ArrayList<>(); final IntegerSequence.Range r = IntegerSequence.range(start, max, step); for (Integer i : r) { seq.add(i); @@ -72,7 +72,7 @@ public void testIncreasingRangeNegativeEnd() { final int max = -1; final int step = 2; - final List seq = new ArrayList(); + final List seq = new ArrayList<>(); final IntegerSequence.Range r = IntegerSequence.range(start, max, step); for (Integer i : r) { seq.add(i); @@ -91,7 +91,7 @@ public void testDecreasingRange() { final int max = -8; final int step = -3; - final List seq = new ArrayList(); + final List seq = new ArrayList<>(); final IntegerSequence.Range r = IntegerSequence.range(start, max, step); for (Integer i : r) { seq.add(i); @@ -110,7 +110,7 @@ public void testSingleElementRange() { final int max = 1; final int step = -1; - final List seq = new ArrayList(); + final List seq = new ArrayList<>(); final IntegerSequence.Range r = IntegerSequence.range(start, max, step); for (Integer i : r) { seq.add(i); @@ -126,7 +126,7 @@ public void testBasicRange() { final int start = -2; final int end = 4; - final List seq = new ArrayList(); + final List seq = new ArrayList<>(); for (Integer i : IntegerSequence.range(start, end)) { seq.add(i); } @@ -141,7 +141,7 @@ public void testEmptyRange() { final int start = 2; final int end = 0; - final List seq = new ArrayList(); + final List seq = new ArrayList<>(); final IntegerSequence.Range r = IntegerSequence.range(start, end); for (Integer i : r) { seq.add(i); @@ -157,7 +157,7 @@ public void testEmptyRangeNegativeStart() { final int max = -1; final int step = -1; - final List seq = new ArrayList(); + final List seq = new ArrayList<>(); final IntegerSequence.Range r = IntegerSequence.range(start, max, step); for (Integer i : r) { seq.add(i); diff --git a/src/test/java/org/apache/commons/math4/util/OpenIntToDoubleHashMapTest.java b/src/test/java/org/apache/commons/math4/util/OpenIntToDoubleHashMapTest.java index 0841868cd4..eea8560255 100644 --- a/src/test/java/org/apache/commons/math4/util/OpenIntToDoubleHashMapTest.java +++ b/src/test/java/org/apache/commons/math4/util/OpenIntToDoubleHashMapTest.java @@ -37,7 +37,7 @@ @SuppressWarnings("boxing") public class OpenIntToDoubleHashMapTest { - private Map javaMap = new HashMap(); + private Map javaMap = new HashMap<>(); @Before public void setUp() throws Exception { @@ -60,7 +60,7 @@ public void setUp() throws Exception { } private Map generate() { - Map map = new HashMap(); + Map map = new HashMap<>(); Random r = new Random(); for (int i = 0; i < 2000; ++i) map.put(r.nextInt(), r.nextDouble()); @@ -168,7 +168,7 @@ public void testRemove2() { OpenIntToDoubleHashMap map = createFromJavaMap(); int mapSize = javaMap.size(); int count = 0; - Set keysInMap = new HashSet(javaMap.keySet()); + Set keysInMap = new HashSet<>(javaMap.keySet()); for (Map.Entry mapEntry : javaMap.entrySet()) { keysInMap.remove(mapEntry.getKey()); map.remove(mapEntry.getKey()); @@ -206,7 +206,7 @@ public void testRemoveAbsent() { * Returns a map with at least 100 elements where each element is absent from javaMap. */ private Map generateAbsent() { - Map generated = new HashMap(); + Map generated = new HashMap<>(); do { generated.putAll(generate()); for (Integer key : javaMap.keySet()) diff --git a/src/test/java/org/apache/commons/math4/util/OpenIntToFieldTest.java b/src/test/java/org/apache/commons/math4/util/OpenIntToFieldTest.java index 6df12dd465..d7de53c083 100644 --- a/src/test/java/org/apache/commons/math4/util/OpenIntToFieldTest.java +++ b/src/test/java/org/apache/commons/math4/util/OpenIntToFieldTest.java @@ -38,7 +38,7 @@ @SuppressWarnings("boxing") public class OpenIntToFieldTest { - private Map javaMap = new HashMap(); + private Map javaMap = new HashMap<>(); private FractionField field = FractionField.getInstance(); @Before @@ -62,7 +62,7 @@ public void setUp() throws FractionConversionException { } private Map generate() { - Map map = new HashMap(); + Map map = new HashMap<>(); Random r = new Random(); double dd=0; for (int i = 0; i < 2000; ++i) @@ -76,7 +76,7 @@ private Map generate() { } private OpenIntToFieldHashMap createFromJavaMap(Field field) { - OpenIntToFieldHashMap map = new OpenIntToFieldHashMap(field); + OpenIntToFieldHashMap map = new OpenIntToFieldHashMap<>(field); for (Map.Entry mapEntry : javaMap.entrySet()) { map.put(mapEntry.getKey(), mapEntry.getValue()); } @@ -85,19 +85,19 @@ private OpenIntToFieldHashMap createFromJavaMap(Field field) @Test public void testPutAndGetWith0ExpectedSize() { - OpenIntToFieldHashMap map = new OpenIntToFieldHashMap(field,0); + OpenIntToFieldHashMap map = new OpenIntToFieldHashMap<>(field,0); assertPutAndGet(map); } @Test public void testPutAndGetWithExpectedSize() { - OpenIntToFieldHashMap map = new OpenIntToFieldHashMap(field,500); + OpenIntToFieldHashMap map = new OpenIntToFieldHashMap<>(field,500); assertPutAndGet(map); } @Test public void testPutAndGet() { - OpenIntToFieldHashMap map = new OpenIntToFieldHashMap(field); + OpenIntToFieldHashMap map = new OpenIntToFieldHashMap<>(field); assertPutAndGet(map); } @@ -149,7 +149,7 @@ public void testGetAbsent() { @Test public void testGetFromEmpty() { - OpenIntToFieldHashMap map = new OpenIntToFieldHashMap(field); + OpenIntToFieldHashMap map = new OpenIntToFieldHashMap<>(field); Assert.assertTrue(field.getZero().equals(map.get(5))); Assert.assertTrue(field.getZero().equals(map.get(0))); Assert.assertTrue(field.getZero().equals(map.get(50))); @@ -176,7 +176,7 @@ public void testRemove2() { OpenIntToFieldHashMap map = createFromJavaMap(field); int mapSize = javaMap.size(); int count = 0; - Set keysInMap = new HashSet(javaMap.keySet()); + Set keysInMap = new HashSet<>(javaMap.keySet()); for (Map.Entry mapEntry : javaMap.entrySet()) { keysInMap.remove(mapEntry.getKey()); map.remove(mapEntry.getKey()); @@ -192,7 +192,7 @@ public void testRemove2() { @Test public void testRemoveFromEmpty() { - OpenIntToFieldHashMap map = new OpenIntToFieldHashMap(field); + OpenIntToFieldHashMap map = new OpenIntToFieldHashMap<>(field); Assert.assertTrue(field.getZero().equals(map.remove(50))); } @@ -214,7 +214,7 @@ public void testRemoveAbsent() { * Returns a map with at least 100 elements where each element is absent from javaMap. */ private Map generateAbsent() { - Map generated = new HashMap(); + Map generated = new HashMap<>(); do { generated.putAll(generate()); for (Integer key : javaMap.keySet()) @@ -226,7 +226,7 @@ private Map generateAbsent() { @Test public void testCopy() { OpenIntToFieldHashMap copy = - new OpenIntToFieldHashMap(createFromJavaMap(field)); + new OpenIntToFieldHashMap<>(createFromJavaMap(field)); Assert.assertEquals(javaMap.size(), copy.size()); for (Map.Entry mapEntry : javaMap.entrySet()) @@ -292,7 +292,7 @@ public void testConcurrentModification() { */ @Test public void testPutKeysWithCollisions() { - OpenIntToFieldHashMap map = new OpenIntToFieldHashMap(field); + OpenIntToFieldHashMap map = new OpenIntToFieldHashMap<>(field); int key1 = -1996012590; Fraction value1 = new Fraction(1); map.put(key1, value1); @@ -316,7 +316,7 @@ public void testPutKeysWithCollisions() { */ @Test public void testPutKeysWithCollision2() { - OpenIntToFieldHashMapmap = new OpenIntToFieldHashMap(field); + OpenIntToFieldHashMapmap = new OpenIntToFieldHashMap<>(field); int key1 = 837989881; Fraction value1 = new Fraction(1); map.put(key1, value1); diff --git a/src/test/java/org/apache/commons/math4/util/PairTest.java b/src/test/java/org/apache/commons/math4/util/PairTest.java index 904c93cbce..ba6798ef3c 100644 --- a/src/test/java/org/apache/commons/math4/util/PairTest.java +++ b/src/test/java/org/apache/commons/math4/util/PairTest.java @@ -25,7 +25,7 @@ public class PairTest { @Test public void testAccessor() { final Pair p - = new Pair(new Integer(1), new Double(2)); + = new Pair<>(new Integer(1), new Double(2)); Assert.assertEquals(new Integer(1), p.getKey()); Assert.assertEquals(2, p.getValue().doubleValue(), Math.ulp(1d)); } @@ -33,7 +33,7 @@ public void testAccessor() { @Test public void testAccessor2() { final Pair p - = new Pair(new Integer(1), new Double(2)); + = new Pair<>(new Integer(1), new Double(2)); // Check that both APIs refer to the same data. @@ -43,19 +43,19 @@ public void testAccessor2() { @Test public void testEquals() { - Pair p1 = new Pair(null, null); + Pair p1 = new Pair<>(null, null); Assert.assertFalse(p1.equals(null)); - Pair p2 = new Pair(null, null); + Pair p2 = new Pair<>(null, null); Assert.assertTrue(p1.equals(p2)); - p1 = new Pair(new Integer(1), new Double(2)); + p1 = new Pair<>(new Integer(1), new Double(2)); Assert.assertFalse(p1.equals(p2)); - p2 = new Pair(new Integer(1), new Double(2)); + p2 = new Pair<>(new Integer(1), new Double(2)); Assert.assertTrue(p1.equals(p2)); - Pair p3 = new Pair(new Integer(1), new Float(2)); + Pair p3 = new Pair<>(new Integer(1), new Float(2)); Assert.assertFalse(p1.equals(p3)); } @@ -64,8 +64,8 @@ public void testHashCode() { final MyInteger m1 = new MyInteger(1); final MyInteger m2 = new MyInteger(1); - final Pair p1 = new Pair(m1, m1); - final Pair p2 = new Pair(m2, m2); + final Pair p1 = new Pair<>(m1, m1); + final Pair p2 = new Pair<>(m2, m2); // Same contents, same hash code. Assert.assertTrue(p1.hashCode() == p2.hashCode()); @@ -76,15 +76,15 @@ public void testHashCode() { @Test public void testToString() { - Assert.assertEquals("[null, null]", new Pair(null, null).toString()); - Assert.assertEquals("[foo, 3]", new Pair("foo", 3).toString()); + Assert.assertEquals("[null, null]", new Pair<>(null, null).toString()); + Assert.assertEquals("[foo, 3]", new Pair<>("foo", 3).toString()); } @Test public void testCreate() { final Pair p1 = Pair.create("foo", 3); Assert.assertNotNull(p1); - final Pair p2 = new Pair("foo", 3); + final Pair p2 = new Pair<>("foo", 3); Assert.assertEquals(p2, p1); } From 6df150da22b4690ae521c6bd1abf10a1ed60c41b Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 20 Sep 2016 10:30:57 -0700 Subject: [PATCH 9/9] Revert "Remove redundant type arguments." This reverts commit 8b5f4535ec5a3983e655e5fc66a90fce657d4344. --- .../analysis/differentiation/DSCompiler.java | 10 +- .../differentiation/SparseGradient.java | 4 +- .../integration/gauss/BaseRuleFactory.java | 8 +- .../gauss/GaussIntegratorFactory.java | 2 +- .../integration/gauss/HermiteRuleFactory.java | 4 +- .../LegendreHighPrecisionRuleFactory.java | 4 +- .../gauss/LegendreRuleFactory.java | 4 +- .../FieldHermiteInterpolator.java | 6 +- .../interpolation/HermiteInterpolator.java | 6 +- .../InterpolatingMicrosphere.java | 6 +- .../polynomials/PolynomialsUtils.java | 12 +- .../apache/commons/math4/complex/Complex.java | 2 +- .../distribution/EnumeratedDistribution.java | 6 +- .../EnumeratedIntegerDistribution.java | 10 +- .../EnumeratedRealDistribution.java | 10 +- ...MixtureMultivariateNormalDistribution.java | 4 +- .../MixtureMultivariateRealDistribution.java | 6 +- ...eNormalMixtureExpectationMaximization.java | 4 +- .../math4/exception/util/ArgUtils.java | 2 +- .../exception/util/ExceptionContext.java | 12 +- .../math4/fitting/GaussianCurveFitter.java | 2 +- .../math4/fitting/HarmonicCurveFitter.java | 2 +- .../math4/fitting/WeightedObservedPoints.java | 4 +- .../leastsquares/GaussNewtonOptimizer.java | 2 +- .../leastsquares/LeastSquaresFactory.java | 2 +- .../genetics/AbstractListChromosome.java | 2 +- .../math4/genetics/BinaryChromosome.java | 2 +- .../math4/genetics/BinaryMutation.java | 2 +- .../math4/genetics/CycleCrossover.java | 8 +- .../math4/genetics/ListPopulation.java | 2 +- .../math4/genetics/NPointCrossover.java | 4 +- .../math4/genetics/OnePointCrossover.java | 4 +- .../math4/genetics/OrderedCrossover.java | 8 +- .../commons/math4/genetics/RandomKey.java | 16 +- .../math4/genetics/RandomKeyMutation.java | 2 +- .../math4/genetics/TournamentSelection.java | 2 +- .../math4/genetics/UniformCrossover.java | 4 +- .../geometry/enclosing/WelzlEncloser.java | 4 +- .../geometry/euclidean/oned/IntervalsSet.java | 22 +- .../euclidean/oned/SubOrientedPoint.java | 6 +- .../euclidean/threed/FieldRotation.java | 40 ++-- .../euclidean/threed/FieldVector3D.java | 42 ++-- .../euclidean/threed/OutlineExtractor.java | 2 +- .../euclidean/threed/PolyhedronsSet.java | 4 +- .../euclidean/threed/SphereGenerator.java | 10 +- .../geometry/euclidean/threed/SubLine.java | 2 +- .../geometry/euclidean/threed/SubPlane.java | 12 +- .../euclidean/twod/DiskGenerator.java | 8 +- .../geometry/euclidean/twod/NestedLoops.java | 8 +- .../geometry/euclidean/twod/PolygonsSet.java | 18 +- .../geometry/euclidean/twod/SubLine.java | 14 +- .../twod/hull/AklToussaintHeuristic.java | 4 +- .../euclidean/twod/hull/ConvexHull2D.java | 2 +- .../euclidean/twod/hull/MonotoneChain.java | 8 +- .../geometry/partitioning/AbstractRegion.java | 26 +- .../partitioning/AbstractSubHyperplane.java | 8 +- .../math4/geometry/partitioning/BSPTree.java | 34 +-- .../partitioning/BoundaryBuilder.java | 12 +- .../partitioning/BoundaryProjector.java | 4 +- .../partitioning/Characterization.java | 4 +- .../math4/geometry/partitioning/NodesSet.java | 2 +- .../geometry/partitioning/RegionFactory.java | 14 +- .../geometry/spherical/oned/ArcsSet.java | 36 +-- .../spherical/oned/SubLimitAngle.java | 4 +- .../geometry/spherical/twod/EdgesBuilder.java | 6 +- .../spherical/twod/PropertiesComputer.java | 2 +- .../spherical/twod/SphericalPolygonsSet.java | 30 +-- .../geometry/spherical/twod/SubCircle.java | 4 +- .../math4/geometry/spherical/twod/Vertex.java | 2 +- .../math4/linear/AbstractFieldMatrix.java | 16 +- .../math4/linear/AbstractRealMatrix.java | 2 +- .../math4/linear/Array2DRowFieldMatrix.java | 10 +- .../math4/linear/ArrayFieldVector.java | 40 ++-- .../math4/linear/BlockFieldMatrix.java | 32 +-- .../math4/linear/FieldLUDecomposition.java | 16 +- .../commons/math4/linear/MatrixUtils.java | 8 +- .../math4/linear/RealMatrixFormat.java | 6 +- .../math4/linear/RealVectorFormat.java | 2 +- .../math4/linear/SparseFieldMatrix.java | 12 +- .../math4/linear/SparseFieldVector.java | 32 +-- .../commons/math4/ml/clustering/Cluster.java | 2 +- .../math4/ml/clustering/DBSCANClusterer.java | 12 +- .../ml/clustering/FuzzyKMeansClusterer.java | 6 +- .../clustering/KMeansPlusPlusClusterer.java | 6 +- .../commons/math4/ml/neuralnet/MapUtils.java | 6 +- .../commons/math4/ml/neuralnet/Network.java | 14 +- .../commons/math4/ml/neuralnet/Neuron.java | 2 +- .../neuralnet/sofm/KohonenUpdateAction.java | 4 +- .../ml/neuralnet/twod/NeuronSquareMesh2D.java | 2 +- .../neuralnet/twod/util/LocationFinder.java | 2 +- .../math4/ode/AbstractFieldIntegrator.java | 14 +- .../commons/math4/ode/AbstractIntegrator.java | 8 +- .../math4/ode/AbstractParameterizable.java | 4 +- .../math4/ode/ContinuousOutputFieldModel.java | 2 +- .../math4/ode/ContinuousOutputModel.java | 2 +- .../math4/ode/ExpandableStatefulODE.java | 4 +- .../math4/ode/FieldEquationsMapper.java | 4 +- .../commons/math4/ode/FieldExpandableODE.java | 6 +- .../commons/math4/ode/JacobianMatrices.java | 2 +- .../math4/ode/MultistepFieldIntegrator.java | 4 +- .../math4/ode/ParameterJacobianWrapper.java | 2 +- .../math4/ode/ParameterizedWrapper.java | 2 +- .../AdamsBashforthFieldIntegrator.java | 2 +- .../nonstiff/AdamsFieldStepInterpolator.java | 6 +- .../nonstiff/AdamsMoultonFieldIntegrator.java | 4 +- .../AdamsNordsieckFieldTransformer.java | 22 +- .../nonstiff/AdamsNordsieckTransformer.java | 10 +- .../ClassicalRungeKuttaFieldIntegrator.java | 2 +- ...ssicalRungeKuttaFieldStepInterpolator.java | 4 +- .../DormandPrince54FieldIntegrator.java | 2 +- .../DormandPrince54FieldStepInterpolator.java | 4 +- .../DormandPrince853FieldIntegrator.java | 2 +- ...DormandPrince853FieldStepInterpolator.java | 4 +- .../EmbeddedRungeKuttaFieldIntegrator.java | 2 +- .../ode/nonstiff/EulerFieldIntegrator.java | 2 +- .../nonstiff/EulerFieldStepInterpolator.java | 4 +- .../ode/nonstiff/GillFieldIntegrator.java | 2 +- .../nonstiff/GillFieldStepInterpolator.java | 4 +- .../nonstiff/HighamHall54FieldIntegrator.java | 2 +- .../HighamHall54FieldStepInterpolator.java | 4 +- .../ode/nonstiff/LutherFieldIntegrator.java | 2 +- .../nonstiff/LutherFieldStepInterpolator.java | 4 +- .../ode/nonstiff/MidpointFieldIntegrator.java | 2 +- .../MidpointFieldStepInterpolator.java | 4 +- .../nonstiff/RungeKuttaFieldIntegrator.java | 2 +- .../ThreeEighthesFieldIntegrator.java | 2 +- .../ThreeEighthesFieldStepInterpolator.java | 4 +- .../optim/linear/LinearConstraintSet.java | 2 +- .../math4/optim/linear/SimplexSolver.java | 2 +- .../math4/optim/linear/SimplexTableau.java | 8 +- .../MultiStartMultivariateOptimizer.java | 2 +- .../scalar/noderiv/CMAESOptimizer.java | 8 +- .../commons/math4/primes/SmallPrimes.java | 2 +- .../math4/random/EmpiricalDistribution.java | 2 +- .../apache/commons/math4/stat/Frequency.java | 6 +- .../stat/correlation/KendallsCorrelation.java | 2 +- .../descriptive/rank/PSquarePercentile.java | 2 +- .../stat/inference/KolmogorovSmirnovTest.java | 4 +- .../math4/stat/inference/OneWayAnova.java | 2 +- .../math4/stat/ranking/NaturalRanking.java | 6 +- .../math4/util/CombinatoricsUtils.java | 2 +- .../commons/math4/util/IterationManager.java | 4 +- .../apache/commons/math4/util/MathArrays.java | 4 +- .../org/apache/commons/math4/util/Pair.java | 2 +- .../commons/math4/util/TransformerMap.java | 2 +- .../differentiation/DSCompilerTest.java | 4 +- .../gauss/BaseRuleFactoryTest.java | 4 +- .../gauss/GaussIntegratorTest.java | 6 +- .../gauss/HermiteParametricTest.java | 2 +- .../LegendreHighPrecisionParametricTest.java | 2 +- .../gauss/LegendreParametricTest.java | 2 +- .../FieldHermiteInterpolatorTest.java | 20 +- ...ieldBracketingNthOrderBrentSolverTest.java | 8 +- .../EnumeratedRealDistributionTest.java | 4 +- ...ateNormalMixtureModelDistributionTest.java | 4 +- .../RealDistributionAbstractTest.java | 2 +- ...malMixtureExpectationMaximizationTest.java | 6 +- .../math4/exception/util/ArgUtilsTest.java | 2 +- .../fitting/HarmonicCurveFitterTest.java | 2 +- .../fitting/leastsquares/CircleProblem.java | 2 +- .../fitting/leastsquares/CircleVectorial.java | 2 +- .../fitting/leastsquares/EvaluationTest.java | 4 +- .../EvaluationTestValidation.java | 2 +- .../LevenbergMarquardtOptimizerTest.java | 4 +- .../StatisticalReferenceDataset.java | 2 +- .../leastsquares/StraightLineProblem.java | 2 +- .../math4/genetics/ChromosomeTest.java | 2 +- .../math4/genetics/FitnessCachingTest.java | 2 +- .../genetics/GeneticAlgorithmTestBinary.java | 2 +- .../GeneticAlgorithmTestPermutations.java | 4 +- .../math4/genetics/ListPopulationTest.java | 14 +- .../math4/genetics/NPointCrossoverTest.java | 2 +- .../math4/genetics/OnePointCrossoverTest.java | 2 +- .../math4/genetics/OrderedCrossoverTest.java | 4 +- .../math4/genetics/UniformCrossoverTest.java | 4 +- .../enclosing/WelzlEncloser2DTest.java | 12 +- .../enclosing/WelzlEncloser3DTest.java | 14 +- .../euclidean/oned/IntervalsSetTest.java | 2 +- .../euclidean/threed/FieldRotationDSTest.java | 118 ++++----- .../threed/FieldRotationDfpTest.java | 116 ++++----- .../euclidean/threed/FieldVector3DTest.java | 48 ++-- .../geometry/euclidean/threed/PLYParser.java | 2 +- .../euclidean/threed/PolyhedronsSetTest.java | 6 +- .../euclidean/threed/SphereGeneratorTest.java | 2 +- .../euclidean/twod/DiskGeneratorTest.java | 2 +- .../euclidean/twod/PolygonsSetTest.java | 52 ++-- .../ConvexHullGenerator2DAbstractTest.java | 24 +- .../twod/hull/MonotoneChainTest.java | 2 +- .../geometry/partitioning/RegionParser.java | 2 +- .../geometry/spherical/oned/ArcsSetTest.java | 14 +- .../twod/SphericalPolygonsSetTest.java | 14 +- .../spherical/twod/SubCircleTest.java | 2 +- .../math4/linear/ArrayFieldVectorTest.java | 96 ++++---- .../math4/linear/BlockFieldMatrixTest.java | 226 +++++++++--------- .../linear/FieldLUDecompositionTest.java | 62 ++--- .../math4/linear/FieldLUSolverTest.java | 18 +- .../math4/linear/FieldMatrixImplTest.java | 212 ++++++++-------- .../commons/math4/linear/MatrixUtilsTest.java | 16 +- .../math4/linear/SparseFieldMatrixTest.java | 26 +- .../math4/linear/SparseFieldVectorTest.java | 40 ++-- .../UnmodifiableRealVectorAbstractTest.java | 2 +- .../ml/clustering/DBSCANClustererTest.java | 10 +- .../clustering/FuzzyKMeansClustererTest.java | 16 +- .../KMeansPlusPlusClustererTest.java | 10 +- .../MultiKMeansPlusPlusClustererTest.java | 2 +- .../evaluation/SumOfClusterVariancesTest.java | 8 +- .../math4/ml/neuralnet/MapUtilsTest.java | 6 +- .../ml/neuralnet/oned/NeuronStringTest.java | 2 +- .../sofm/KohonenTrainingTaskTest.java | 4 +- .../sofm/TravellingSalesmanSolver.java | 8 +- .../twod/NeuronSquareMesh2DTest.java | 8 +- .../ode/ContinuousOutputFieldModelTest.java | 44 ++-- .../math4/ode/FieldExpandableODETest.java | 46 ++-- .../commons/math4/ode/TestFieldProblem4.java | 6 +- .../math4/ode/TestFieldProblemAbstract.java | 2 +- .../ode/events/OverlappingEventsTest.java | 4 +- ...EmbeddedRungeKuttaFieldIntegratorTest.java | 64 ++--- ...AbstractRungeKuttaFieldIntegratorTest.java | 80 +++---- .../AdamsBashforthFieldIntegratorTest.java | 4 +- .../AdamsFieldIntegratorAbstractTest.java | 44 ++-- .../AdamsMoultonFieldIntegratorTest.java | 4 +- ...calRungKuttaFieldStepInterpolatorTest.java | 4 +- ...lassicalRungeKuttaFieldIntegratorTest.java | 2 +- .../DormandPrince54FieldIntegratorTest.java | 4 +- ...mandPrince54FieldStepInterpolatorTest.java | 4 +- .../DormandPrince853FieldIntegratorTest.java | 4 +- ...andPrince853FieldStepInterpolatorTest.java | 4 +- ...RungeKuttaFieldIntegratorAbstractTest.java | 64 ++--- .../nonstiff/EulerFieldIntegratorTest.java | 2 +- .../EulerFieldStepInterpolatorTest.java | 4 +- .../ode/nonstiff/GillFieldIntegratorTest.java | 2 +- .../GillFieldStepInterpolatorTest.java | 4 +- .../HighamHall54FieldIntegratorTest.java | 4 +- ...HighamHall54FieldStepInterpolatorTest.java | 4 +- .../nonstiff/LutherFieldIntegratorTest.java | 2 +- .../LutherFieldStepInterpolatorTest.java | 4 +- .../nonstiff/MidpointFieldIntegratorTest.java | 2 +- .../MidpointFieldStepInterpolatorTest.java | 4 +- ...RungeKuttaFieldIntegratorAbstractTest.java | 80 +++---- ...uttaFieldStepInterpolatorAbstractTest.java | 12 +- .../ThreeEighthesFieldIntegratorTest.java | 2 +- ...hreeEighthesFieldStepInterpolatorTest.java | 4 +- .../sampling/DummyFieldStepInterpolator.java | 2 +- .../sampling/StepInterpolatorTestUtils.java | 2 +- .../StepNormalizerOutputTestBase.java | 2 +- .../math4/optim/SimplePointCheckerTest.java | 4 +- .../math4/optim/linear/SimplexSolverTest.java | 62 ++--- .../optim/linear/SimplexTableauTest.java | 4 +- .../scalar/gradient/CircleScalar.java | 2 +- .../commons/math4/primes/PrimesTest.java | 2 +- .../random/EmpiricalDistributionTest.java | 2 +- .../math4/random/RandomDataGeneratorTest.java | 12 +- .../SynchronizedRandomGeneratorTest.java | 2 +- .../commons/math4/stat/FrequencyTest.java | 2 +- .../stat/data/CertifiedDataAbstractTest.java | 2 +- .../AggregateSummaryStatisticsTest.java | 8 +- .../stat/descriptive/ListUnivariateImpl.java | 2 +- .../descriptive/ListUnivariateImplTest.java | 6 +- .../MixedListUnivariateImplTest.java | 8 +- .../UnivariateStatisticAbstractTest.java | 2 +- .../rank/PSquarePercentileTest.java | 4 +- .../math4/stat/inference/OneWayAnovaTest.java | 20 +- .../math4/stat/inference/TestUtilsTest.java | 2 +- .../math4/util/ArithmeticUtilsTest.java | 2 +- .../math4/util/CombinatoricsUtilsTest.java | 2 +- .../util/FastMathStrictComparisonTest.java | 2 +- .../math4/util/IntegerSequenceTest.java | 16 +- .../util/OpenIntToDoubleHashMapTest.java | 8 +- .../math4/util/OpenIntToFieldTest.java | 26 +- .../apache/commons/math4/util/PairTest.java | 24 +- 270 files changed, 1554 insertions(+), 1552 deletions(-) diff --git a/src/main/java/org/apache/commons/math4/analysis/differentiation/DSCompiler.java b/src/main/java/org/apache/commons/math4/analysis/differentiation/DSCompiler.java index 3b1bc738d4..7515a18983 100644 --- a/src/main/java/org/apache/commons/math4/analysis/differentiation/DSCompiler.java +++ b/src/main/java/org/apache/commons/math4/analysis/differentiation/DSCompiler.java @@ -126,7 +126,7 @@ public class DSCompiler { /** Array of all compilers created so far. */ private static AtomicReference compilers = - new AtomicReference<>(null); + new AtomicReference(null); /** Number of free parameters. */ private final int parameters; @@ -358,14 +358,14 @@ private static int[][][] compileMultiplicationIndirection(final int parameters, for (int i = 0; i < dSize; ++i) { final int[][] dRow = derivativeCompiler.multIndirection[i]; - List row = new ArrayList<>(dRow.length * 2); + List row = new ArrayList(dRow.length * 2); for (int j = 0; j < dRow.length; ++j) { row.add(new int[] { dRow[j][0], lowerIndirection[dRow[j][1]], vSize + dRow[j][2] }); row.add(new int[] { dRow[j][0], vSize + dRow[j][1], lowerIndirection[dRow[j][2]] }); } // combine terms with similar derivation orders - final List combined = new ArrayList<>(row.size()); + final List combined = new ArrayList(row.size()); for (int j = 0; j < row.size(); ++j) { final int[] termJ = row.get(j); if (termJ[0] > 0) { @@ -428,7 +428,7 @@ private static int[][][] compileCompositionIndirection(final int parameters, fin // with respect to the parameter this compiler handles and the // underlying one did not handle for (int i = 0; i < dSize; ++i) { - List row = new ArrayList<>(); + List row = new ArrayList(); for (int[] term : derivativeCompiler.compIndirection[i]) { // handle term p * f_k(g(x)) * g_l1(x) * g_l2(x) * ... * g_lp(x) @@ -475,7 +475,7 @@ private static int[][][] compileCompositionIndirection(final int parameters, fin } // combine terms with similar derivation orders - final List combined = new ArrayList<>(row.size()); + final List combined = new ArrayList(row.size()); for (int j = 0; j < row.size(); ++j) { final int[] termJ = row.get(j); if (termJ[0] > 0) { diff --git a/src/main/java/org/apache/commons/math4/analysis/differentiation/SparseGradient.java b/src/main/java/org/apache/commons/math4/analysis/differentiation/SparseGradient.java index 643a975f7d..130c33505b 100644 --- a/src/main/java/org/apache/commons/math4/analysis/differentiation/SparseGradient.java +++ b/src/main/java/org/apache/commons/math4/analysis/differentiation/SparseGradient.java @@ -61,7 +61,7 @@ public class SparseGradient implements RealFieldElement, Seriali */ private SparseGradient(final double value, final Map derivatives) { this.value = value; - this.derivatives = new HashMap<>(); + this.derivatives = new HashMap(); if (derivatives != null) { this.derivatives.putAll(derivatives); } @@ -77,7 +77,7 @@ private SparseGradient(final double value, final Map derivative private SparseGradient(final double value, final double scale, final Map derivatives) { this.value = value; - this.derivatives = new HashMap<>(); + this.derivatives = new HashMap(); if (derivatives != null) { for (final Map.Entry entry : derivatives.entrySet()) { this.derivatives.put(entry.getKey(), scale * entry.getValue()); diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactory.java index bd05c5e686..0b3623800e 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactory.java @@ -37,10 +37,10 @@ public abstract class BaseRuleFactory { /** List of points and weights, indexed by the order of the rule. */ private final Map> pointsAndWeights - = new TreeMap<>(); + = new TreeMap>(); /** Cache for double-precision rules. */ private final Map> pointsAndWeightsDouble - = new TreeMap<>(); + = new TreeMap>(); /** * Gets a copy of the quadrature rule with the given number of integration @@ -75,7 +75,7 @@ public Pair getRule(int numberOfPoints) } // Return a copy. - return new Pair<>(cached.getFirst().clone(), + return new Pair(cached.getFirst().clone(), cached.getSecond().clone()); } @@ -149,6 +149,6 @@ private static Pair convertToDouble(Pair< wD[i] = wT[i].doubleValue(); } - return new Pair<>(pD, wD); + return new Pair(pD, wD); } } diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java index d392277ab4..d15d6abe31 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java @@ -162,6 +162,6 @@ private static Pair transform(Pair rule, weights[i] *= scale; } - return new Pair<>(points, weights); + return new Pair(points, weights); } } diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java index e65f5bdeb3..5c1d0a2693 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java @@ -63,7 +63,7 @@ protected Pair computeRule(int numberOfPoints) if (numberOfPoints == 1) { // Break recursion. - return new Pair<>(new Double[] { 0d }, + return new Pair(new Double[] { 0d }, new Double[] { SQRT_PI }); } @@ -172,6 +172,6 @@ protected Pair computeRule(int numberOfPoints) weights[iMax] = w; } - return new Pair<>(points, weights); + return new Pair(points, weights); } } diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java index 1790c725a4..e4108a239b 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java @@ -66,7 +66,7 @@ protected Pair computeRule(int numberOfPoints) if (numberOfPoints == 1) { // Break recursion. - return new Pair<>(new BigDecimal[] { BigDecimal.ZERO }, + return new Pair(new BigDecimal[] { BigDecimal.ZERO }, new BigDecimal[] { two }); } @@ -210,6 +210,6 @@ protected Pair computeRule(int numberOfPoints) weights[iMax] = tmp2; } - return new Pair<>(points, weights); + return new Pair(points, weights); } } diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java index 29684bffa0..113ab3823f 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java @@ -37,7 +37,7 @@ protected Pair computeRule(int numberOfPoints) if (numberOfPoints == 1) { // Break recursion. - return new Pair<>(new Double[] { 0d }, + return new Pair(new Double[] { 0d }, new Double[] { 2d }); } @@ -135,6 +135,6 @@ protected Pair computeRule(int numberOfPoints) weights[iMax] = w; } - return new Pair<>(points, weights); + return new Pair(points, weights); } } diff --git a/src/main/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolator.java b/src/main/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolator.java index 3241ddf383..e5e660f7a2 100644 --- a/src/main/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolator.java +++ b/src/main/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolator.java @@ -61,9 +61,9 @@ public class FieldHermiteInterpolator> { /** Create an empty interpolator. */ public FieldHermiteInterpolator() { - this.abscissae = new ArrayList<>(); - this.topDiagonal = new ArrayList<>(); - this.bottomDiagonal = new ArrayList<>(); + this.abscissae = new ArrayList(); + this.topDiagonal = new ArrayList(); + this.bottomDiagonal = new ArrayList(); } /** Add a sample point. diff --git a/src/main/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolator.java b/src/main/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolator.java index 5a30815060..3aeb135034 100644 --- a/src/main/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolator.java +++ b/src/main/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolator.java @@ -59,9 +59,9 @@ public class HermiteInterpolator implements UnivariateDifferentiableVectorFuncti /** Create an empty interpolator. */ public HermiteInterpolator() { - this.abscissae = new ArrayList<>(); - this.topDiagonal = new ArrayList<>(); - this.bottomDiagonal = new ArrayList<>(); + this.abscissae = new ArrayList(); + this.topDiagonal = new ArrayList(); + this.bottomDiagonal = new ArrayList(); } /** Add a sample point. diff --git a/src/main/java/org/apache/commons/math4/analysis/interpolation/InterpolatingMicrosphere.java b/src/main/java/org/apache/commons/math4/analysis/interpolation/InterpolatingMicrosphere.java index 4887d80da1..c8929cf0ef 100644 --- a/src/main/java/org/apache/commons/math4/analysis/interpolation/InterpolatingMicrosphere.java +++ b/src/main/java/org/apache/commons/math4/analysis/interpolation/InterpolatingMicrosphere.java @@ -93,8 +93,8 @@ protected InterpolatingMicrosphere(int dimension, this.maxDarkFraction = maxDarkFraction; this.darkThreshold = darkThreshold; this.background = background; - microsphere = new ArrayList<>(size); - microsphereData = new ArrayList<>(size); + microsphere = new ArrayList(size); + microsphereData = new ArrayList(size); } /** @@ -150,7 +150,7 @@ protected InterpolatingMicrosphere(InterpolatingMicrosphere other) { microsphere = other.microsphere; // Field must be copied. - microsphereData = new ArrayList<>(size); + microsphereData = new ArrayList(size); for (FacetData fd : other.microsphereData) { microsphereData.add(new FacetData(fd.illumination(), fd.sample())); } diff --git a/src/main/java/org/apache/commons/math4/analysis/polynomials/PolynomialsUtils.java b/src/main/java/org/apache/commons/math4/analysis/polynomials/PolynomialsUtils.java index 92e9e6d9a6..c4069792a9 100644 --- a/src/main/java/org/apache/commons/math4/analysis/polynomials/PolynomialsUtils.java +++ b/src/main/java/org/apache/commons/math4/analysis/polynomials/PolynomialsUtils.java @@ -51,34 +51,34 @@ public class PolynomialsUtils { // initialize recurrence for Chebyshev polynomials // T0(X) = 1, T1(X) = 0 + 1 * X - CHEBYSHEV_COEFFICIENTS = new ArrayList<>(); + CHEBYSHEV_COEFFICIENTS = new ArrayList(); CHEBYSHEV_COEFFICIENTS.add(BigFraction.ONE); CHEBYSHEV_COEFFICIENTS.add(BigFraction.ZERO); CHEBYSHEV_COEFFICIENTS.add(BigFraction.ONE); // initialize recurrence for Hermite polynomials // H0(X) = 1, H1(X) = 0 + 2 * X - HERMITE_COEFFICIENTS = new ArrayList<>(); + HERMITE_COEFFICIENTS = new ArrayList(); HERMITE_COEFFICIENTS.add(BigFraction.ONE); HERMITE_COEFFICIENTS.add(BigFraction.ZERO); HERMITE_COEFFICIENTS.add(BigFraction.TWO); // initialize recurrence for Laguerre polynomials // L0(X) = 1, L1(X) = 1 - 1 * X - LAGUERRE_COEFFICIENTS = new ArrayList<>(); + LAGUERRE_COEFFICIENTS = new ArrayList(); LAGUERRE_COEFFICIENTS.add(BigFraction.ONE); LAGUERRE_COEFFICIENTS.add(BigFraction.ONE); LAGUERRE_COEFFICIENTS.add(BigFraction.MINUS_ONE); // initialize recurrence for Legendre polynomials // P0(X) = 1, P1(X) = 0 + 1 * X - LEGENDRE_COEFFICIENTS = new ArrayList<>(); + LEGENDRE_COEFFICIENTS = new ArrayList(); LEGENDRE_COEFFICIENTS.add(BigFraction.ONE); LEGENDRE_COEFFICIENTS.add(BigFraction.ZERO); LEGENDRE_COEFFICIENTS.add(BigFraction.ONE); // initialize map for Jacobi polynomials - JACOBI_COEFFICIENTS = new HashMap<>(); + JACOBI_COEFFICIENTS = new HashMap>(); } @@ -228,7 +228,7 @@ public static PolynomialFunction createJacobiPolynomial(final int degree, final if (!JACOBI_COEFFICIENTS.containsKey(key)) { // allocate a new list for v, w - final List list = new ArrayList<>(); + final List list = new ArrayList(); JACOBI_COEFFICIENTS.put(key, list); // Pv,w,0(x) = 1; diff --git a/src/main/java/org/apache/commons/math4/complex/Complex.java b/src/main/java/org/apache/commons/math4/complex/Complex.java index 48b17fc124..5a073c7c28 100644 --- a/src/main/java/org/apache/commons/math4/complex/Complex.java +++ b/src/main/java/org/apache/commons/math4/complex/Complex.java @@ -1209,7 +1209,7 @@ public List nthRoot(int n) throws NotPositiveException { n); } - final List result = new ArrayList<>(); + final List result = new ArrayList(); if (isNaN) { result.add(NaN); diff --git a/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java b/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java index 838e2252bb..8e1149f0db 100644 --- a/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java @@ -117,7 +117,7 @@ public EnumeratedDistribution(final RandomGenerator rng, final List(pmf.size()); + singletons = new ArrayList(pmf.size()); final double[] probs = new double[pmf.size()]; for (int i = 0; i < pmf.size(); i++) { @@ -191,10 +191,10 @@ public void reseedRandomGenerator(long seed) { * @return the probability mass function. */ public List> getPmf() { - final List> samples = new ArrayList<>(probabilities.length); + final List> samples = new ArrayList>(probabilities.length); for (int i = 0; i < probabilities.length; i++) { - samples.add(new Pair<>(singletons.get(i), probabilities[i])); + samples.add(new Pair(singletons.get(i), probabilities[i])); } return samples; diff --git a/src/main/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistribution.java b/src/main/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistribution.java index e3f271d9e7..af641406ff 100644 --- a/src/main/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistribution.java @@ -97,7 +97,7 @@ public EnumeratedIntegerDistribution(final RandomGenerator rng, throws DimensionMismatchException, NotPositiveException, MathArithmeticException, NotFiniteNumberException, NotANumberException { super(rng); - innerDistribution = new EnumeratedDistribution<>( + innerDistribution = new EnumeratedDistribution( rng, createDistribution(singletons, probabilities)); } @@ -111,7 +111,7 @@ public EnumeratedIntegerDistribution(final RandomGenerator rng, */ public EnumeratedIntegerDistribution(final RandomGenerator rng, final int[] data) { super(rng); - final Map dataMap = new HashMap<>(); + final Map dataMap = new HashMap(); for (int value : data) { Integer count = dataMap.get(value); if (count == null) { @@ -129,7 +129,7 @@ public EnumeratedIntegerDistribution(final RandomGenerator rng, final int[] data probabilities[index] = entry.getValue().intValue() / denom; index++; } - innerDistribution = new EnumeratedDistribution<>(rng, createDistribution(values, probabilities)); + innerDistribution = new EnumeratedDistribution(rng, createDistribution(values, probabilities)); } /** @@ -156,10 +156,10 @@ private static List> createDistribution(int[] singletons, throw new DimensionMismatchException(probabilities.length, singletons.length); } - final List> samples = new ArrayList<>(singletons.length); + final List> samples = new ArrayList>(singletons.length); for (int i = 0; i < singletons.length; i++) { - samples.add(new Pair<>(singletons[i], probabilities[i])); + samples.add(new Pair(singletons[i], probabilities[i])); } return samples; diff --git a/src/main/java/org/apache/commons/math4/distribution/EnumeratedRealDistribution.java b/src/main/java/org/apache/commons/math4/distribution/EnumeratedRealDistribution.java index b98b3ad28c..688b3fda46 100644 --- a/src/main/java/org/apache/commons/math4/distribution/EnumeratedRealDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/EnumeratedRealDistribution.java @@ -99,7 +99,7 @@ public EnumeratedRealDistribution(final RandomGenerator rng, NotFiniteNumberException, NotANumberException { super(rng); - innerDistribution = new EnumeratedDistribution<>( + innerDistribution = new EnumeratedDistribution( rng, createDistribution(singletons, probabilities)); } @@ -113,7 +113,7 @@ public EnumeratedRealDistribution(final RandomGenerator rng, */ public EnumeratedRealDistribution(final RandomGenerator rng, final double[] data) { super(rng); - final Map dataMap = new HashMap<>(); + final Map dataMap = new HashMap(); for (double value : data) { Integer count = dataMap.get(value); if (count == null) { @@ -131,7 +131,7 @@ public EnumeratedRealDistribution(final RandomGenerator rng, final double[] data probabilities[index] = entry.getValue().intValue() / denom; index++; } - innerDistribution = new EnumeratedDistribution<>(rng, createDistribution(values, probabilities)); + innerDistribution = new EnumeratedDistribution(rng, createDistribution(values, probabilities)); } /** @@ -157,10 +157,10 @@ private static List> createDistribution(double[] singleton throw new DimensionMismatchException(probabilities.length, singletons.length); } - final List> samples = new ArrayList<>(singletons.length); + final List> samples = new ArrayList>(singletons.length); for (int i = 0; i < singletons.length; i++) { - samples.add(new Pair<>(singletons[i], probabilities[i])); + samples.add(new Pair(singletons[i], probabilities[i])); } return samples; diff --git a/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateNormalDistribution.java b/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateNormalDistribution.java index c06d8efc1a..d7cd4cdb10 100644 --- a/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateNormalDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateNormalDistribution.java @@ -99,13 +99,13 @@ private static List> createComponen double[][] means, double[][][] covariances) { final List> mvns - = new ArrayList<>(weights.length); + = new ArrayList>(weights.length); for (int i = 0; i < weights.length; i++) { final MultivariateNormalDistribution dist = new MultivariateNormalDistribution(means[i], covariances[i]); - mvns.add(new Pair<>(weights[i], dist)); + mvns.add(new Pair(weights[i], dist)); } return mvns; diff --git a/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateRealDistribution.java b/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateRealDistribution.java index e20f0d65a6..ce8c7d9610 100644 --- a/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateRealDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/MixtureMultivariateRealDistribution.java @@ -93,7 +93,7 @@ public MixtureMultivariateRealDistribution(RandomGenerator rng, } // Store each distribution and its normalized weight. - distribution = new ArrayList<>(); + distribution = new ArrayList(); weight = new double[numComp]; for (int i = 0; i < numComp; i++) { final Pair comp = components.get(i); @@ -161,10 +161,10 @@ public void reseedRandomGenerator(long seed) { * @return the component distributions and associated weights. */ public List> getComponents() { - final List> list = new ArrayList<>(weight.length); + final List> list = new ArrayList>(weight.length); for (int i = 0; i < weight.length; i++) { - list.add(new Pair<>(weight[i], distribution.get(i))); + list.add(new Pair(weight[i], distribution.get(i))); } return list; diff --git a/src/main/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximization.java b/src/main/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximization.java index 20cbfc2074..a0cf24818c 100644 --- a/src/main/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximization.java +++ b/src/main/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximization.java @@ -328,7 +328,7 @@ public static MixtureMultivariateNormalDistribution estimate(final double[][] da // components of mixture model to be created final List> components = - new ArrayList<>(numComponents); + new ArrayList>(numComponents); // create a component based on data in each bin for (int binIndex = 0; binIndex < numComponents; binIndex++) { @@ -364,7 +364,7 @@ public static MixtureMultivariateNormalDistribution estimate(final double[][] da final MultivariateNormalDistribution mvn = new MultivariateNormalDistribution(columnMeans, covMat); - components.add(new Pair<>(weight, mvn)); + components.add(new Pair(weight, mvn)); } return new MixtureMultivariateNormalDistribution(components); diff --git a/src/main/java/org/apache/commons/math4/exception/util/ArgUtils.java b/src/main/java/org/apache/commons/math4/exception/util/ArgUtils.java index 6e447a019b..577b0a56af 100644 --- a/src/main/java/org/apache/commons/math4/exception/util/ArgUtils.java +++ b/src/main/java/org/apache/commons/math4/exception/util/ArgUtils.java @@ -38,7 +38,7 @@ private ArgUtils() {} * {@code array}. */ public static Object[] flatten(Object[] array) { - final List list = new ArrayList<>(); + final List list = new ArrayList(); if (array != null) { for (Object o : array) { if (o instanceof Object[]) { diff --git a/src/main/java/org/apache/commons/math4/exception/util/ExceptionContext.java b/src/main/java/org/apache/commons/math4/exception/util/ExceptionContext.java index 4cdde9af93..59f91a313d 100644 --- a/src/main/java/org/apache/commons/math4/exception/util/ExceptionContext.java +++ b/src/main/java/org/apache/commons/math4/exception/util/ExceptionContext.java @@ -62,9 +62,9 @@ public class ExceptionContext implements Serializable { */ public ExceptionContext(final Throwable throwable) { this.throwable = throwable; - msgPatterns = new ArrayList<>(); - msgArguments = new ArrayList<>(); - context = new HashMap<>(); + msgPatterns = new ArrayList(); + msgArguments = new ArrayList(); + context = new HashMap(); } /** Get a reference to the exception to which the context relates. @@ -256,8 +256,8 @@ private void deSerializeMessages(ObjectInputStream in) ClassNotFoundException { // Step 1. final int len = in.readInt(); - msgPatterns = new ArrayList<>(len); - msgArguments = new ArrayList<>(len); + msgPatterns = new ArrayList(len); + msgArguments = new ArrayList(len); // Step 2. for (int i = 0; i < len; i++) { // Step 3. @@ -311,7 +311,7 @@ private void deSerializeContext(ObjectInputStream in) ClassNotFoundException { // Step 1. final int len = in.readInt(); - context = new HashMap<>(); + context = new HashMap(); for (int i = 0; i < len; i++) { // Step 2. final String key = (String) in.readObject(); diff --git a/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java b/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java index 3c5f14a320..ae2b8d8dac 100644 --- a/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java +++ b/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java @@ -248,7 +248,7 @@ public double[] guess() { * @return the input observations, sorted. */ private List sortObservations(Collection unsorted) { - final List observations = new ArrayList<>(unsorted); + final List observations = new ArrayList(unsorted); final Comparator cmp = new Comparator() { /** {@inheritDoc} */ diff --git a/src/main/java/org/apache/commons/math4/fitting/HarmonicCurveFitter.java b/src/main/java/org/apache/commons/math4/fitting/HarmonicCurveFitter.java index fbd643f2c2..c8a2a8e37d 100644 --- a/src/main/java/org/apache/commons/math4/fitting/HarmonicCurveFitter.java +++ b/src/main/java/org/apache/commons/math4/fitting/HarmonicCurveFitter.java @@ -292,7 +292,7 @@ public double[] guess() { * @return the input observations, sorted. */ private List sortObservations(Collection unsorted) { - final List observations = new ArrayList<>(unsorted); + final List observations = new ArrayList(unsorted); // Since the samples are almost always already sorted, this // method is implemented as an insertion sort that reorders the diff --git a/src/main/java/org/apache/commons/math4/fitting/WeightedObservedPoints.java b/src/main/java/org/apache/commons/math4/fitting/WeightedObservedPoints.java index 00cef70ce0..520af887b6 100644 --- a/src/main/java/org/apache/commons/math4/fitting/WeightedObservedPoints.java +++ b/src/main/java/org/apache/commons/math4/fitting/WeightedObservedPoints.java @@ -32,7 +32,7 @@ public class WeightedObservedPoints implements Serializable { /** Observed points. */ private final List observations - = new ArrayList<>(); + = new ArrayList(); /** * Adds a point to the sample. @@ -100,7 +100,7 @@ public List toList() { // The copy is necessary to ensure thread-safety because of the // "clear" method (which otherwise would be able to empty the // list of points while it is being used by another thread). - return new ArrayList<>(observations); + return new ArrayList(observations); } /** diff --git a/src/main/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizer.java b/src/main/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizer.java index 637382cdf2..ec17b931c1 100644 --- a/src/main/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizer.java +++ b/src/main/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizer.java @@ -294,7 +294,7 @@ private static Pair computeNormalMatrix(final RealMatrix normal.setEntry(i, j, normal.getEntry(j, i)); } } - return new Pair<>(normal, jTr); + return new Pair(normal, jTr); } } diff --git a/src/main/java/org/apache/commons/math4/fitting/leastsquares/LeastSquaresFactory.java b/src/main/java/org/apache/commons/math4/fitting/leastsquares/LeastSquaresFactory.java index 933278d5a4..a0ddace064 100644 --- a/src/main/java/org/apache/commons/math4/fitting/leastsquares/LeastSquaresFactory.java +++ b/src/main/java/org/apache/commons/math4/fitting/leastsquares/LeastSquaresFactory.java @@ -332,7 +332,7 @@ public Pair value(final RealVector point) { final double[] p = point.toArray(); // Evaluate. - return new Pair<>(computeValue(p), + return new Pair(computeValue(p), computeJacobian(p)); } diff --git a/src/main/java/org/apache/commons/math4/genetics/AbstractListChromosome.java b/src/main/java/org/apache/commons/math4/genetics/AbstractListChromosome.java index e7ac9a87f5..707ddd5044 100644 --- a/src/main/java/org/apache/commons/math4/genetics/AbstractListChromosome.java +++ b/src/main/java/org/apache/commons/math4/genetics/AbstractListChromosome.java @@ -59,7 +59,7 @@ public AbstractListChromosome(final T[] representation) throws InvalidRepresenta public AbstractListChromosome(final List representation, final boolean copyList) { checkValidity(representation); this.representation = - Collections.unmodifiableList(copyList ? new ArrayList<>(representation) : representation); + Collections.unmodifiableList(copyList ? new ArrayList(representation) : representation); } /** diff --git a/src/main/java/org/apache/commons/math4/genetics/BinaryChromosome.java b/src/main/java/org/apache/commons/math4/genetics/BinaryChromosome.java index 6f1e08cb10..b4aa23291d 100644 --- a/src/main/java/org/apache/commons/math4/genetics/BinaryChromosome.java +++ b/src/main/java/org/apache/commons/math4/genetics/BinaryChromosome.java @@ -67,7 +67,7 @@ protected void checkValidity(List chromosomeRepresentation) throws Inva */ public static List randomBinaryRepresentation(int length) { // random binary list - List rList= new ArrayList<> (length); + List rList= new ArrayList (length); for (int j=0; j newRepr = new ArrayList<>(origChrom.getRepresentation()); + List newRepr = new ArrayList(origChrom.getRepresentation()); // randomly select a gene int geneIndex = GeneticAlgorithm.getRandomGenerator().nextInt(origChrom.getLength()); diff --git a/src/main/java/org/apache/commons/math4/genetics/CycleCrossover.java b/src/main/java/org/apache/commons/math4/genetics/CycleCrossover.java index 0de83713a8..507ffdf499 100644 --- a/src/main/java/org/apache/commons/math4/genetics/CycleCrossover.java +++ b/src/main/java/org/apache/commons/math4/genetics/CycleCrossover.java @@ -129,13 +129,13 @@ protected ChromosomePair mate(final AbstractListChromosome first, final Abstr final List parent1Rep = first.getRepresentation(); final List parent2Rep = second.getRepresentation(); // and of the children: do a crossover copy to simplify the later processing - final List child1Rep = new ArrayList<>(second.getRepresentation()); - final List child2Rep = new ArrayList<>(first.getRepresentation()); + final List child1Rep = new ArrayList(second.getRepresentation()); + final List child2Rep = new ArrayList(first.getRepresentation()); // the set of all visited indices so far - final Set visitedIndices = new HashSet<>(length); + final Set visitedIndices = new HashSet(length); // the indices of the current cycle - final List indices = new ArrayList<>(length); + final List indices = new ArrayList(length); // determine the starting index int idx = randomStart ? GeneticAlgorithm.getRandomGenerator().nextInt(length) : 0; diff --git a/src/main/java/org/apache/commons/math4/genetics/ListPopulation.java b/src/main/java/org/apache/commons/math4/genetics/ListPopulation.java index 0aa02396b1..1adf6ac634 100644 --- a/src/main/java/org/apache/commons/math4/genetics/ListPopulation.java +++ b/src/main/java/org/apache/commons/math4/genetics/ListPopulation.java @@ -76,7 +76,7 @@ public ListPopulation(final List chromosomes, final int populationLi chromosomes.size(), populationLimit, false); } this.populationLimit = populationLimit; - this.chromosomes = new ArrayList<>(populationLimit); + this.chromosomes = new ArrayList(populationLimit); this.chromosomes.addAll(chromosomes); } diff --git a/src/main/java/org/apache/commons/math4/genetics/NPointCrossover.java b/src/main/java/org/apache/commons/math4/genetics/NPointCrossover.java index 720df8af01..5c79ef1f4d 100644 --- a/src/main/java/org/apache/commons/math4/genetics/NPointCrossover.java +++ b/src/main/java/org/apache/commons/math4/genetics/NPointCrossover.java @@ -139,8 +139,8 @@ private ChromosomePair mate(final AbstractListChromosome first, final List parent1Rep = first.getRepresentation(); final List parent2Rep = second.getRepresentation(); // and of the children - final List child1Rep = new ArrayList<>(length); - final List child2Rep = new ArrayList<>(length); + final List child1Rep = new ArrayList(length); + final List child2Rep = new ArrayList(length); final RandomGenerator random = GeneticAlgorithm.getRandomGenerator(); diff --git a/src/main/java/org/apache/commons/math4/genetics/OnePointCrossover.java b/src/main/java/org/apache/commons/math4/genetics/OnePointCrossover.java index 7308043612..0df7313c69 100644 --- a/src/main/java/org/apache/commons/math4/genetics/OnePointCrossover.java +++ b/src/main/java/org/apache/commons/math4/genetics/OnePointCrossover.java @@ -105,8 +105,8 @@ private ChromosomePair crossover(final AbstractListChromosome first, final List parent1Rep = first.getRepresentation(); final List parent2Rep = second.getRepresentation(); // and of the children - final List child1Rep = new ArrayList<>(length); - final List child2Rep = new ArrayList<>(length); + final List child1Rep = new ArrayList(length); + final List child2Rep = new ArrayList(length); // select a crossover point at random (0 and length makes no sense) final int crossoverIndex = 1 + (GeneticAlgorithm.getRandomGenerator().nextInt(length-2)); diff --git a/src/main/java/org/apache/commons/math4/genetics/OrderedCrossover.java b/src/main/java/org/apache/commons/math4/genetics/OrderedCrossover.java index 2ceb299251..b5aecc8f83 100644 --- a/src/main/java/org/apache/commons/math4/genetics/OrderedCrossover.java +++ b/src/main/java/org/apache/commons/math4/genetics/OrderedCrossover.java @@ -97,11 +97,11 @@ protected ChromosomePair mate(final AbstractListChromosome first, final Abstr final List parent1Rep = first.getRepresentation(); final List parent2Rep = second.getRepresentation(); // and of the children - final List child1 = new ArrayList<>(length); - final List child2 = new ArrayList<>(length); + final List child1 = new ArrayList(length); + final List child2 = new ArrayList(length); // sets of already inserted items for quick access - final Set child1Set = new HashSet<>(length); - final Set child2Set = new HashSet<>(length); + final Set child1Set = new HashSet(length); + final Set child2Set = new HashSet(length); final RandomGenerator random = GeneticAlgorithm.getRandomGenerator(); // choose random points, making sure that lb < ub. diff --git a/src/main/java/org/apache/commons/math4/genetics/RandomKey.java b/src/main/java/org/apache/commons/math4/genetics/RandomKey.java index ea0a40119e..8186a5274d 100644 --- a/src/main/java/org/apache/commons/math4/genetics/RandomKey.java +++ b/src/main/java/org/apache/commons/math4/genetics/RandomKey.java @@ -72,7 +72,7 @@ public abstract class RandomKey extends AbstractListChromosome implem public RandomKey(final List representation) throws InvalidRepresentationException { super(representation); // store the sorted representation - List sortedRepr = new ArrayList<> (getRepresentation()); + List sortedRepr = new ArrayList (getRepresentation()); Collections.sort(sortedRepr); sortedRepresentation = Collections.unmodifiableList(sortedRepr); // store the permutation of [0,1,...,n-1] list for toString() and isSame() methods @@ -126,10 +126,10 @@ private static List decodeGeneric(final List sequence, List re } // do not modify the original representation - List reprCopy = new ArrayList<> (representation); + List reprCopy = new ArrayList (representation); // now find the indices in the original repr and use them for permuting - List res = new ArrayList<> (l); + List res = new ArrayList (l); for (int i=0; i chromosomeRepresentation) * @return representation of a random permutation */ public static final List randomPermutation(final int l) { - List repr = new ArrayList<>(l); + List repr = new ArrayList(l); for (int i=0; i randomPermutation(final int l) { * @return representation of an identity permutation */ public static final List identityPermutation(final int l) { - List repr = new ArrayList<>(l); + List repr = new ArrayList(l); for (int i=0; i identityPermutation(final int l) { */ public static List comparatorPermutation(final List data, final Comparator comparator) { - List sortedData = new ArrayList<>(data); + List sortedData = new ArrayList(data); Collections.sort(sortedData, comparator); return inducedPermutation(data, sortedData); @@ -264,7 +264,7 @@ public static List inducedPermutation(final List originalData, } int l = originalData.size(); - List origDataCopy = new ArrayList<> (originalData); + List origDataCopy = new ArrayList (originalData); Double[] res = new Double[l]; for (int i=0; i baseSequence(final int l) { - List baseSequence = new ArrayList<> (l); + List baseSequence = new ArrayList (l); for (int i=0; i repr = originalRk.getRepresentation(); int rInd = GeneticAlgorithm.getRandomGenerator().nextInt(repr.size()); - List newRepr = new ArrayList<> (repr); + List newRepr = new ArrayList (repr); newRepr.set(rInd, GeneticAlgorithm.getRandomGenerator().nextDouble()); return originalRk.newFixedLengthChromosome(newRepr); diff --git a/src/main/java/org/apache/commons/math4/genetics/TournamentSelection.java b/src/main/java/org/apache/commons/math4/genetics/TournamentSelection.java index 0924033031..97becff404 100644 --- a/src/main/java/org/apache/commons/math4/genetics/TournamentSelection.java +++ b/src/main/java/org/apache/commons/math4/genetics/TournamentSelection.java @@ -84,7 +84,7 @@ public Population nextGeneration() { }; // create a copy of the chromosome list - List chromosomes = new ArrayList<> (population.getChromosomes()); + List chromosomes = new ArrayList (population.getChromosomes()); for (int i=0; i first, final List parent1Rep = first.getRepresentation(); final List parent2Rep = second.getRepresentation(); // and of the children - final List child1Rep = new ArrayList<>(length); - final List child2Rep = new ArrayList<>(length); + final List child1Rep = new ArrayList(length); + final List child2Rep = new ArrayList(length); final RandomGenerator random = GeneticAlgorithm.getRandomGenerator(); diff --git a/src/main/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser.java b/src/main/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser.java index b76ff6a9d9..9cd1112781 100644 --- a/src/main/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser.java +++ b/src/main/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser.java @@ -78,8 +78,8 @@ public EnclosingBall enclose(final Iterable

points) { private EnclosingBall pivotingBall(final Iterable

points) { final P first = points.iterator().next(); - final List

extreme = new ArrayList<>(first.getSpace().getDimension() + 1); - final List

support = new ArrayList<>(first.getSpace().getDimension() + 1); + final List

extreme = new ArrayList

(first.getSpace().getDimension() + 1); + final List

support = new ArrayList

(first.getSpace().getDimension() + 1); // start with only first point selected as a candidate support extreme.add(first); diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java index 1b58cd9970..7d944afb45 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java @@ -108,12 +108,12 @@ private static BSPTree buildTree(final double lower, final double u if (Double.isInfinite(lower) && (lower < 0)) { if (Double.isInfinite(upper) && (upper > 0)) { // the tree must cover the whole real line - return new BSPTree<>(Boolean.TRUE); + return new BSPTree(Boolean.TRUE); } // the tree must be open on the negative infinity side final SubHyperplane upperCut = new OrientedPoint(new Vector1D(upper), true, tolerance).wholeHyperplane(); - return new BSPTree<>(upperCut, + return new BSPTree(upperCut, new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null); @@ -122,7 +122,7 @@ private static BSPTree buildTree(final double lower, final double u new OrientedPoint(new Vector1D(lower), false, tolerance).wholeHyperplane(); if (Double.isInfinite(upper) && (upper > 0)) { // the tree must be open on the positive infinity side - return new BSPTree<>(lowerCut, + return new BSPTree(lowerCut, new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null); @@ -131,9 +131,9 @@ private static BSPTree buildTree(final double lower, final double u // the tree must be bounded on the two sides final SubHyperplane upperCut = new OrientedPoint(new Vector1D(upper), true, tolerance).wholeHyperplane(); - return new BSPTree<>(lowerCut, + return new BSPTree(lowerCut, new BSPTree(Boolean.FALSE), - new BSPTree<>(upperCut, + new BSPTree(upperCut, new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null), @@ -222,9 +222,9 @@ public BoundaryProjection projectToBoundary(final Point(point, finiteOrNullPoint(previous), previousOffset); + return new BoundaryProjection(point, finiteOrNullPoint(previous), previousOffset); } else { - return new BoundaryProjection<>(point, finiteOrNullPoint(a[0]), currentOffset); + return new BoundaryProjection(point, finiteOrNullPoint(a[0]), currentOffset); } } else if (x <= a[1]) { // the test point lies within the current interval @@ -232,16 +232,16 @@ public BoundaryProjection projectToBoundary(final Point(point, finiteOrNullPoint(a[1]), offset1); + return new BoundaryProjection(point, finiteOrNullPoint(a[1]), offset1); } else { - return new BoundaryProjection<>(point, finiteOrNullPoint(a[0]), offset0); + return new BoundaryProjection(point, finiteOrNullPoint(a[0]), offset0); } } previous = a[1]; } // the test point if past the last sub-interval - return new BoundaryProjection<>(point, finiteOrNullPoint(previous), x - previous); + return new BoundaryProjection(point, finiteOrNullPoint(previous), x - previous); } @@ -267,7 +267,7 @@ private Vector1D finiteOrNullPoint(final double x) { * elements */ public List asList() { - final List list = new ArrayList<>(); + final List list = new ArrayList(); for (final double[] a : this) { list.add(new Interval(a[0], a[1])); } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/SubOrientedPoint.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/SubOrientedPoint.java index 878c0466e9..a80873d8a0 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/SubOrientedPoint.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/SubOrientedPoint.java @@ -61,11 +61,11 @@ protected AbstractSubHyperplane buildNew(final Hyperpl public SplitSubHyperplane split(final Hyperplane hyperplane) { final double global = hyperplane.getOffset(((OrientedPoint) getHyperplane()).getLocation()); if (global < -1.0e-10) { - return new SplitSubHyperplane<>(null, this); + return new SplitSubHyperplane(null, this); } else if (global > 1.0e-10) { - return new SplitSubHyperplane<>(this, null); + return new SplitSubHyperplane(this, null); } else { - return new SplitSubHyperplane<>(null, null); + return new SplitSubHyperplane(null, null); } } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java index be89ef41be..2dc69337b9 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java @@ -374,9 +374,9 @@ public FieldRotation(final RotationOrder order, final T alpha1, final T alpha2, public FieldRotation(final RotationOrder order, final RotationConvention convention, final T alpha1, final T alpha2, final T alpha3) { final T one = alpha1.getField().getOne(); - final FieldRotation r1 = new FieldRotation<>(new FieldVector3D<>(one, order.getA1()), alpha1, convention); - final FieldRotation r2 = new FieldRotation<>(new FieldVector3D<>(one, order.getA2()), alpha2, convention); - final FieldRotation r3 = new FieldRotation<>(new FieldVector3D<>(one, order.getA3()), alpha3, convention); + final FieldRotation r1 = new FieldRotation(new FieldVector3D(one, order.getA1()), alpha1, convention); + final FieldRotation r2 = new FieldRotation(new FieldVector3D(one, order.getA2()), alpha2, convention); + final FieldRotation r3 = new FieldRotation(new FieldVector3D(one, order.getA3()), alpha3, convention); final FieldRotation composed = r1.compose(r2.compose(r3, convention), convention); q0 = composed.q0; q1 = composed.q1; @@ -453,7 +453,7 @@ private T[] mat2quat(final T[][] ort) { * of the instance */ public FieldRotation revert() { - return new FieldRotation<>(q0.negate(), q1, q2, q3, false); + return new FieldRotation(q0.negate(), q1, q2, q3, false); } /** Get the scalar coordinate of the quaternion. @@ -509,17 +509,17 @@ public FieldVector3D getAxis(final RotationConvention convention) { final T squaredSine = q1.multiply(q1).add(q2.multiply(q2)).add(q3.multiply(q3)); if (squaredSine.getReal() == 0) { final Field field = squaredSine.getField(); - return new FieldVector3D<>(convention == RotationConvention.VECTOR_OPERATOR ? field.getOne(): field.getOne().negate(), + return new FieldVector3D(convention == RotationConvention.VECTOR_OPERATOR ? field.getOne(): field.getOne().negate(), field.getZero(), field.getZero()); } else { final double sgn = convention == RotationConvention.VECTOR_OPERATOR ? +1 : -1; if (q0.getReal() < 0) { T inverse = squaredSine.sqrt().reciprocal().multiply(sgn); - return new FieldVector3D<>(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse)); + return new FieldVector3D(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse)); } final T inverse = squaredSine.sqrt().reciprocal().negate().multiply(sgn); - return new FieldVector3D<>(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse)); + return new FieldVector3D(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse)); } } @@ -1032,7 +1032,7 @@ private T[] buildArray(final T a0, final T a1, final T a2) { */ private FieldVector3D vector(final double x, final double y, final double z) { final T zero = q0.getField().getZero(); - return new FieldVector3D<>(zero.add(x), zero.add(y), zero.add(z)); + return new FieldVector3D(zero.add(x), zero.add(y), zero.add(z)); } /** Get the 3X3 matrix corresponding to the instance @@ -1090,7 +1090,7 @@ public FieldVector3D applyTo(final FieldVector3D u) { final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z)); - return new FieldVector3D<>(q0.multiply(x.multiply(q0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), + return new FieldVector3D(q0.multiply(x.multiply(q0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), q0.multiply(y.multiply(q0).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y), q0.multiply(z.multiply(q0).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z)); @@ -1108,7 +1108,7 @@ public FieldVector3D applyTo(final Vector3D u) { final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z)); - return new FieldVector3D<>(q0.multiply(q0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), + return new FieldVector3D(q0.multiply(q0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), q0.multiply(q0.multiply(y).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y), q0.multiply(q0.multiply(z).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z)); @@ -1165,7 +1165,7 @@ public static > FieldVector3D applyTo(final Rot final T s = x.multiply(r.getQ1()).add(y.multiply(r.getQ2())).add(z.multiply(r.getQ3())); - return new FieldVector3D<>(x.multiply(r.getQ0()).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(r.getQ0()).add(s.multiply(r.getQ1())).multiply(2).subtract(x), + return new FieldVector3D(x.multiply(r.getQ0()).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(r.getQ0()).add(s.multiply(r.getQ1())).multiply(2).subtract(x), y.multiply(r.getQ0()).subtract(x.multiply(r.getQ3()).subtract(z.multiply(r.getQ1()))).multiply(r.getQ0()).add(s.multiply(r.getQ2())).multiply(2).subtract(y), z.multiply(r.getQ0()).subtract(y.multiply(r.getQ1()).subtract(x.multiply(r.getQ2()))).multiply(r.getQ0()).add(s.multiply(r.getQ3())).multiply(2).subtract(z)); @@ -1184,7 +1184,7 @@ public FieldVector3D applyInverseTo(final FieldVector3D u) { final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z)); final T m0 = q0.negate(); - return new FieldVector3D<>(m0.multiply(x.multiply(m0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), + return new FieldVector3D(m0.multiply(x.multiply(m0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), m0.multiply(y.multiply(m0).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y), m0.multiply(z.multiply(m0).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z)); @@ -1203,7 +1203,7 @@ public FieldVector3D applyInverseTo(final Vector3D u) { final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z)); final T m0 = q0.negate(); - return new FieldVector3D<>(m0.multiply(m0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), + return new FieldVector3D(m0.multiply(m0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), m0.multiply(m0.multiply(y).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y), m0.multiply(m0.multiply(z).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z)); @@ -1263,7 +1263,7 @@ public static > FieldVector3D applyInverseTo(fi final T s = x.multiply(r.getQ1()).add(y.multiply(r.getQ2())).add(z.multiply(r.getQ3())); final double m0 = -r.getQ0(); - return new FieldVector3D<>(x.multiply(m0).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(m0).add(s.multiply(r.getQ1())).multiply(2).subtract(x), + return new FieldVector3D(x.multiply(m0).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(m0).add(s.multiply(r.getQ1())).multiply(2).subtract(x), y.multiply(m0).subtract(x.multiply(r.getQ3()).subtract(z.multiply(r.getQ1()))).multiply(m0).add(s.multiply(r.getQ2())).multiply(2).subtract(y), z.multiply(m0).subtract(y.multiply(r.getQ1()).subtract(x.multiply(r.getQ2()))).multiply(m0).add(s.multiply(r.getQ3())).multiply(2).subtract(z)); @@ -1317,7 +1317,7 @@ public FieldRotation compose(final FieldRotation r, final RotationConventi * using vector operator convention */ private FieldRotation composeInternal(final FieldRotation r) { - return new FieldRotation<>(r.q0.multiply(q0).subtract(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))), + return new FieldRotation(r.q0.multiply(q0).subtract(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))), r.q1.multiply(q0).add(r.q0.multiply(q1)).add(r.q2.multiply(q3).subtract(r.q3.multiply(q2))), r.q2.multiply(q0).add(r.q0.multiply(q2)).add(r.q3.multiply(q1).subtract(r.q1.multiply(q3))), r.q3.multiply(q0).add(r.q0.multiply(q3)).add(r.q1.multiply(q2).subtract(r.q2.multiply(q1))), @@ -1372,7 +1372,7 @@ public FieldRotation compose(final Rotation r, final RotationConvention conve * using vector operator convention */ private FieldRotation composeInternal(final Rotation r) { - return new FieldRotation<>(q0.multiply(r.getQ0()).subtract(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))), + return new FieldRotation(q0.multiply(r.getQ0()).subtract(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))), q0.multiply(r.getQ1()).add(q1.multiply(r.getQ0())).add(q3.multiply(r.getQ2()).subtract(q2.multiply(r.getQ3()))), q0.multiply(r.getQ2()).add(q2.multiply(r.getQ0())).add(q1.multiply(r.getQ3()).subtract(q3.multiply(r.getQ1()))), q0.multiply(r.getQ3()).add(q3.multiply(r.getQ0())).add(q2.multiply(r.getQ1()).subtract(q1.multiply(r.getQ2()))), @@ -1391,7 +1391,7 @@ private FieldRotation composeInternal(final Rotation r) { * @return a new rotation which is the composition of r by the instance */ public static > FieldRotation applyTo(final Rotation r1, final FieldRotation rInner) { - return new FieldRotation<>(rInner.q0.multiply(r1.getQ0()).subtract(rInner.q1.multiply(r1.getQ1()).add(rInner.q2.multiply(r1.getQ2())).add(rInner.q3.multiply(r1.getQ3()))), + return new FieldRotation(rInner.q0.multiply(r1.getQ0()).subtract(rInner.q1.multiply(r1.getQ1()).add(rInner.q2.multiply(r1.getQ2())).add(rInner.q3.multiply(r1.getQ3()))), rInner.q1.multiply(r1.getQ0()).add(rInner.q0.multiply(r1.getQ1())).add(rInner.q2.multiply(r1.getQ3()).subtract(rInner.q3.multiply(r1.getQ2()))), rInner.q2.multiply(r1.getQ0()).add(rInner.q0.multiply(r1.getQ2())).add(rInner.q3.multiply(r1.getQ1()).subtract(rInner.q1.multiply(r1.getQ3()))), rInner.q3.multiply(r1.getQ0()).add(rInner.q0.multiply(r1.getQ3())).add(rInner.q1.multiply(r1.getQ2()).subtract(rInner.q2.multiply(r1.getQ1()))), @@ -1450,7 +1450,7 @@ public FieldRotation composeInverse(final FieldRotation r, final RotationC * of the instance using vector operator convention */ private FieldRotation composeInverseInternal(FieldRotation r) { - return new FieldRotation<>(r.q0.multiply(q0).add(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))).negate(), + return new FieldRotation(r.q0.multiply(q0).add(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))).negate(), r.q0.multiply(q1).add(r.q2.multiply(q3).subtract(r.q3.multiply(q2))).subtract(r.q1.multiply(q0)), r.q0.multiply(q2).add(r.q3.multiply(q1).subtract(r.q1.multiply(q3))).subtract(r.q2.multiply(q0)), r.q0.multiply(q3).add(r.q1.multiply(q2).subtract(r.q2.multiply(q1))).subtract(r.q3.multiply(q0)), @@ -1509,7 +1509,7 @@ public FieldRotation composeInverse(final Rotation r, final RotationConventio * of the instance using vector operator convention */ private FieldRotation composeInverseInternal(Rotation r) { - return new FieldRotation<>(q0.multiply(r.getQ0()).add(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))).negate(), + return new FieldRotation(q0.multiply(r.getQ0()).add(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))).negate(), q1.multiply(r.getQ0()).add(q3.multiply(r.getQ2()).subtract(q2.multiply(r.getQ3()))).subtract(q0.multiply(r.getQ1())), q2.multiply(r.getQ0()).add(q1.multiply(r.getQ3()).subtract(q3.multiply(r.getQ1()))).subtract(q0.multiply(r.getQ2())), q3.multiply(r.getQ0()).add(q2.multiply(r.getQ1()).subtract(q1.multiply(r.getQ2()))).subtract(q0.multiply(r.getQ3())), @@ -1530,7 +1530,7 @@ private FieldRotation composeInverseInternal(Rotation r) { * of the instance */ public static > FieldRotation applyInverseTo(final Rotation rOuter, final FieldRotation rInner) { - return new FieldRotation<>(rInner.q0.multiply(rOuter.getQ0()).add(rInner.q1.multiply(rOuter.getQ1()).add(rInner.q2.multiply(rOuter.getQ2())).add(rInner.q3.multiply(rOuter.getQ3()))).negate(), + return new FieldRotation(rInner.q0.multiply(rOuter.getQ0()).add(rInner.q1.multiply(rOuter.getQ1()).add(rInner.q2.multiply(rOuter.getQ2())).add(rInner.q3.multiply(rOuter.getQ3()))).negate(), rInner.q0.multiply(rOuter.getQ1()).add(rInner.q2.multiply(rOuter.getQ3()).subtract(rInner.q3.multiply(rOuter.getQ2()))).subtract(rInner.q1.multiply(rOuter.getQ0())), rInner.q0.multiply(rOuter.getQ2()).add(rInner.q3.multiply(rOuter.getQ1()).subtract(rInner.q1.multiply(rOuter.getQ3()))).subtract(rInner.q2.multiply(rOuter.getQ0())), rInner.q0.multiply(rOuter.getQ3()).add(rInner.q1.multiply(rOuter.getQ2()).subtract(rInner.q2.multiply(rOuter.getQ1()))).subtract(rInner.q3.multiply(rOuter.getQ0())), diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java index bec2d74e8d..f03a1ececa 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java @@ -408,7 +408,7 @@ public T getDelta() { * @return a new vector */ public FieldVector3D add(final FieldVector3D v) { - return new FieldVector3D<>(x.add(v.x), y.add(v.y), z.add(v.z)); + return new FieldVector3D(x.add(v.x), y.add(v.y), z.add(v.z)); } /** Add a vector to the instance. @@ -416,7 +416,7 @@ public FieldVector3D add(final FieldVector3D v) { * @return a new vector */ public FieldVector3D add(final Vector3D v) { - return new FieldVector3D<>(x.add(v.getX()), y.add(v.getY()), z.add(v.getZ())); + return new FieldVector3D(x.add(v.getX()), y.add(v.getY()), z.add(v.getZ())); } /** Add a scaled vector to the instance. @@ -425,7 +425,7 @@ public FieldVector3D add(final Vector3D v) { * @return a new vector */ public FieldVector3D add(final T factor, final FieldVector3D v) { - return new FieldVector3D<>(x.getField().getOne(), this, factor, v); + return new FieldVector3D(x.getField().getOne(), this, factor, v); } /** Add a scaled vector to the instance. @@ -434,7 +434,7 @@ public FieldVector3D add(final T factor, final FieldVector3D v) { * @return a new vector */ public FieldVector3D add(final T factor, final Vector3D v) { - return new FieldVector3D<>(x.add(factor.multiply(v.getX())), + return new FieldVector3D(x.add(factor.multiply(v.getX())), y.add(factor.multiply(v.getY())), z.add(factor.multiply(v.getZ()))); } @@ -445,7 +445,7 @@ public FieldVector3D add(final T factor, final Vector3D v) { * @return a new vector */ public FieldVector3D add(final double factor, final FieldVector3D v) { - return new FieldVector3D<>(1.0, this, factor, v); + return new FieldVector3D(1.0, this, factor, v); } /** Add a scaled vector to the instance. @@ -454,7 +454,7 @@ public FieldVector3D add(final double factor, final FieldVector3D v) { * @return a new vector */ public FieldVector3D add(final double factor, final Vector3D v) { - return new FieldVector3D<>(x.add(factor * v.getX()), + return new FieldVector3D(x.add(factor * v.getX()), y.add(factor * v.getY()), z.add(factor * v.getZ())); } @@ -464,7 +464,7 @@ public FieldVector3D add(final double factor, final Vector3D v) { * @return a new vector */ public FieldVector3D subtract(final FieldVector3D v) { - return new FieldVector3D<>(x.subtract(v.x), y.subtract(v.y), z.subtract(v.z)); + return new FieldVector3D(x.subtract(v.x), y.subtract(v.y), z.subtract(v.z)); } /** Subtract a vector from the instance. @@ -472,7 +472,7 @@ public FieldVector3D subtract(final FieldVector3D v) { * @return a new vector */ public FieldVector3D subtract(final Vector3D v) { - return new FieldVector3D<>(x.subtract(v.getX()), y.subtract(v.getY()), z.subtract(v.getZ())); + return new FieldVector3D(x.subtract(v.getX()), y.subtract(v.getY()), z.subtract(v.getZ())); } /** Subtract a scaled vector from the instance. @@ -481,7 +481,7 @@ public FieldVector3D subtract(final Vector3D v) { * @return a new vector */ public FieldVector3D subtract(final T factor, final FieldVector3D v) { - return new FieldVector3D<>(x.getField().getOne(), this, factor.negate(), v); + return new FieldVector3D(x.getField().getOne(), this, factor.negate(), v); } /** Subtract a scaled vector from the instance. @@ -490,7 +490,7 @@ public FieldVector3D subtract(final T factor, final FieldVector3D v) { * @return a new vector */ public FieldVector3D subtract(final T factor, final Vector3D v) { - return new FieldVector3D<>(x.subtract(factor.multiply(v.getX())), + return new FieldVector3D(x.subtract(factor.multiply(v.getX())), y.subtract(factor.multiply(v.getY())), z.subtract(factor.multiply(v.getZ()))); } @@ -501,7 +501,7 @@ public FieldVector3D subtract(final T factor, final Vector3D v) { * @return a new vector */ public FieldVector3D subtract(final double factor, final FieldVector3D v) { - return new FieldVector3D<>(1.0, this, -factor, v); + return new FieldVector3D(1.0, this, -factor, v); } /** Subtract a scaled vector from the instance. @@ -510,7 +510,7 @@ public FieldVector3D subtract(final double factor, final FieldVector3D v) * @return a new vector */ public FieldVector3D subtract(final double factor, final Vector3D v) { - return new FieldVector3D<>(x.subtract(factor * v.getX()), + return new FieldVector3D(x.subtract(factor * v.getX()), y.subtract(factor * v.getY()), z.subtract(factor * v.getZ())); } @@ -551,13 +551,13 @@ public FieldVector3D orthogonal() throws MathArithmeticException { if (FastMath.abs(x.getReal()) <= threshold) { final T inverse = y.multiply(y).add(z.multiply(z)).sqrt().reciprocal(); - return new FieldVector3D<>(inverse.getField().getZero(), inverse.multiply(z), inverse.multiply(y).negate()); + return new FieldVector3D(inverse.getField().getZero(), inverse.multiply(z), inverse.multiply(y).negate()); } else if (FastMath.abs(y.getReal()) <= threshold) { final T inverse = x.multiply(x).add(z.multiply(z)).sqrt().reciprocal(); - return new FieldVector3D<>(inverse.multiply(z).negate(), inverse.getField().getZero(), inverse.multiply(x)); + return new FieldVector3D(inverse.multiply(z).negate(), inverse.getField().getZero(), inverse.multiply(x)); } else { final T inverse = x.multiply(x).add(y.multiply(y)).sqrt().reciprocal(); - return new FieldVector3D<>(inverse.multiply(y), inverse.multiply(x).negate(), inverse.getField().getZero()); + return new FieldVector3D(inverse.multiply(y), inverse.multiply(x).negate(), inverse.getField().getZero()); } } @@ -655,7 +655,7 @@ public static > T angle(final Vector3D v1, final F * @return a new vector which is opposite to the instance */ public FieldVector3D negate() { - return new FieldVector3D<>(x.negate(), y.negate(), z.negate()); + return new FieldVector3D(x.negate(), y.negate(), z.negate()); } /** Multiply the instance by a scalar. @@ -663,7 +663,7 @@ public FieldVector3D negate() { * @return a new vector */ public FieldVector3D scalarMultiply(final T a) { - return new FieldVector3D<>(x.multiply(a), y.multiply(a), z.multiply(a)); + return new FieldVector3D(x.multiply(a), y.multiply(a), z.multiply(a)); } /** Multiply the instance by a scalar. @@ -671,7 +671,7 @@ public FieldVector3D scalarMultiply(final T a) { * @return a new vector */ public FieldVector3D scalarMultiply(final double a) { - return new FieldVector3D<>(x.multiply(a), y.multiply(a), z.multiply(a)); + return new FieldVector3D(x.multiply(a), y.multiply(a), z.multiply(a)); } /** @@ -779,7 +779,7 @@ public T dotProduct(final Vector3D v) { * @return the cross product this ^ v as a new Vector3D */ public FieldVector3D crossProduct(final FieldVector3D v) { - return new FieldVector3D<>(x.linearCombination(y, v.z, z.negate(), v.y), + return new FieldVector3D(x.linearCombination(y, v.z, z.negate(), v.y), y.linearCombination(z, v.x, x.negate(), v.z), z.linearCombination(x, v.y, y.negate(), v.x)); } @@ -789,7 +789,7 @@ public FieldVector3D crossProduct(final FieldVector3D v) { * @return the cross product this ^ v as a new Vector3D */ public FieldVector3D crossProduct(final Vector3D v) { - return new FieldVector3D<>(x.linearCombination(v.getZ(), y, -v.getY(), z), + return new FieldVector3D(x.linearCombination(v.getZ(), y, -v.getY(), z), y.linearCombination(v.getX(), z, -v.getZ(), x), z.linearCombination(v.getY(), x, -v.getX(), y)); } @@ -993,7 +993,7 @@ public static > FieldVector3D crossProduct(fina */ public static > FieldVector3D crossProduct(final Vector3D v1, final FieldVector3D v2) { - return new FieldVector3D<>(v2.x.linearCombination(v1.getY(), v2.z, -v1.getZ(), v2.y), + return new FieldVector3D(v2.x.linearCombination(v1.getY(), v2.z, -v1.getZ(), v2.y), v2.y.linearCombination(v1.getZ(), v2.x, -v1.getX(), v2.z), v2.z.linearCombination(v1.getX(), v2.y, -v1.getY(), v2.x)); } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java index 67abdd1999..a5018134d4 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java @@ -203,7 +203,7 @@ private void addContribution(final SubHyperplane facet, final boole } // compute the projection of the facet in the outline plane - final ArrayList> edges = new ArrayList<>(); + final ArrayList> edges = new ArrayList>(); for (Vector2D[] loop : vertices) { final boolean closed = loop[0] != null; int previous = closed ? (loop.length - 1) : 1; diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java index b99c9c224d..095d6d5c59 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java @@ -162,7 +162,7 @@ private static BSPTree buildBoundary(final double xMin, final doubl final double tolerance) { if ((xMin >= xMax - tolerance) || (yMin >= yMax - tolerance) || (zMin >= zMax - tolerance)) { // too thin box, build an empty polygons set - return new BSPTree<>(Boolean.FALSE); + return new BSPTree(Boolean.FALSE); } final Plane pxMin = new Plane(new Vector3D(xMin, 0, 0), Vector3D.MINUS_I, tolerance); final Plane pxMax = new Plane(new Vector3D(xMax, 0, 0), Vector3D.PLUS_I, tolerance); @@ -226,7 +226,7 @@ private static List> buildBoundary(final List> boundary = new ArrayList<>(); + final List> boundary = new ArrayList>(); for (final int[] facet : facets) { diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java index deef1e9118..f28a76299b 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java @@ -37,15 +37,15 @@ public class SphereGenerator implements SupportBallGenerator ballOnSupport(final List support) { if (support.size() < 1) { - return new EnclosingBall<>(Vector3D.ZERO, Double.NEGATIVE_INFINITY); + return new EnclosingBall(Vector3D.ZERO, Double.NEGATIVE_INFINITY); } else { final Vector3D vA = support.get(0); if (support.size() < 2) { - return new EnclosingBall<>(vA, 0, vA); + return new EnclosingBall(vA, 0, vA); } else { final Vector3D vB = support.get(1); if (support.size() < 3) { - return new EnclosingBall<>(new Vector3D(0.5, vA, 0.5, vB), + return new EnclosingBall(new Vector3D(0.5, vA, 0.5, vB), 0.5 * vA.distance(vB), vA, vB); } else { @@ -61,7 +61,7 @@ public EnclosingBall ballOnSupport(final List s p.toSubSpace(vC))); // convert back to 3D - return new EnclosingBall<>(p.toSpace(disk.getCenter()), + return new EnclosingBall(p.toSpace(disk.getCenter()), disk.getRadius(), vA, vB, vC); } else { @@ -118,7 +118,7 @@ public EnclosingBall ballOnSupport(final List s final BigFraction dy = c3[0].subtract(centerY); final BigFraction dz = c4[0].subtract(centerZ); final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy)).add(dz.multiply(dz)); - return new EnclosingBall<>(new Vector3D(centerX.doubleValue(), + return new EnclosingBall(new Vector3D(centerX.doubleValue(), centerY.doubleValue(), centerZ.doubleValue()), FastMath.sqrt(r2.doubleValue()), diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java index 61499d9e54..ae3dc4a5ad 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java @@ -85,7 +85,7 @@ public SubLine(final Segment segment) throws MathIllegalArgumentException { public List getSegments() { final List list = remainingRegion.asList(); - final List segments = new ArrayList<>(list.size()); + final List segments = new ArrayList(list.size()); for (final Interval interval : list) { final Vector3D start = line.toSpace((Point) new Vector1D(interval.getInf())); diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java index 0c89584492..89885d4b26 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java @@ -67,11 +67,11 @@ public SplitSubHyperplane split(Hyperplane hyperplane) // the hyperplanes are parallel final double global = otherPlane.getOffset(thisPlane); if (global < -tolerance) { - return new SplitSubHyperplane<>(null, this); + return new SplitSubHyperplane(null, this); } else if (global > tolerance) { - return new SplitSubHyperplane<>(this, null); + return new SplitSubHyperplane(this, null); } else { - return new SplitSubHyperplane<>(null, null); + return new SplitSubHyperplane(null, null); } } @@ -92,15 +92,15 @@ public SplitSubHyperplane split(Hyperplane hyperplane) final BSPTree splitTree = getRemainingRegion().getTree(false).split(l2DMinus); final BSPTree plusTree = getRemainingRegion().isEmpty(splitTree.getPlus()) ? new BSPTree(Boolean.FALSE) : - new BSPTree<>(l2DPlus, new BSPTree(Boolean.FALSE), + new BSPTree(l2DPlus, new BSPTree(Boolean.FALSE), splitTree.getPlus(), null); final BSPTree minusTree = getRemainingRegion().isEmpty(splitTree.getMinus()) ? new BSPTree(Boolean.FALSE) : - new BSPTree<>(l2DMinus, new BSPTree(Boolean.FALSE), + new BSPTree(l2DMinus, new BSPTree(Boolean.FALSE), splitTree.getMinus(), null); - return new SplitSubHyperplane<>(new SubPlane(thisPlane.copySelf(), new PolygonsSet(plusTree, tolerance)), + return new SplitSubHyperplane(new SubPlane(thisPlane.copySelf(), new PolygonsSet(plusTree, tolerance)), new SubPlane(thisPlane.copySelf(), new PolygonsSet(minusTree, tolerance))); } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java index a19a8768ab..4cc3546f6b 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java @@ -33,15 +33,15 @@ public class DiskGenerator implements SupportBallGenerator ballOnSupport(final List support) { if (support.size() < 1) { - return new EnclosingBall<>(Vector2D.ZERO, Double.NEGATIVE_INFINITY); + return new EnclosingBall(Vector2D.ZERO, Double.NEGATIVE_INFINITY); } else { final Vector2D vA = support.get(0); if (support.size() < 2) { - return new EnclosingBall<>(vA, 0, vA); + return new EnclosingBall(vA, 0, vA); } else { final Vector2D vB = support.get(1); if (support.size() < 3) { - return new EnclosingBall<>(new Vector2D(0.5, vA, 0.5, vB), + return new EnclosingBall(new Vector2D(0.5, vA, 0.5, vB), 0.5 * vA.distance(vB), vA, vB); } else { @@ -86,7 +86,7 @@ public EnclosingBall ballOnSupport(final List s final BigFraction dx = c2[0].subtract(centerX); final BigFraction dy = c3[0].subtract(centerY); final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy)); - return new EnclosingBall<>(new Vector2D(centerX.doubleValue(), + return new EnclosingBall(new Vector2D(centerX.doubleValue(), centerY.doubleValue()), FastMath.sqrt(r2.doubleValue()), vA, vB, vC); diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java index a967fb6de5..cb3a2be970 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java @@ -71,7 +71,7 @@ class NestedLoops { * @since 3.3 */ NestedLoops(final double tolerance) { - this.surrounded = new ArrayList<>(); + this.surrounded = new ArrayList(); this.tolerance = tolerance; } @@ -90,11 +90,11 @@ private NestedLoops(final Vector2D[] loop, final double tolerance) } this.loop = loop; - this.surrounded = new ArrayList<>(); + this.surrounded = new ArrayList(); this.tolerance = tolerance; // build the polygon defined by the loop - final ArrayList> edges = new ArrayList<>(); + final ArrayList> edges = new ArrayList>(); Vector2D current = loop[loop.length - 1]; for (int i = 0; i < loop.length; ++i) { final Vector2D previous = current; @@ -152,7 +152,7 @@ private void add(final NestedLoops node) throws MathIllegalArgumentException { } // we should be separate from the remaining children - RegionFactory factory = new RegionFactory<>(); + RegionFactory factory = new RegionFactory(); for (final NestedLoops child : surrounded) { if (!factory.intersection(node.polygon, child.polygon).isEmpty()) { throw new MathIllegalArgumentException(LocalizedFormats.CROSSING_BOUNDARY_LOOPS); diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java index 38b94f4938..6dcf2cd95f 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java @@ -199,7 +199,7 @@ private static BSPTree verticesToTree(final double hyperplaneThickn final int n = vertices.length; if (n == 0) { // the tree represents the whole space - return new BSPTree<>(Boolean.TRUE); + return new BSPTree(Boolean.TRUE); } // build the vertices @@ -209,7 +209,7 @@ private static BSPTree verticesToTree(final double hyperplaneThickn } // build the edges - List edges = new ArrayList<>(n); + List edges = new ArrayList(n); for (int i = 0; i < n; ++i) { // get the endpoints of the edge @@ -238,7 +238,7 @@ private static BSPTree verticesToTree(final double hyperplaneThickn } // build the tree top-down - final BSPTree tree = new BSPTree<>(); + final BSPTree tree = new BSPTree(); insertEdges(hyperplaneThickness, tree, edges); return tree; @@ -287,8 +287,8 @@ private static void insertEdges(final double hyperplaneThickness, // we have split the node by inserting an edge as a cut sub-hyperplane // distribute the remaining edges in the two sub-trees - final List plusList = new ArrayList<>(); - final List minusList = new ArrayList<>(); + final List plusList = new ArrayList(); + final List minusList = new ArrayList(); for (final Edge edge : edges) { if (edge != inserted) { final double startOffset = inserted.getLine().getOffset((Point) edge.getStart().getLocation()); @@ -365,7 +365,7 @@ private static class Vertex { this.location = location; this.incoming = null; this.outgoing = null; - this.lines = new ArrayList<>(); + this.lines = new ArrayList(); } /** Get Vertex location. @@ -640,7 +640,7 @@ public Vector2D[][] getVertices() { } // create the segment loops - final ArrayList> loops = new ArrayList<>(); + final ArrayList> loops = new ArrayList>(); for (ConnectableSegment s = getUnprocessed(segments); s != null; s = getUnprocessed(segments)) { final List loop = followLoop(s); if (loop != null) { @@ -824,7 +824,7 @@ private ConnectableSegment getUnprocessed(final List segment */ private List followLoop(final ConnectableSegment defining) { - final List loop = new ArrayList<>(); + final List loop = new ArrayList(); loop.add(defining); defining.setProcessed(true); @@ -998,7 +998,7 @@ private static class SegmentsBuilder implements BSPTreeVisitor { */ SegmentsBuilder(final double tolerance) { this.tolerance = tolerance; - this.segments = new ArrayList<>(); + this.segments = new ArrayList(); } /** {@inheritDoc} */ diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java index eb247605e3..4f53e6c91e 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java @@ -83,7 +83,7 @@ public List getSegments() { final Line line = (Line) getHyperplane(); final List list = ((IntervalsSet) getRemainingRegion()).asList(); - final List segments = new ArrayList<>(list.size()); + final List segments = new ArrayList(list.size()); for (final Interval interval : list) { final Vector2D start = line.toSpace((Point) new Vector1D(interval.getInf())); @@ -168,11 +168,11 @@ public SplitSubHyperplane split(final Hyperplane hyper // the lines are parallel final double global = otherLine.getOffset(thisLine); if (global < -tolerance) { - return new SplitSubHyperplane<>(null, this); + return new SplitSubHyperplane(null, this); } else if (global > tolerance) { - return new SplitSubHyperplane<>(this, null); + return new SplitSubHyperplane(this, null); } else { - return new SplitSubHyperplane<>(null, null); + return new SplitSubHyperplane(null, null); } } @@ -187,13 +187,13 @@ public SplitSubHyperplane split(final Hyperplane hyper final BSPTree splitTree = getRemainingRegion().getTree(false).split(subMinus); final BSPTree plusTree = getRemainingRegion().isEmpty(splitTree.getPlus()) ? new BSPTree(Boolean.FALSE) : - new BSPTree<>(subPlus, new BSPTree(Boolean.FALSE), + new BSPTree(subPlus, new BSPTree(Boolean.FALSE), splitTree.getPlus(), null); final BSPTree minusTree = getRemainingRegion().isEmpty(splitTree.getMinus()) ? new BSPTree(Boolean.FALSE) : - new BSPTree<>(subMinus, new BSPTree(Boolean.FALSE), + new BSPTree(subMinus, new BSPTree(Boolean.FALSE), splitTree.getMinus(), null); - return new SplitSubHyperplane<>(new SubLine(thisLine.copySelf(), new IntervalsSet(plusTree, tolerance)), + return new SplitSubHyperplane(new SubLine(thisLine.copySelf(), new IntervalsSet(plusTree, tolerance)), new SubLine(thisLine.copySelf(), new IntervalsSet(minusTree, tolerance))); } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java index 84be4ac399..2388db0509 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java @@ -84,7 +84,7 @@ public static Collection reducePoints(final Collection point return points; } - final List reducedPoints = new ArrayList<>(quadrilateral); + final List reducedPoints = new ArrayList(quadrilateral); for (final Vector2D p : points) { // check all points if they are within the quadrilateral // in which case they can not be part of the convex hull @@ -103,7 +103,7 @@ public static Collection reducePoints(final Collection point * @return the quadrilateral */ private static List buildQuadrilateral(final Vector2D... points) { - List quadrilateral = new ArrayList<>(); + List quadrilateral = new ArrayList(); for (Vector2D p : points) { if (!quadrilateral.contains(p)) { quadrilateral.add(p); diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java index 7356da12fe..b973e13c30 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java @@ -163,7 +163,7 @@ public Region createRegion() throws InsufficientDataException { if (vertices.length < 3) { throw new InsufficientDataException(); } - final RegionFactory factory = new RegionFactory<>(); + final RegionFactory factory = new RegionFactory(); final Segment[] segments = retrieveLineSegments(); final Line[] lineArray = new Line[segments.length]; for (int i = 0; i < segments.length; i++) { diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java index 5746c7f179..39caa99350 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java @@ -77,7 +77,7 @@ public MonotoneChain(final boolean includeCollinearPoints, final double toleranc @Override public Collection findHullVertices(final Collection points) { - final List pointsSortedByXAxis = new ArrayList<>(points); + final List pointsSortedByXAxis = new ArrayList(points); // sort the points in increasing order on the x-axis Collections.sort(pointsSortedByXAxis, new Comparator() { @@ -97,13 +97,13 @@ public int compare(final Vector2D o1, final Vector2D o2) { }); // build lower hull - final List lowerHull = new ArrayList<>(); + final List lowerHull = new ArrayList(); for (Vector2D p : pointsSortedByXAxis) { updateHull(p, lowerHull); } // build upper hull - final List upperHull = new ArrayList<>(); + final List upperHull = new ArrayList(); for (int idx = pointsSortedByXAxis.size() - 1; idx >= 0; idx--) { final Vector2D p = pointsSortedByXAxis.get(idx); updateHull(p, upperHull); @@ -111,7 +111,7 @@ public int compare(final Vector2D o1, final Vector2D o2) { // concatenate the lower and upper hulls // the last point of each list is omitted as it is repeated at the beginning of the other list - final List hullVertices = new ArrayList<>(lowerHull.size() + upperHull.size() - 2); + final List hullVertices = new ArrayList(lowerHull.size() + upperHull.size() - 2); for (int idx = 0; idx < lowerHull.size() - 1; idx++) { hullVertices.add(lowerHull.get(idx)); } diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java index 9463bb832b..57d2c648f0 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java @@ -53,7 +53,7 @@ public abstract class AbstractRegion implement * @param tolerance tolerance below which points are considered identical. */ protected AbstractRegion(final double tolerance) { - this.tree = new BSPTree<>(Boolean.TRUE); + this.tree = new BSPTree(Boolean.TRUE); this.tolerance = tolerance; } @@ -102,14 +102,14 @@ protected AbstractRegion(final Collection> boundary, final doub if (boundary.size() == 0) { // the tree represents the whole space - tree = new BSPTree<>(Boolean.TRUE); + tree = new BSPTree(Boolean.TRUE); } else { // sort the boundary elements in decreasing size order // (we don't want equal size elements to be removed, so // we use a trick to fool the TreeSet) - final TreeSet> ordered = new TreeSet<>(new Comparator>() { + final TreeSet> ordered = new TreeSet>(new Comparator>() { /** {@inheritDoc} */ @Override public int compare(final SubHyperplane o1, final SubHyperplane o2) { @@ -121,7 +121,7 @@ public int compare(final SubHyperplane o1, final SubHyperplane o2) { ordered.addAll(boundary); // build the tree top-down - tree = new BSPTree<>(); + tree = new BSPTree(); insertCuts(tree, ordered); // set up the inside/outside flags @@ -161,7 +161,7 @@ public void visitLeafNode(final BSPTree node) { public AbstractRegion(final Hyperplane[] hyperplanes, final double tolerance) { this.tolerance = tolerance; if ((hyperplanes == null) || (hyperplanes.length == 0)) { - tree = new BSPTree<>(Boolean.FALSE); + tree = new BSPTree(Boolean.FALSE); } else { // use the first hyperplane to build the right class @@ -218,8 +218,8 @@ private void insertCuts(final BSPTree node, final Collection } // distribute the remaining edges in the two sub-trees - final ArrayList> plusList = new ArrayList<>(); - final ArrayList> minusList = new ArrayList<>(); + final ArrayList> plusList = new ArrayList>(); + final ArrayList> minusList = new ArrayList>(); while (iterator.hasNext()) { final SubHyperplane other = iterator.next(); final SubHyperplane.SplitSubHyperplane split = other.split(inserted); @@ -310,7 +310,7 @@ public boolean contains(final Region region) { */ @Override public BoundaryProjection projectToBoundary(final Point point) { - final BoundaryProjector projector = new BoundaryProjector<>(point); + final BoundaryProjector projector = new BoundaryProjector(point); getTree(true).visit(projector); return projector.getProjection(); } @@ -376,7 +376,7 @@ public BSPTree getTree(final boolean includeBoundaryAttributes) { /** {@inheritDoc} */ @Override public double getBoundarySize() { - final BoundarySizeVisitor visitor = new BoundarySizeVisitor<>(); + final BoundarySizeVisitor visitor = new BoundarySizeVisitor(); getTree(true).visit(visitor); return visitor.getSize(); } @@ -485,7 +485,7 @@ private SubHyperplane recurseIntersection(final BSPTree node, final SubHyp public AbstractRegion applyTransform(final Transform transform) { // transform the tree, except for boundary attribute splitters - final Map, BSPTree> map = new HashMap<>(); + final Map, BSPTree> map = new HashMap, BSPTree>(); final BSPTree transformedTree = recurseTransform(getTree(false), transform, map); // set up the boundary attributes splitters @@ -519,7 +519,7 @@ private BSPTree recurseTransform(final BSPTree node, final Transform final BSPTree transformedNode; if (node.getCut() == null) { - transformedNode = new BSPTree<>(node.getAttribute()); + transformedNode = new BSPTree(node.getAttribute()); } else { final SubHyperplane sub = node.getCut(); @@ -531,10 +531,10 @@ private BSPTree recurseTransform(final BSPTree node, final Transform final SubHyperplane tPI = (attribute.getPlusInside() == null) ? null : ((AbstractSubHyperplane) attribute.getPlusInside()).applyTransform(transform); // we start with an empty list of splitters, it will be filled in out of recursion - attribute = new BoundaryAttribute<>(tPO, tPI, new NodesSet()); + attribute = new BoundaryAttribute(tPO, tPI, new NodesSet()); } - transformedNode = new BSPTree<>(tSub, + transformedNode = new BSPTree(tSub, recurseTransform(node.getPlus(), transform, map), recurseTransform(node.getMinus(), transform, map), attribute); diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java index 275269e749..76c925c576 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java @@ -116,7 +116,7 @@ public AbstractSubHyperplane applyTransform(final Transform transfor final Hyperplane tHyperplane = transform.apply(hyperplane); // transform the tree, except for boundary attribute splitters - final Map, BSPTree> map = new HashMap<>(); + final Map, BSPTree> map = new HashMap, BSPTree>(); final BSPTree tTree = recurseTransform(remainingRegion.getTree(false), tHyperplane, transform, map); @@ -153,7 +153,7 @@ private BSPTree recurseTransform(final BSPTree node, final BSPTree transformedNode; if (node.getCut() == null) { - transformedNode = new BSPTree<>(node.getAttribute()); + transformedNode = new BSPTree(node.getAttribute()); } else { @SuppressWarnings("unchecked") @@ -164,10 +164,10 @@ private BSPTree recurseTransform(final BSPTree node, final SubHyperplane tPI = (attribute.getPlusInside() == null) ? null : transform.apply(attribute.getPlusInside(), hyperplane, transformed); // we start with an empty list of splitters, it will be filled in out of recursion - attribute = new BoundaryAttribute<>(tPO, tPI, new NodesSet()); + attribute = new BoundaryAttribute(tPO, tPI, new NodesSet()); } - transformedNode = new BSPTree<>(transform.apply(node.getCut(), hyperplane, transformed), + transformedNode = new BSPTree(transform.apply(node.getCut(), hyperplane, transformed), recurseTransform(node.getPlus(), transformed, transform, map), recurseTransform(node.getMinus(), transformed, transform, map), attribute); diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/BSPTree.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/BSPTree.java index 0599d89233..16548ddbc8 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/BSPTree.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/BSPTree.java @@ -163,9 +163,9 @@ public boolean insertCut(final Hyperplane hyperplane) { } cut = chopped; - plus = new BSPTree<>(); + plus = new BSPTree(); plus.parent = this; - minus = new BSPTree<>(); + minus = new BSPTree(); minus.parent = this; return true; @@ -181,10 +181,10 @@ public boolean insertCut(final Hyperplane hyperplane) { public BSPTree copySelf() { if (cut == null) { - return new BSPTree<>(attribute); + return new BSPTree(attribute); } - return new BSPTree<>(cut.copySelf(), plus.copySelf(), minus.copySelf(), + return new BSPTree(cut.copySelf(), plus.copySelf(), minus.copySelf(), attribute); } @@ -340,7 +340,7 @@ public BSPTree getCell(final Point point, final double tolerance) { * than maxOffset from the point) */ public List> getCloseCuts(final Point point, final double maxOffset) { - final List> close = new ArrayList<>(); + final List> close = new ArrayList>(); recurseCloseCuts(point, maxOffset, close); return close; } @@ -554,7 +554,7 @@ public interface VanishingCutHandler { public BSPTree split(final SubHyperplane sub) { if (cut == null) { - return new BSPTree<>(sub, copySelf(), new BSPTree(attribute), null); + return new BSPTree(sub, copySelf(), new BSPTree(attribute), null); } final Hyperplane cHyperplane = cut.getHyperplane(); @@ -566,12 +566,12 @@ public BSPTree split(final SubHyperplane sub) { final BSPTree split = plus.split(sub); if (cut.split(sHyperplane).getSide() == Side.PLUS) { split.plus = - new BSPTree<>(cut.copySelf(), split.plus, minus.copySelf(), attribute); + new BSPTree(cut.copySelf(), split.plus, minus.copySelf(), attribute); split.plus.condense(); split.plus.parent = split; } else { split.minus = - new BSPTree<>(cut.copySelf(), split.minus, minus.copySelf(), attribute); + new BSPTree(cut.copySelf(), split.minus, minus.copySelf(), attribute); split.minus.condense(); split.minus.parent = split; } @@ -582,12 +582,12 @@ public BSPTree split(final SubHyperplane sub) { final BSPTree split = minus.split(sub); if (cut.split(sHyperplane).getSide() == Side.PLUS) { split.plus = - new BSPTree<>(cut.copySelf(), plus.copySelf(), split.plus, attribute); + new BSPTree(cut.copySelf(), plus.copySelf(), split.plus, attribute); split.plus.condense(); split.plus.parent = split; } else { split.minus = - new BSPTree<>(cut.copySelf(), plus.copySelf(), split.minus, attribute); + new BSPTree(cut.copySelf(), plus.copySelf(), split.minus, attribute); split.minus.condense(); split.minus.parent = split; } @@ -597,7 +597,7 @@ public BSPTree split(final SubHyperplane sub) { { final SubHyperplane.SplitSubHyperplane cutParts = cut.split(sHyperplane); final BSPTree split = - new BSPTree<>(sub, plus.split(subParts.getPlus()), minus.split(subParts.getMinus()), + new BSPTree(sub, plus.split(subParts.getPlus()), minus.split(subParts.getMinus()), null); split.plus.cut = cutParts.getPlus(); split.minus.cut = cutParts.getMinus(); @@ -612,8 +612,8 @@ public BSPTree split(final SubHyperplane sub) { } default : return cHyperplane.sameOrientationAs(sHyperplane) ? - new BSPTree<>(sub, plus.copySelf(), minus.copySelf(), attribute) : - new BSPTree<>(sub, minus.copySelf(), plus.copySelf(), attribute); + new BSPTree(sub, plus.copySelf(), minus.copySelf(), attribute) : + new BSPTree(sub, minus.copySelf(), plus.copySelf(), attribute); } } @@ -710,16 +710,16 @@ public BSPTree pruneAroundConvexCell(final Object cellAttribute, final Object internalAttributes) { // build the current cell leaf - BSPTree tree = new BSPTree<>(cellAttribute); + BSPTree tree = new BSPTree(cellAttribute); // build the pruned tree bottom-up for (BSPTree current = this; current.parent != null; current = current.parent) { final SubHyperplane parentCut = current.parent.cut.copySelf(); - final BSPTree sibling = new BSPTree<>(otherLeafsAttributes); + final BSPTree sibling = new BSPTree(otherLeafsAttributes); if (current == current.parent.plus) { - tree = new BSPTree<>(parentCut, tree, sibling, internalAttributes); + tree = new BSPTree(parentCut, tree, sibling, internalAttributes); } else { - tree = new BSPTree<>(parentCut, sibling, tree, internalAttributes); + tree = new BSPTree(parentCut, sibling, tree, internalAttributes); } } diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java index a28623550f..2b35eb9a2c 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java @@ -44,18 +44,18 @@ public void visitInternalNode(BSPTree node) { // characterize the cut sub-hyperplane, // first with respect to the plus sub-tree - final Characterization plusChar = new Characterization<>(node.getPlus(), node.getCut().copySelf()); + final Characterization plusChar = new Characterization(node.getPlus(), node.getCut().copySelf()); if (plusChar.touchOutside()) { // plusChar.outsideTouching() corresponds to a subset of the cut sub-hyperplane // known to have outside cells on its plus side, we want to check if parts // of this subset do have inside cells on their minus side - final Characterization minusChar = new Characterization<>(node.getMinus(), plusChar.outsideTouching()); + final Characterization minusChar = new Characterization(node.getMinus(), plusChar.outsideTouching()); if (minusChar.touchInside()) { // this part belongs to the boundary, // it has the outside on its plus side and the inside on its minus side plusOutside = minusChar.insideTouching(); - splitters = new NodesSet<>(); + splitters = new NodesSet(); splitters.addAll(minusChar.getInsideSplitters()); splitters.addAll(plusChar.getOutsideSplitters()); } @@ -65,13 +65,13 @@ public void visitInternalNode(BSPTree node) { // plusChar.insideTouching() corresponds to a subset of the cut sub-hyperplane // known to have inside cells on its plus side, we want to check if parts // of this subset do have outside cells on their minus side - final Characterization minusChar = new Characterization<>(node.getMinus(), plusChar.insideTouching()); + final Characterization minusChar = new Characterization(node.getMinus(), plusChar.insideTouching()); if (minusChar.touchOutside()) { // this part belongs to the boundary, // it has the inside on its plus side and the outside on its minus side plusInside = minusChar.outsideTouching(); if (splitters == null) { - splitters = new NodesSet<>(); + splitters = new NodesSet(); } splitters.addAll(minusChar.getOutsideSplitters()); splitters.addAll(plusChar.getInsideSplitters()); @@ -86,7 +86,7 @@ public void visitInternalNode(BSPTree node) { } // set the boundary attribute at non-leaf nodes - node.setAttribute(new BoundaryAttribute<>(plusOutside, plusInside, splitters)); + node.setAttribute(new BoundaryAttribute(plusOutside, plusInside, splitters)); } diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java index 212f624d0c..afb88849a1 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java @@ -130,7 +130,7 @@ public BoundaryProjection getProjection() { // fix offset sign offset = FastMath.copySign(offset, (Boolean) leaf.getAttribute() ? -1 : +1); - return new BoundaryProjection<>(original, projected, offset); + return new BoundaryProjection(original, projected, offset); } @@ -140,7 +140,7 @@ public BoundaryProjection getProjection() { */ private List> boundaryRegions(final BSPTree node) { - final List> regions = new ArrayList<>(2); + final List> regions = new ArrayList>(2); @SuppressWarnings("unchecked") final BoundaryAttribute ba = (BoundaryAttribute) node.getAttribute(); diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/Characterization.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/Characterization.java index 9eae3588f1..69df9addd2 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/Characterization.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/Characterization.java @@ -56,8 +56,8 @@ class Characterization { Characterization(final BSPTree node, final SubHyperplane sub) { outsideTouching = null; insideTouching = null; - outsideSplitters = new NodesSet<>(); - insideSplitters = new NodesSet<>(); + outsideSplitters = new NodesSet(); + insideSplitters = new NodesSet(); characterize(node, sub, new ArrayList>()); } diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java index 1d55c5ba65..e7588e0aa3 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java @@ -35,7 +35,7 @@ public class NodesSet implements Iterable> { /** Simple constructor. */ public NodesSet() { - list = new ArrayList<>(); + list = new ArrayList>(); } /** Add a node if not already known. diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java index 3b0e7953fd..6d49939894 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java @@ -176,7 +176,7 @@ public Region getComplement(final Region region) { private BSPTree recurseComplement(final BSPTree node) { // transform the tree, except for boundary attribute splitters - final Map, BSPTree> map = new HashMap<>(); + final Map, BSPTree> map = new HashMap, BSPTree>(); final BSPTree transformedTree = recurseComplement(node, map); // set up the boundary attributes splitters @@ -208,7 +208,7 @@ private BSPTree recurseComplement(final BSPTree node, final BSPTree transformedNode; if (node.getCut() == null) { - transformedNode = new BSPTree<>(((Boolean) node.getAttribute()) ? Boolean.FALSE : Boolean.TRUE); + transformedNode = new BSPTree(((Boolean) node.getAttribute()) ? Boolean.FALSE : Boolean.TRUE); } else { @SuppressWarnings("unchecked") @@ -219,10 +219,10 @@ private BSPTree recurseComplement(final BSPTree node, final SubHyperplane plusInside = (attribute.getPlusOutside() == null) ? null : attribute.getPlusOutside().copySelf(); // we start with an empty list of splitters, it will be filled in out of recursion - attribute = new BoundaryAttribute<>(plusOutside, plusInside, new NodesSet()); + attribute = new BoundaryAttribute(plusOutside, plusInside, new NodesSet()); } - transformedNode = new BSPTree<>(node.getCut().copySelf(), + transformedNode = new BSPTree(node.getCut().copySelf(), recurseComplement(node.getPlus(), map), recurseComplement(node.getMinus(), map), attribute); @@ -330,7 +330,7 @@ public BSPTree fixNode(final BSPTree node) { final BSPTree cell = node.pruneAroundConvexCell(Boolean.TRUE, Boolean.FALSE, null); final Region r = region1.buildNew(cell); final Point p = r.getBarycenter(); - return new BSPTree<>(region1.checkPoint(p) == Location.INSIDE && + return new BSPTree(region1.checkPoint(p) == Location.INSIDE && region2.checkPoint(p) == Location.OUTSIDE); } @@ -376,10 +376,10 @@ private class VanishingToLeaf implements VanishingCutHandler { public BSPTree fixNode(final BSPTree node) { if (node.getPlus().getAttribute().equals(node.getMinus().getAttribute())) { // no ambiguity - return new BSPTree<>(node.getPlus().getAttribute()); + return new BSPTree(node.getPlus().getAttribute()); } else { // ambiguous node - return new BSPTree<>(inside); + return new BSPTree(inside); } } diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java index bc1e3905e2..1436ce2975 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java @@ -132,7 +132,7 @@ private static BSPTree buildTree(final double lower, final double uppe if (Precision.equals(lower, upper, 0) || (upper - lower) >= MathUtils.TWO_PI) { // the tree must cover the whole circle - return new BSPTree<>(Boolean.TRUE); + return new BSPTree(Boolean.TRUE); } else if (lower > upper) { throw new NumberIsTooLargeException(LocalizedFormats.ENDPOINTS_NOT_AN_INTERVAL, lower, upper, true); @@ -148,9 +148,9 @@ private static BSPTree buildTree(final double lower, final double uppe // simple arc starting after 0 and ending before 2 \pi final SubHyperplane upperCut = new LimitAngle(new S1Point(normalizedUpper), true, tolerance).wholeHyperplane(); - return new BSPTree<>(lowerCut, + return new BSPTree(lowerCut, new BSPTree(Boolean.FALSE), - new BSPTree<>(upperCut, + new BSPTree(upperCut, new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null), @@ -159,8 +159,8 @@ private static BSPTree buildTree(final double lower, final double uppe // arc wrapping around 2 \pi final SubHyperplane upperCut = new LimitAngle(new S1Point(normalizedUpper - MathUtils.TWO_PI), true, tolerance).wholeHyperplane(); - return new BSPTree<>(lowerCut, - new BSPTree<>(upperCut, + return new BSPTree(lowerCut, + new BSPTree(upperCut, new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null), @@ -504,9 +504,9 @@ public BoundaryProjection projectToBoundary(final Point poin final double previousOffset = alpha - previous; final double currentOffset = a[0] - alpha; if (previousOffset < currentOffset) { - return new BoundaryProjection<>(point, new S1Point(previous), previousOffset); + return new BoundaryProjection(point, new S1Point(previous), previousOffset); } else { - return new BoundaryProjection<>(point, new S1Point(a[0]), currentOffset); + return new BoundaryProjection(point, new S1Point(a[0]), currentOffset); } } } else if (alpha <= a[1]) { @@ -515,9 +515,9 @@ public BoundaryProjection projectToBoundary(final Point poin final double offset0 = a[0] - alpha; final double offset1 = alpha - a[1]; if (offset0 < offset1) { - return new BoundaryProjection<>(point, new S1Point(a[1]), offset1); + return new BoundaryProjection(point, new S1Point(a[1]), offset1); } else { - return new BoundaryProjection<>(point, new S1Point(a[0]), offset0); + return new BoundaryProjection(point, new S1Point(a[0]), offset0); } } } @@ -527,7 +527,7 @@ public BoundaryProjection projectToBoundary(final Point poin if (Double.isNaN(previous)) { // there are no points at all in the arcs set - return new BoundaryProjection<>(point, null, MathUtils.TWO_PI); + return new BoundaryProjection(point, null, MathUtils.TWO_PI); } else { @@ -538,18 +538,18 @@ public BoundaryProjection projectToBoundary(final Point poin final double previousOffset = alpha - (previous - MathUtils.TWO_PI); final double currentOffset = first - alpha; if (previousOffset < currentOffset) { - return new BoundaryProjection<>(point, new S1Point(previous), previousOffset); + return new BoundaryProjection(point, new S1Point(previous), previousOffset); } else { - return new BoundaryProjection<>(point, new S1Point(first), currentOffset); + return new BoundaryProjection(point, new S1Point(first), currentOffset); } } else { // the test point is between last and 2\pi final double previousOffset = alpha - previous; final double currentOffset = first + MathUtils.TWO_PI - alpha; if (previousOffset < currentOffset) { - return new BoundaryProjection<>(point, new S1Point(previous), previousOffset); + return new BoundaryProjection(point, new S1Point(previous), previousOffset); } else { - return new BoundaryProjection<>(point, new S1Point(first), currentOffset); + return new BoundaryProjection(point, new S1Point(first), currentOffset); } } @@ -565,7 +565,7 @@ public BoundaryProjection projectToBoundary(final Point poin * @return a new ordered list containing {@link Arc Arc} elements */ public List asList() { - final List list = new ArrayList<>(); + final List list = new ArrayList(); for (final double[] a : this) { list.add(new Arc(a[0], a[1], getTolerance())); } @@ -724,8 +724,8 @@ public Side side(final Arc arc) { */ public Split split(final Arc arc) { - final List minus = new ArrayList<>(); - final List plus = new ArrayList<>(); + final List minus = new ArrayList(); + final List plus = new ArrayList(); final double reference = FastMath.PI + arc.getInf(); final double arcLength = arc.getSup() - arc.getInf(); @@ -861,7 +861,7 @@ private ArcsSet createSplitPart(final List limits) { } // build the tree by adding all angular sectors - BSPTree tree = new BSPTree<>(Boolean.FALSE); + BSPTree tree = new BSPTree(Boolean.FALSE); for (int i = 0; i < limits.size() - 1; i += 2) { addArcLimit(tree, limits.get(i), true); addArcLimit(tree, limits.get(i + 1), false); diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/SubLimitAngle.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/SubLimitAngle.java index 37a6de8b71..31f79fd88f 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/SubLimitAngle.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/SubLimitAngle.java @@ -59,8 +59,8 @@ protected AbstractSubHyperplane buildNew(final Hyperplane split(final Hyperplane hyperplane) { final double global = hyperplane.getOffset(((LimitAngle) getHyperplane()).getLocation()); return (global < -1.0e-10) ? - new SplitSubHyperplane<>(null, this) : - new SplitSubHyperplane<>(this, null); + new SplitSubHyperplane(null, this) : + new SplitSubHyperplane(this, null); } } diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java index 86f12c617b..002d42ce57 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java @@ -55,8 +55,8 @@ class EdgesBuilder implements BSPTreeVisitor { EdgesBuilder(final BSPTree root, final double tolerance) { this.root = root; this.tolerance = tolerance; - this.edgeToNode = new IdentityHashMap<>(); - this.nodeToEdgesList = new IdentityHashMap<>(); + this.edgeToNode = new IdentityHashMap>(); + this.nodeToEdgesList = new IdentityHashMap, List>(); } /** {@inheritDoc} */ @@ -165,7 +165,7 @@ public List getEdges() throws MathIllegalStateException { previous.setNextEdge(getFollowingEdge(previous)); } - return new ArrayList<>(edgeToNode.keySet()); + return new ArrayList(edgeToNode.keySet()); } diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java index b7bcbf03b0..eadc2231e0 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java @@ -50,7 +50,7 @@ class PropertiesComputer implements BSPTreeVisitor { this.tolerance = tolerance; this.summedArea = 0; this.summedBarycenter = Vector3D.ZERO; - this.convexCellsInsidePoints = new ArrayList<>(); + this.convexCellsInsidePoints = new ArrayList(); } /** {@inheritDoc} */ diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java index 6d4d980a52..e84bf581af 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java @@ -59,7 +59,7 @@ public SphericalPolygonsSet(final double tolerance) { * @param tolerance below which points are consider to be identical */ public SphericalPolygonsSet(final Vector3D pole, final double tolerance) { - super(new BSPTree<>(new Circle(pole, tolerance).wholeHyperplane(), + super(new BSPTree(new Circle(pole, tolerance).wholeHyperplane(), new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null), @@ -198,7 +198,7 @@ private static BSPTree verticesToTree(final double hyperplaneThickness final int n = vertices.length; if (n == 0) { // the tree represents the whole space - return new BSPTree<>(Boolean.TRUE); + return new BSPTree(Boolean.TRUE); } // build the vertices @@ -208,7 +208,7 @@ private static BSPTree verticesToTree(final double hyperplaneThickness } // build the edges - List edges = new ArrayList<>(n); + List edges = new ArrayList(n); Vertex end = vArray[n - 1]; for (int i = 0; i < n; ++i) { @@ -241,7 +241,7 @@ private static BSPTree verticesToTree(final double hyperplaneThickness } // build the tree top-down - final BSPTree tree = new BSPTree<>(); + final BSPTree tree = new BSPTree(); insertEdges(hyperplaneThickness, tree, edges); return tree; @@ -284,8 +284,8 @@ private static void insertEdges(final double hyperplaneThickness, // we have split the node by inserting an edge as a cut sub-hyperplane // distribute the remaining edges in the two sub-trees - final List outsideList = new ArrayList<>(); - final List insideList = new ArrayList<>(); + final List outsideList = new ArrayList(); + final List insideList = new ArrayList(); for (final Edge edge : edges) { if (edge != inserted) { edge.split(inserted.getCircle(), outsideList, insideList); @@ -384,7 +384,7 @@ public List getBoundaryLoops() throws MathIllegalStateException { // convert the list of all edges into a list of start vertices - loops = new ArrayList<>(); + loops = new ArrayList(); while (!edges.isEmpty()) { // this is an edge belonging to a new loop, store it @@ -468,10 +468,10 @@ public EnclosingBall getEnclosingCap() { // handle special cases first if (isEmpty()) { - return new EnclosingBall<>(S2Point.PLUS_K, Double.NEGATIVE_INFINITY); + return new EnclosingBall(S2Point.PLUS_K, Double.NEGATIVE_INFINITY); } if (isFull()) { - return new EnclosingBall<>(S2Point.PLUS_K, Double.POSITIVE_INFINITY); + return new EnclosingBall(S2Point.PLUS_K, Double.POSITIVE_INFINITY); } // as the polygons is neither empty nor full, it has some boundaries and cut hyperplanes @@ -479,13 +479,13 @@ public EnclosingBall getEnclosingCap() { if (isEmpty(root.getMinus()) && isFull(root.getPlus())) { // the polygon covers an hemisphere, and its boundary is one 2Ï€ long edge final Circle circle = (Circle) root.getCut().getHyperplane(); - return new EnclosingBall<>(new S2Point(circle.getPole()).negate(), + return new EnclosingBall(new S2Point(circle.getPole()).negate(), 0.5 * FastMath.PI); } if (isFull(root.getMinus()) && isEmpty(root.getPlus())) { // the polygon covers an hemisphere, and its boundary is one 2Ï€ long edge final Circle circle = (Circle) root.getCut().getHyperplane(); - return new EnclosingBall<>(new S2Point(circle.getPole()), + return new EnclosingBall(new S2Point(circle.getPole()), 0.5 * FastMath.PI); } @@ -505,7 +505,7 @@ public EnclosingBall getEnclosingCap() { // find the smallest enclosing 3D sphere final SphereGenerator generator = new SphereGenerator(); final WelzlEncloser encloser = - new WelzlEncloser<>(getTolerance(), generator); + new WelzlEncloser(getTolerance(), generator); EnclosingBall enclosing3D = encloser.enclose(points); final Vector3D[] support3D = enclosing3D.getSupport(); @@ -516,12 +516,12 @@ public EnclosingBall getEnclosingCap() { // the 3D sphere is centered on the unit sphere and covers it // fall back to a crude approximation, based only on outside convex cells EnclosingBall enclosingS2 = - new EnclosingBall<>(S2Point.PLUS_K, Double.POSITIVE_INFINITY); + new EnclosingBall(S2Point.PLUS_K, Double.POSITIVE_INFINITY); for (Vector3D outsidePoint : getOutsidePoints()) { final S2Point outsideS2 = new S2Point(outsidePoint); final BoundaryProjection projection = projectToBoundary(outsideS2); if (FastMath.PI - projection.getOffset() < enclosingS2.getRadius()) { - enclosingS2 = new EnclosingBall<>(outsideS2.negate(), + enclosingS2 = new EnclosingBall(outsideS2.negate(), FastMath.PI - projection.getOffset(), (S2Point) projection.getProjected()); } @@ -534,7 +534,7 @@ public EnclosingBall getEnclosingCap() { } final EnclosingBall enclosingS2 = - new EnclosingBall<>(new S2Point(enclosing3D.getCenter()), + new EnclosingBall(new S2Point(enclosing3D.getCenter()), FastMath.acos((1 + h * h - r * r) / (2 * h)), support); diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java index ba74b52b46..837c953f47 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java @@ -56,14 +56,14 @@ public SplitSubHyperplane split(final Hyperplane hyperplane) if (angle < thisCircle.getTolerance() || angle > FastMath.PI - thisCircle.getTolerance()) { // the two circles are aligned or opposite - return new SplitSubHyperplane<>(null, null); + return new SplitSubHyperplane(null, null); } else { // the two circles intersect each other final Arc arc = thisCircle.getInsideArc(otherCircle); final ArcsSet.Split split = ((ArcsSet) getRemainingRegion()).split(arc); final ArcsSet plus = split.getPlus(); final ArcsSet minus = split.getMinus(); - return new SplitSubHyperplane<>(plus == null ? null : new SubCircle(thisCircle.copySelf(), plus), + return new SplitSubHyperplane(plus == null ? null : new SubCircle(thisCircle.copySelf(), plus), minus == null ? null : new SubCircle(thisCircle.copySelf(), minus)); } diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Vertex.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Vertex.java index a8b1db2887..d3102c15aa 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Vertex.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Vertex.java @@ -45,7 +45,7 @@ public class Vertex { this.location = location; this.incoming = null; this.outgoing = null; - this.circles = new ArrayList<>(); + this.circles = new ArrayList(); } /** Get Vertex location. diff --git a/src/main/java/org/apache/commons/math4/linear/AbstractFieldMatrix.java b/src/main/java/org/apache/commons/math4/linear/AbstractFieldMatrix.java index a182e49a90..23c496934f 100644 --- a/src/main/java/org/apache/commons/math4/linear/AbstractFieldMatrix.java +++ b/src/main/java/org/apache/commons/math4/linear/AbstractFieldMatrix.java @@ -270,7 +270,7 @@ public FieldMatrix power(final int p) throws NonSquareMatrixException, final char[] binaryRepresentation = Integer.toBinaryString(power) .toCharArray(); - final ArrayList nonZeroPositions = new ArrayList<>(); + final ArrayList nonZeroPositions = new ArrayList(); for (int i = 0; i < binaryRepresentation.length; ++i) { if (binaryRepresentation[i] == '1') { @@ -279,7 +279,7 @@ public FieldMatrix power(final int p) throws NonSquareMatrixException, } } - ArrayList> results = new ArrayList<>( + ArrayList> results = new ArrayList>( binaryRepresentation.length); results.add(0, this.copy()); @@ -537,7 +537,7 @@ public void setColumnMatrix(final int column, final FieldMatrix matrix) @Override public FieldVector getRowVector(final int row) throws OutOfRangeException { - return new ArrayFieldVector<>(field, getRow(row), false); + return new ArrayFieldVector(field, getRow(row), false); } /** {@inheritDoc} */ @@ -560,7 +560,7 @@ public void setRowVector(final int row, final FieldVector vector) @Override public FieldVector getColumnVector(final int column) throws OutOfRangeException { - return new ArrayFieldVector<>(field, getColumn(column), false); + return new ArrayFieldVector(field, getColumn(column), false); } /** {@inheritDoc} */ @@ -726,7 +726,7 @@ public T[] operate(final T[] v) throws DimensionMismatchException { public FieldVector operate(final FieldVector v) throws DimensionMismatchException { try { - return new ArrayFieldVector<>(field, operate(((ArrayFieldVector) v).getDataRef()), false); + return new ArrayFieldVector(field, operate(((ArrayFieldVector) v).getDataRef()), false); } catch (ClassCastException cce) { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); @@ -743,7 +743,7 @@ public FieldVector operate(final FieldVector v) out[row] = sum; } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } } @@ -774,7 +774,7 @@ public T[] preMultiply(final T[] v) throws DimensionMismatchException { public FieldVector preMultiply(final FieldVector v) throws DimensionMismatchException { try { - return new ArrayFieldVector<>(field, preMultiply(((ArrayFieldVector) v).getDataRef()), false); + return new ArrayFieldVector(field, preMultiply(((ArrayFieldVector) v).getDataRef()), false); } catch (ClassCastException cce) { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); @@ -791,7 +791,7 @@ public FieldVector preMultiply(final FieldVector v) out[col] = sum; } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } } diff --git a/src/main/java/org/apache/commons/math4/linear/AbstractRealMatrix.java b/src/main/java/org/apache/commons/math4/linear/AbstractRealMatrix.java index 76ef1cb89f..4dcf64070e 100644 --- a/src/main/java/org/apache/commons/math4/linear/AbstractRealMatrix.java +++ b/src/main/java/org/apache/commons/math4/linear/AbstractRealMatrix.java @@ -198,7 +198,7 @@ public RealMatrix power(final int p) */ final char[] binaryRepresentation = Integer.toBinaryString(power).toCharArray(); - final ArrayList nonZeroPositions = new ArrayList<>(); + final ArrayList nonZeroPositions = new ArrayList(); int maxI = -1; for (int i = 0; i < binaryRepresentation.length; ++i) { diff --git a/src/main/java/org/apache/commons/math4/linear/Array2DRowFieldMatrix.java b/src/main/java/org/apache/commons/math4/linear/Array2DRowFieldMatrix.java index 7a70931908..70d789486e 100644 --- a/src/main/java/org/apache/commons/math4/linear/Array2DRowFieldMatrix.java +++ b/src/main/java/org/apache/commons/math4/linear/Array2DRowFieldMatrix.java @@ -208,13 +208,13 @@ public Array2DRowFieldMatrix(final Field field, final T[] v) { public FieldMatrix createMatrix(final int rowDimension, final int columnDimension) throws NotStrictlyPositiveException { - return new Array2DRowFieldMatrix<>(getField(), rowDimension, columnDimension); + return new Array2DRowFieldMatrix(getField(), rowDimension, columnDimension); } /** {@inheritDoc} */ @Override public FieldMatrix copy() { - return new Array2DRowFieldMatrix<>(getField(), copyOut(), false); + return new Array2DRowFieldMatrix(getField(), copyOut(), false); } /** @@ -242,7 +242,7 @@ public Array2DRowFieldMatrix add(final Array2DRowFieldMatrix m) } } - return new Array2DRowFieldMatrix<>(getField(), outData, false); + return new Array2DRowFieldMatrix(getField(), outData, false); } /** @@ -270,7 +270,7 @@ public Array2DRowFieldMatrix subtract(final Array2DRowFieldMatrix m) } } - return new Array2DRowFieldMatrix<>(getField(), outData, false); + return new Array2DRowFieldMatrix(getField(), outData, false); } @@ -303,7 +303,7 @@ public Array2DRowFieldMatrix multiply(final Array2DRowFieldMatrix m) } } - return new Array2DRowFieldMatrix<>(getField(), outData, false); + return new Array2DRowFieldMatrix(getField(), outData, false); } diff --git a/src/main/java/org/apache/commons/math4/linear/ArrayFieldVector.java b/src/main/java/org/apache/commons/math4/linear/ArrayFieldVector.java index b468bb7d17..b2240e6c91 100644 --- a/src/main/java/org/apache/commons/math4/linear/ArrayFieldVector.java +++ b/src/main/java/org/apache/commons/math4/linear/ArrayFieldVector.java @@ -388,7 +388,7 @@ public Field getField() { /** {@inheritDoc} */ @Override public FieldVector copy() { - return new ArrayFieldVector<>(this, true); + return new ArrayFieldVector(this, true); } /** {@inheritDoc} */ @@ -403,7 +403,7 @@ public FieldVector add(FieldVector v) for (int i = 0; i < data.length; i++) { out[i] = data[i].add(v.getEntry(i)); } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } } @@ -421,7 +421,7 @@ public ArrayFieldVector add(ArrayFieldVector v) for (int i = 0; i < data.length; i++) { out[i] = data[i].add(v.data[i]); } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } /** {@inheritDoc} */ @@ -436,7 +436,7 @@ public FieldVector subtract(FieldVector v) for (int i = 0; i < data.length; i++) { out[i] = data[i].subtract(v.getEntry(i)); } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } } @@ -454,7 +454,7 @@ public ArrayFieldVector subtract(ArrayFieldVector v) for (int i = 0; i < data.length; i++) { out[i] = data[i].subtract(v.data[i]); } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } /** {@inheritDoc} */ @@ -464,7 +464,7 @@ public FieldVector mapAdd(T d) throws NullArgumentException { for (int i = 0; i < data.length; i++) { out[i] = data[i].add(d); } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } /** {@inheritDoc} */ @@ -483,7 +483,7 @@ public FieldVector mapSubtract(T d) throws NullArgumentException { for (int i = 0; i < data.length; i++) { out[i] = data[i].subtract(d); } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } /** {@inheritDoc} */ @@ -502,7 +502,7 @@ public FieldVector mapMultiply(T d) throws NullArgumentException { for (int i = 0; i < data.length; i++) { out[i] = data[i].multiply(d); } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } /** {@inheritDoc} */ @@ -523,7 +523,7 @@ public FieldVector mapDivide(T d) for (int i = 0; i < data.length; i++) { out[i] = data[i].divide(d); } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } /** {@inheritDoc} */ @@ -549,7 +549,7 @@ public FieldVector mapInv() throws MathArithmeticException { throw new MathArithmeticException(LocalizedFormats.INDEX, i); } } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } /** {@inheritDoc} */ @@ -578,7 +578,7 @@ public FieldVector ebeMultiply(FieldVector v) for (int i = 0; i < data.length; i++) { out[i] = data[i].multiply(v.getEntry(i)); } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } } @@ -596,7 +596,7 @@ public ArrayFieldVector ebeMultiply(ArrayFieldVector v) for (int i = 0; i < data.length; i++) { out[i] = data[i].multiply(v.data[i]); } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } /** {@inheritDoc} */ @@ -615,7 +615,7 @@ public FieldVector ebeDivide(FieldVector v) throw new MathArithmeticException(LocalizedFormats.INDEX, i); } } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } } @@ -638,7 +638,7 @@ public ArrayFieldVector ebeDivide(ArrayFieldVector v) throw new MathArithmeticException(LocalizedFormats.INDEX, i); } } - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } /** @@ -710,7 +710,7 @@ public FieldMatrix outerProduct(FieldVector v) { } catch (ClassCastException cce) { final int m = data.length; final int n = v.getDimension(); - final FieldMatrix out = new Array2DRowFieldMatrix<>(field, m, n); + final FieldMatrix out = new Array2DRowFieldMatrix(field, m, n); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { out.setEntry(i, j, data[i].multiply(v.getEntry(j))); @@ -728,7 +728,7 @@ public FieldMatrix outerProduct(FieldVector v) { public FieldMatrix outerProduct(ArrayFieldVector v) { final int m = data.length; final int n = v.data.length; - final FieldMatrix out = new Array2DRowFieldMatrix<>(field, m, n); + final FieldMatrix out = new Array2DRowFieldMatrix(field, m, n); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { out.setEntry(i, j, data[i].multiply(v.data[j])); @@ -755,7 +755,7 @@ public FieldVector append(FieldVector v) { try { return append((ArrayFieldVector) v); } catch (ClassCastException cce) { - return new ArrayFieldVector<>(this,new ArrayFieldVector<>(v)); + return new ArrayFieldVector(this,new ArrayFieldVector(v)); } } @@ -765,7 +765,7 @@ public FieldVector append(FieldVector v) { * @return a new vector */ public ArrayFieldVector append(ArrayFieldVector v) { - return new ArrayFieldVector<>(this, v); + return new ArrayFieldVector(this, v); } /** {@inheritDoc} */ @@ -774,7 +774,7 @@ public FieldVector append(T in) { final T[] out = MathArrays.buildArray(field, data.length + 1); System.arraycopy(data, 0, out, 0, data.length); out[data.length] = in; - return new ArrayFieldVector<>(field, out, false); + return new ArrayFieldVector(field, out, false); } /** {@inheritDoc} */ @@ -784,7 +784,7 @@ public FieldVector getSubVector(int index, int n) if (n < 0) { throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n); } - ArrayFieldVector out = new ArrayFieldVector<>(field, n); + ArrayFieldVector out = new ArrayFieldVector(field, n); try { System.arraycopy(data, index, out.data, 0, n); } catch (IndexOutOfBoundsException e) { diff --git a/src/main/java/org/apache/commons/math4/linear/BlockFieldMatrix.java b/src/main/java/org/apache/commons/math4/linear/BlockFieldMatrix.java index 74c6fe8d30..e5294f2c65 100644 --- a/src/main/java/org/apache/commons/math4/linear/BlockFieldMatrix.java +++ b/src/main/java/org/apache/commons/math4/linear/BlockFieldMatrix.java @@ -294,7 +294,7 @@ public static > T[][] createBlocksLayout(final Field createMatrix(final int rowDimension, final int columnDimension) throws NotStrictlyPositiveException { - return new BlockFieldMatrix<>(getField(), rowDimension, + return new BlockFieldMatrix(getField(), rowDimension, columnDimension); } @@ -303,7 +303,7 @@ public FieldMatrix createMatrix(final int rowDimension, public FieldMatrix copy() { // create an empty matrix - BlockFieldMatrix copied = new BlockFieldMatrix<>(getField(), rows, columns); + BlockFieldMatrix copied = new BlockFieldMatrix(getField(), rows, columns); // copy the blocks for (int i = 0; i < blocks.length; ++i) { @@ -324,7 +324,7 @@ public FieldMatrix add(final FieldMatrix m) // safety check checkAdditionCompatible(m); - final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, columns); + final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, columns); // perform addition block-wise, to ensure good cache behavior int blockIndex = 0; @@ -370,7 +370,7 @@ public BlockFieldMatrix add(final BlockFieldMatrix m) // safety check checkAdditionCompatible(m); - final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, columns); + final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, columns); // perform addition block-wise, to ensure good cache behavior for (int blockIndex = 0; blockIndex < out.blocks.length; ++blockIndex) { @@ -396,7 +396,7 @@ public FieldMatrix subtract(final FieldMatrix m) // safety check checkSubtractionCompatible(m); - final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, columns); + final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, columns); // perform subtraction block-wise, to ensure good cache behavior int blockIndex = 0; @@ -440,7 +440,7 @@ public BlockFieldMatrix subtract(final BlockFieldMatrix m) throws MatrixDi // safety check checkSubtractionCompatible(m); - final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, columns); + final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, columns); // perform subtraction block-wise, to ensure good cache behavior for (int blockIndex = 0; blockIndex < out.blocks.length; ++blockIndex) { @@ -458,7 +458,7 @@ public BlockFieldMatrix subtract(final BlockFieldMatrix m) throws MatrixDi /** {@inheritDoc} */ @Override public FieldMatrix scalarAdd(final T d) { - final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, columns); + final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, columns); // perform subtraction block-wise, to ensure good cache behavior for (int blockIndex = 0; blockIndex < out.blocks.length; ++blockIndex) { @@ -476,7 +476,7 @@ public FieldMatrix scalarAdd(final T d) { @Override public FieldMatrix scalarMultiply(final T d) { - final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, columns); + final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, columns); // perform subtraction block-wise, to ensure good cache behavior for (int blockIndex = 0; blockIndex < out.blocks.length; ++blockIndex) { @@ -501,7 +501,7 @@ public FieldMatrix multiply(final FieldMatrix m) // safety check checkMultiplicationCompatible(m); - final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, m.getColumnDimension()); + final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, m.getColumnDimension()); final T zero = getField().getZero(); // perform multiplication block-wise, to ensure good cache behavior @@ -564,7 +564,7 @@ public BlockFieldMatrix multiply(BlockFieldMatrix m) // safety check checkMultiplicationCompatible(m); - final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, m.columns); + final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, m.columns); final T zero = getField().getZero(); // perform multiplication block-wise, to ensure good cache behavior @@ -663,7 +663,7 @@ public FieldMatrix getSubMatrix(final int startRow, final int endRow, // create the output matrix final BlockFieldMatrix out = - new BlockFieldMatrix<>(getField(), endRow - startRow + 1, endColumn - startColumn + 1); + new BlockFieldMatrix(getField(), endRow - startRow + 1, endColumn - startColumn + 1); // compute blocks shifts final int blockStartRow = startRow / BLOCK_SIZE; @@ -836,7 +836,7 @@ public void setSubMatrix(final T[][] subMatrix, final int row, public FieldMatrix getRowMatrix(final int row) throws OutOfRangeException { checkRowIndex(row); - final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), 1, columns); + final BlockFieldMatrix out = new BlockFieldMatrix(getField(), 1, columns); // perform copy block-wise, to ensure good cache behavior final int iBlock = row / BLOCK_SIZE; @@ -922,7 +922,7 @@ public void setRowMatrix(final int row, final BlockFieldMatrix matrix) public FieldMatrix getColumnMatrix(final int column) throws OutOfRangeException { checkColumnIndex(column); - final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), rows, 1); + final BlockFieldMatrix out = new BlockFieldMatrix(getField(), rows, 1); // perform copy block-wise, to ensure good cache behavior final int jBlock = column / BLOCK_SIZE; @@ -1017,7 +1017,7 @@ public FieldVector getRowVector(final int row) outIndex += jWidth; } - return new ArrayFieldVector<>(getField(), outData, false); + return new ArrayFieldVector(getField(), outData, false); } /** {@inheritDoc} */ @@ -1051,7 +1051,7 @@ public FieldVector getColumnVector(final int column) } } - return new ArrayFieldVector<>(getField(), outData, false); + return new ArrayFieldVector(getField(), outData, false); } /** {@inheritDoc} */ @@ -1220,7 +1220,7 @@ public void multiplyEntry(final int row, final int column, final T factor) public FieldMatrix transpose() { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); - final BlockFieldMatrix out = new BlockFieldMatrix<>(getField(), nCols, nRows); + final BlockFieldMatrix out = new BlockFieldMatrix(getField(), nCols, nRows); // perform transpose block-wise, to ensure good cache behavior int blockIndex = 0; diff --git a/src/main/java/org/apache/commons/math4/linear/FieldLUDecomposition.java b/src/main/java/org/apache/commons/math4/linear/FieldLUDecomposition.java index e733f42bf3..1e4c47317f 100644 --- a/src/main/java/org/apache/commons/math4/linear/FieldLUDecomposition.java +++ b/src/main/java/org/apache/commons/math4/linear/FieldLUDecomposition.java @@ -171,7 +171,7 @@ public FieldLUDecomposition(FieldMatrix matrix) { public FieldMatrix getL() { if ((cachedL == null) && !singular) { final int m = pivot.length; - cachedL = new Array2DRowFieldMatrix<>(field, m, m); + cachedL = new Array2DRowFieldMatrix(field, m, m); for (int i = 0; i < m; ++i) { final T[] luI = lu[i]; for (int j = 0; j < i; ++j) { @@ -191,7 +191,7 @@ public FieldMatrix getL() { public FieldMatrix getU() { if ((cachedU == null) && !singular) { final int m = pivot.length; - cachedU = new Array2DRowFieldMatrix<>(field, m, m); + cachedU = new Array2DRowFieldMatrix(field, m, m); for (int i = 0; i < m; ++i) { final T[] luI = lu[i]; for (int j = i; j < m; ++j) { @@ -214,7 +214,7 @@ public FieldMatrix getU() { public FieldMatrix getP() { if ((cachedP == null) && !singular) { final int m = pivot.length; - cachedP = new Array2DRowFieldMatrix<>(field, m, m); + cachedP = new Array2DRowFieldMatrix(field, m, m); for (int i = 0; i < m; ++i) { cachedP.setEntry(i, pivot[i], field.getOne()); } @@ -253,7 +253,7 @@ public T getDeterminant() { * @return a solver */ public FieldDecompositionSolver getSolver() { - return new Solver<>(field, lu, pivot, singular); + return new Solver(field, lu, pivot, singular); } /** Specialized solver. @@ -332,7 +332,7 @@ public FieldVector solve(FieldVector b) { } } - return new ArrayFieldVector<>(field, bp, false); + return new ArrayFieldVector(field, bp, false); } } @@ -377,7 +377,7 @@ public ArrayFieldVector solve(ArrayFieldVector b) { } } - return new ArrayFieldVector<>(bp, false); + return new ArrayFieldVector(bp, false); } /** {@inheritDoc} */ @@ -431,7 +431,7 @@ public FieldMatrix solve(FieldMatrix b) { } } - return new Array2DRowFieldMatrix<>(field, bp, false); + return new Array2DRowFieldMatrix(field, bp, false); } @@ -440,7 +440,7 @@ public FieldMatrix solve(FieldMatrix b) { public FieldMatrix getInverse() { final int m = pivot.length; final T one = field.getOne(); - FieldMatrix identity = new Array2DRowFieldMatrix<>(field, m, m); + FieldMatrix identity = new Array2DRowFieldMatrix(field, m, m); for (int i = 0; i < m; ++i) { identity.setEntry(i, i, one); } diff --git a/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java b/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java index a18c015043..19ff724fae 100644 --- a/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java +++ b/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java @@ -101,7 +101,7 @@ public static > FieldMatrix createFieldMatrix(final final int rows, final int columns) { return (rows * columns <= 4096) ? - new Array2DRowFieldMatrix<>(field, rows, columns) : new BlockFieldMatrix<>(field, rows, columns); + new Array2DRowFieldMatrix(field, rows, columns) : new BlockFieldMatrix(field, rows, columns); } /** @@ -161,7 +161,7 @@ public static > FieldMatrix createFieldMatrix(T[][] throw new NullArgumentException(); } return (data.length * data[0].length <= 4096) ? - new Array2DRowFieldMatrix<>(data) : new BlockFieldMatrix<>(data); + new Array2DRowFieldMatrix(data) : new BlockFieldMatrix(data); } /** @@ -200,7 +200,7 @@ public static RealMatrix createRealIdentityMatrix(int dimension) { Arrays.fill(dRow, zero); dRow[row] = one; } - return new Array2DRowFieldMatrix<>(field, d, false); + return new Array2DRowFieldMatrix(field, d, false); } /** @@ -272,7 +272,7 @@ public static > FieldVector createFieldVector(final if (data.length == 0) { throw new ZeroException(LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT); } - return new ArrayFieldVector<>(data[0].getField(), data, true); + return new ArrayFieldVector(data[0].getField(), data, true); } /** diff --git a/src/main/java/org/apache/commons/math4/linear/RealMatrixFormat.java b/src/main/java/org/apache/commons/math4/linear/RealMatrixFormat.java index 34c0b0e9c8..8601490961 100644 --- a/src/main/java/org/apache/commons/math4/linear/RealMatrixFormat.java +++ b/src/main/java/org/apache/commons/math4/linear/RealMatrixFormat.java @@ -315,8 +315,8 @@ public RealMatrix parse(String source, ParsePosition pos) { } // parse components - List> matrix = new ArrayList<>(); - List rowComponents = new ArrayList<>(); + List> matrix = new ArrayList>(); + List rowComponents = new ArrayList(); for (boolean loop = true; loop;){ if (!rowComponents.isEmpty()) { @@ -329,7 +329,7 @@ public RealMatrix parse(String source, ParsePosition pos) { CompositeFormat.parseAndIgnoreWhitespace(source, pos); if (CompositeFormat.parseFixedstring(source, trimmedRowSeparator, pos)) { matrix.add(rowComponents); - rowComponents = new ArrayList<>(); + rowComponents = new ArrayList(); continue; } else { loop = false; diff --git a/src/main/java/org/apache/commons/math4/linear/RealVectorFormat.java b/src/main/java/org/apache/commons/math4/linear/RealVectorFormat.java index 2ffb378650..49de55dd7e 100644 --- a/src/main/java/org/apache/commons/math4/linear/RealVectorFormat.java +++ b/src/main/java/org/apache/commons/math4/linear/RealVectorFormat.java @@ -247,7 +247,7 @@ public ArrayRealVector parse(String source, ParsePosition pos) { } // parse components - List components = new ArrayList<>(); + List components = new ArrayList(); for (boolean loop = true; loop;){ if (!components.isEmpty()) { diff --git a/src/main/java/org/apache/commons/math4/linear/SparseFieldMatrix.java b/src/main/java/org/apache/commons/math4/linear/SparseFieldMatrix.java index 70d5999088..b48970c21c 100644 --- a/src/main/java/org/apache/commons/math4/linear/SparseFieldMatrix.java +++ b/src/main/java/org/apache/commons/math4/linear/SparseFieldMatrix.java @@ -51,7 +51,7 @@ public SparseFieldMatrix(final Field field) { super(field); rows = 0; columns= 0; - entries = new OpenIntToFieldHashMap<>(field); + entries = new OpenIntToFieldHashMap(field); } /** @@ -69,7 +69,7 @@ public SparseFieldMatrix(final Field field, super(field, rowDimension, columnDimension); this.rows = rowDimension; this.columns = columnDimension; - entries = new OpenIntToFieldHashMap<>(field); + entries = new OpenIntToFieldHashMap(field); } /** @@ -81,7 +81,7 @@ public SparseFieldMatrix(SparseFieldMatrix other) { super(other.getField(), other.getRowDimension(), other.getColumnDimension()); rows = other.getRowDimension(); columns = other.getColumnDimension(); - entries = new OpenIntToFieldHashMap<>(other.entries); + entries = new OpenIntToFieldHashMap(other.entries); } /** @@ -93,7 +93,7 @@ public SparseFieldMatrix(FieldMatrix other){ super(other.getField(), other.getRowDimension(), other.getColumnDimension()); rows = other.getRowDimension(); columns = other.getColumnDimension(); - entries = new OpenIntToFieldHashMap<>(getField()); + entries = new OpenIntToFieldHashMap(getField()); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { setEntry(i, j, other.getEntry(i, j)); @@ -118,13 +118,13 @@ public void addToEntry(int row, int column, T increment) { /** {@inheritDoc} */ @Override public FieldMatrix copy() { - return new SparseFieldMatrix<>(this); + return new SparseFieldMatrix(this); } /** {@inheritDoc} */ @Override public FieldMatrix createMatrix(int rowDimension, int columnDimension) { - return new SparseFieldMatrix<>(getField(), rowDimension, columnDimension); + return new SparseFieldMatrix(getField(), rowDimension, columnDimension); } /** {@inheritDoc} */ diff --git a/src/main/java/org/apache/commons/math4/linear/SparseFieldVector.java b/src/main/java/org/apache/commons/math4/linear/SparseFieldVector.java index 1bf041dc62..7065f10900 100644 --- a/src/main/java/org/apache/commons/math4/linear/SparseFieldVector.java +++ b/src/main/java/org/apache/commons/math4/linear/SparseFieldVector.java @@ -77,7 +77,7 @@ public SparseFieldVector(Field field) { public SparseFieldVector(Field field, int dimension) { this.field = field; virtualSize = dimension; - entries = new OpenIntToFieldHashMap<>(field); + entries = new OpenIntToFieldHashMap(field); } /** @@ -89,7 +89,7 @@ public SparseFieldVector(Field field, int dimension) { protected SparseFieldVector(SparseFieldVector v, int resize) { field = v.field; virtualSize = v.getDimension() + resize; - entries = new OpenIntToFieldHashMap<>(v.entries); + entries = new OpenIntToFieldHashMap(v.entries); } @@ -103,7 +103,7 @@ protected SparseFieldVector(SparseFieldVector v, int resize) { public SparseFieldVector(Field field, int dimension, int expectedSize) { this.field = field; virtualSize = dimension; - entries = new OpenIntToFieldHashMap<>(field,expectedSize); + entries = new OpenIntToFieldHashMap(field,expectedSize); } /** @@ -118,7 +118,7 @@ public SparseFieldVector(Field field, T[] values) throws NullArgumentExceptio MathUtils.checkNotNull(values); this.field = field; virtualSize = values.length; - entries = new OpenIntToFieldHashMap<>(field); + entries = new OpenIntToFieldHashMap(field); for (int key = 0; key < values.length; key++) { T value = values[key]; entries.put(key, value); @@ -133,7 +133,7 @@ public SparseFieldVector(Field field, T[] values) throws NullArgumentExceptio public SparseFieldVector(SparseFieldVector v) { field = v.field; virtualSize = v.getDimension(); - entries = new OpenIntToFieldHashMap<>(v.getEntries()); + entries = new OpenIntToFieldHashMap(v.getEntries()); } /** @@ -179,7 +179,7 @@ public FieldVector add(SparseFieldVector v) * @return a new vector. */ public FieldVector append(SparseFieldVector v) { - SparseFieldVector res = new SparseFieldVector<>(this, v.getDimension()); + SparseFieldVector res = new SparseFieldVector(this, v.getDimension()); OpenIntToFieldHashMap.Iterator iter = v.entries.iterator(); while (iter.hasNext()) { iter.advance(); @@ -195,7 +195,7 @@ public FieldVector append(FieldVector v) { return append((SparseFieldVector) v); } else { final int n = v.getDimension(); - FieldVector res = new SparseFieldVector<>(this, n); + FieldVector res = new SparseFieldVector(this, n); for (int i = 0; i < n; i++) { res.setEntry(i + virtualSize, v.getEntry(i)); } @@ -209,7 +209,7 @@ public FieldVector append(FieldVector v) { @Override public FieldVector append(T d) throws NullArgumentException { MathUtils.checkNotNull(d); - FieldVector res = new SparseFieldVector<>(this, 1); + FieldVector res = new SparseFieldVector(this, 1); res.setEntry(virtualSize, d); return res; } @@ -217,7 +217,7 @@ public FieldVector append(T d) throws NullArgumentException { /** {@inheritDoc} */ @Override public FieldVector copy() { - return new SparseFieldVector<>(this); + return new SparseFieldVector(this); } /** {@inheritDoc} */ @@ -238,7 +238,7 @@ public T dotProduct(FieldVector v) throws DimensionMismatchException { public FieldVector ebeDivide(FieldVector v) throws DimensionMismatchException, MathArithmeticException { checkVectorDimensions(v.getDimension()); - SparseFieldVector res = new SparseFieldVector<>(this); + SparseFieldVector res = new SparseFieldVector(this); OpenIntToFieldHashMap.Iterator iter = res.entries.iterator(); while (iter.hasNext()) { iter.advance(); @@ -252,7 +252,7 @@ public FieldVector ebeDivide(FieldVector v) public FieldVector ebeMultiply(FieldVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); - SparseFieldVector res = new SparseFieldVector<>(this); + SparseFieldVector res = new SparseFieldVector(this); OpenIntToFieldHashMap.Iterator iter = res.entries.iterator(); while (iter.hasNext()) { iter.advance(); @@ -289,7 +289,7 @@ public FieldVector getSubVector(int index, int n) } checkIndex(index); checkIndex(index + n - 1); - SparseFieldVector res = new SparseFieldVector<>(field,n); + SparseFieldVector res = new SparseFieldVector(field,n); int end = index + n; OpenIntToFieldHashMap.Iterator iter = entries.iterator(); while (iter.hasNext()) { @@ -387,7 +387,7 @@ public FieldVector mapSubtractToSelf(T d) throws NullArgumentException { */ public FieldMatrix outerProduct(SparseFieldVector v) { final int n = v.getDimension(); - SparseFieldMatrix res = new SparseFieldMatrix<>(field, virtualSize, n); + SparseFieldMatrix res = new SparseFieldMatrix(field, virtualSize, n); OpenIntToFieldHashMap.Iterator iter = entries.iterator(); while (iter.hasNext()) { iter.advance(); @@ -407,7 +407,7 @@ public FieldMatrix outerProduct(FieldVector v) { return outerProduct((SparseFieldVector)v); } else { final int n = v.getDimension(); - FieldMatrix res = new SparseFieldMatrix<>(field, virtualSize, n); + FieldMatrix res = new SparseFieldMatrix(field, virtualSize, n); OpenIntToFieldHashMap.Iterator iter = entries.iterator(); while (iter.hasNext()) { iter.advance(); @@ -495,7 +495,7 @@ public FieldVector subtract(FieldVector v) } else { final int n = v.getDimension(); checkVectorDimensions(n); - SparseFieldVector res = new SparseFieldVector<>(this); + SparseFieldVector res = new SparseFieldVector(this); for (int i = 0; i < n; i++) { if (entries.containsKey(i)) { res.setEntry(i, entries.get(i).subtract(v.getEntry(i))); @@ -578,7 +578,7 @@ public FieldVector add(FieldVector v) throws DimensionMismatchException { } else { final int n = v.getDimension(); checkVectorDimensions(n); - SparseFieldVector res = new SparseFieldVector<>(field, + SparseFieldVector res = new SparseFieldVector(field, getDimension()); for (int i = 0; i < n; i++) { res.setEntry(i, v.getEntry(i).add(getEntry(i))); diff --git a/src/main/java/org/apache/commons/math4/ml/clustering/Cluster.java b/src/main/java/org/apache/commons/math4/ml/clustering/Cluster.java index f655065a7f..bd264bb1e1 100644 --- a/src/main/java/org/apache/commons/math4/ml/clustering/Cluster.java +++ b/src/main/java/org/apache/commons/math4/ml/clustering/Cluster.java @@ -38,7 +38,7 @@ public class Cluster implements Serializable { * Build a cluster centered at a specified point. */ public Cluster() { - points = new ArrayList<>(); + points = new ArrayList(); } /** diff --git a/src/main/java/org/apache/commons/math4/ml/clustering/DBSCANClusterer.java b/src/main/java/org/apache/commons/math4/ml/clustering/DBSCANClusterer.java index a5614337eb..1223be84f4 100644 --- a/src/main/java/org/apache/commons/math4/ml/clustering/DBSCANClusterer.java +++ b/src/main/java/org/apache/commons/math4/ml/clustering/DBSCANClusterer.java @@ -136,8 +136,8 @@ public List> cluster(final Collection points) throws NullArgumentE // sanity checks MathUtils.checkNotNull(points); - final List> clusters = new ArrayList<>(); - final Map visited = new HashMap<>(); + final List> clusters = new ArrayList>(); + final Map visited = new HashMap(); for (final T point : points) { if (visited.get(point) != null) { @@ -146,7 +146,7 @@ public List> cluster(final Collection points) throws NullArgumentE final List neighbors = getNeighbors(point, points); if (neighbors.size() >= minPts) { // DBSCAN does not care about center points - final Cluster cluster = new Cluster<>(); + final Cluster cluster = new Cluster(); clusters.add(expandCluster(cluster, point, neighbors, points, visited)); } else { visited.put(point, PointStatus.NOISE); @@ -174,7 +174,7 @@ private Cluster expandCluster(final Cluster cluster, cluster.addPoint(point); visited.put(point, PointStatus.PART_OF_CLUSTER); - List seeds = new ArrayList<>(neighbors); + List seeds = new ArrayList(neighbors); int index = 0; while (index < seeds.size()) { final T current = seeds.get(index); @@ -205,7 +205,7 @@ private Cluster expandCluster(final Cluster cluster, * @return the List of neighbors */ private List getNeighbors(final T point, final Collection points) { - final List neighbors = new ArrayList<>(); + final List neighbors = new ArrayList(); for (final T neighbor : points) { if (point != neighbor && distance(neighbor, point) <= eps) { neighbors.add(neighbor); @@ -222,7 +222,7 @@ private List getNeighbors(final T point, final Collection points) { * @return merged lists */ private List merge(final List one, final List two) { - final Set oneSet = new HashSet<>(one); + final Set oneSet = new HashSet(one); for (T item : two) { if (!oneSet.contains(item)) { one.add(item); diff --git a/src/main/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClusterer.java b/src/main/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClusterer.java index 7ef632f527..e57697f379 100644 --- a/src/main/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClusterer.java +++ b/src/main/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClusterer.java @@ -279,8 +279,8 @@ public List> cluster(final Collection dataPoints) } // copy the input collection to an unmodifiable list with indexed access - points = Collections.unmodifiableList(new ArrayList<>(dataPoints)); - clusters = new ArrayList<>(); + points = Collections.unmodifiableList(new ArrayList(dataPoints)); + clusters = new ArrayList>(); membershipMatrix = new double[size][k]; final double[][] oldMatrix = new double[size][k]; @@ -316,7 +316,7 @@ public List> cluster(final Collection dataPoints) */ private void updateClusterCenters() { int j = 0; - final List> newClusters = new ArrayList<>(k); + final List> newClusters = new ArrayList>(k); for (final CentroidCluster cluster : clusters) { final Clusterable center = cluster.getCenter(); int i = 0; diff --git a/src/main/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClusterer.java b/src/main/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClusterer.java index 79dca8e166..1901013d04 100644 --- a/src/main/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClusterer.java +++ b/src/main/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClusterer.java @@ -216,7 +216,7 @@ public List> cluster(final Collection points) final int max = (maxIterations < 0) ? Integer.MAX_VALUE : maxIterations; for (int count = 0; count < max; count++) { boolean emptyCluster = false; - List> newClusters = new ArrayList<>(); + List> newClusters = new ArrayList>(); for (final CentroidCluster cluster : clusters) { final Clusterable newCenter; if (cluster.getPoints().isEmpty()) { @@ -288,7 +288,7 @@ private List> chooseInitialCenters(final Collection points // Convert to list for indexed access. Make it unmodifiable, since removal of items // would screw up the logic of this method. - final List pointList = Collections.unmodifiableList(new ArrayList<> (points)); + final List pointList = Collections.unmodifiableList(new ArrayList (points)); // The number of points in the list. final int numPoints = pointList.size(); @@ -298,7 +298,7 @@ private List> chooseInitialCenters(final Collection points final boolean[] taken = new boolean[numPoints]; // The resulting list of initial centers. - final List> resultSet = new ArrayList<>(); + final List> resultSet = new ArrayList>(); // Choose one center uniformly at random from among the data points. final int firstPointIndex = random.nextInt(numPoints); diff --git a/src/main/java/org/apache/commons/math4/ml/neuralnet/MapUtils.java b/src/main/java/org/apache/commons/math4/ml/neuralnet/MapUtils.java index a793fa0ac3..d097edd398 100644 --- a/src/main/java/org/apache/commons/math4/ml/neuralnet/MapUtils.java +++ b/src/main/java/org/apache/commons/math4/ml/neuralnet/MapUtils.java @@ -105,7 +105,7 @@ public static Pair findBestAndSecondBest(double[] features, } } - return new Pair<>(best[0], best[1]); + return new Pair(best[0], best[1]); } /** @@ -130,7 +130,7 @@ public static Pair findBestAndSecondBest(double[] features, public static Neuron[] sort(double[] features, Iterable neurons, DistanceMeasure distance) { - final List list = new ArrayList<>(); + final List list = new ArrayList(); for (final Neuron n : neurons) { final double d = distance.compute(n.getFeatures(), features); @@ -196,7 +196,7 @@ public static double[][] computeU(NeuronSquareMesh2D map, public static int[][] computeHitHistogram(Iterable data, NeuronSquareMesh2D map, DistanceMeasure distance) { - final HashMap hit = new HashMap<>(); + final HashMap hit = new HashMap(); final Network net = map.getNetwork(); for (double[] f : data) { diff --git a/src/main/java/org/apache/commons/math4/ml/neuralnet/Network.java b/src/main/java/org/apache/commons/math4/ml/neuralnet/Network.java index 6da635ea05..6dcd729b72 100644 --- a/src/main/java/org/apache/commons/math4/ml/neuralnet/Network.java +++ b/src/main/java/org/apache/commons/math4/ml/neuralnet/Network.java @@ -51,14 +51,14 @@ public class Network private static final long serialVersionUID = 20130207L; /** Neurons. */ private final ConcurrentHashMap neuronMap - = new ConcurrentHashMap<>(); + = new ConcurrentHashMap(); /** Next available neuron identifier. */ private final AtomicLong nextId; /** Neuron's features set size. */ private final int featureSize; /** Links. */ private final ConcurrentHashMap> linkMap - = new ConcurrentHashMap<>(); + = new ConcurrentHashMap>(); /** * Comparator that prescribes an order of the neurons according @@ -155,7 +155,7 @@ public synchronized Network copy() { } for (Map.Entry> e : linkMap.entrySet()) { - copy.linkMap.put(e.getKey(), new HashSet<>(e.getValue())); + copy.linkMap.put(e.getKey(), new HashSet(e.getValue())); } return copy; @@ -178,7 +178,7 @@ public Iterator iterator() { * @see NeuronIdentifierComparator */ public Collection getNeurons(Comparator comparator) { - final List neurons = new ArrayList<>(); + final List neurons = new ArrayList(); neurons.addAll(neuronMap.values()); Collections.sort(neurons, comparator); @@ -356,7 +356,7 @@ public Collection getNeighbours(Iterable neurons) { */ public Collection getNeighbours(Iterable neurons, Iterable exclude) { - final Set idList = new HashSet<>(); + final Set idList = new HashSet(); for (Neuron n : neurons) { idList.addAll(linkMap.get(n.getIdentifier())); @@ -367,7 +367,7 @@ public Collection getNeighbours(Iterable neurons, } } - final List neuronList = new ArrayList<>(); + final List neuronList = new ArrayList(); for (Long id : idList) { neuronList.add(getNeuron(id)); } @@ -403,7 +403,7 @@ public Collection getNeighbours(Neuron neuron, } } - final List neuronList = new ArrayList<>(); + final List neuronList = new ArrayList(); for (Long id : idList) { neuronList.add(getNeuron(id)); } diff --git a/src/main/java/org/apache/commons/math4/ml/neuralnet/Neuron.java b/src/main/java/org/apache/commons/math4/ml/neuralnet/Neuron.java index 61b3aa192f..56f19768a9 100644 --- a/src/main/java/org/apache/commons/math4/ml/neuralnet/Neuron.java +++ b/src/main/java/org/apache/commons/math4/ml/neuralnet/Neuron.java @@ -63,7 +63,7 @@ public class Neuron implements Serializable { double[] features) { this.identifier = identifier; this.size = features.length; - this.features = new AtomicReference<>(features.clone()); + this.features = new AtomicReference(features.clone()); } /** diff --git a/src/main/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenUpdateAction.java b/src/main/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenUpdateAction.java index 1c49d06380..87e1bbca21 100644 --- a/src/main/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenUpdateAction.java +++ b/src/main/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenUpdateAction.java @@ -111,10 +111,10 @@ public void update(Network net, if (currentNeighbourhood > 0) { // Initial set of neurons only contains the winning neuron. - Collection neighbours = new HashSet<>(); + Collection neighbours = new HashSet(); neighbours.add(best); // Winning neuron must be excluded from the neighbours. - final HashSet exclude = new HashSet<>(); + final HashSet exclude = new HashSet(); exclude.add(best); int radius = 1; diff --git a/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2D.java b/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2D.java index e42491d639..38bd608465 100644 --- a/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2D.java +++ b/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2D.java @@ -423,7 +423,7 @@ private int[] getLocation(int row, */ private void createLinks() { // "linkEnd" will store the identifiers of the "neighbours". - final List linkEnd = new ArrayList<>(); + final List linkEnd = new ArrayList(); final int iLast = numberOfRows - 1; final int jLast = numberOfColumns - 1; for (int i = 0; i < numberOfRows; i++) { diff --git a/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/util/LocationFinder.java b/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/util/LocationFinder.java index 7785f7b5dc..fa02e3aac6 100644 --- a/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/util/LocationFinder.java +++ b/src/main/java/org/apache/commons/math4/ml/neuralnet/twod/util/LocationFinder.java @@ -29,7 +29,7 @@ */ public class LocationFinder { /** Identifier to location mapping. */ - private final Map locations = new HashMap<>(); + private final Map locations = new HashMap(); /** * Container holding a (row, column) pair. diff --git a/src/main/java/org/apache/commons/math4/ode/AbstractFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/AbstractFieldIntegrator.java index 2475a482af..c61da98a18 100644 --- a/src/main/java/org/apache/commons/math4/ode/AbstractFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/AbstractFieldIntegrator.java @@ -95,10 +95,10 @@ public abstract class AbstractFieldIntegrator> imp protected AbstractFieldIntegrator(final Field field, final String name) { this.field = field; this.name = name; - stepHandlers = new ArrayList<>(); + stepHandlers = new ArrayList>(); stepStart = null; stepSize = null; - eventsStates = new ArrayList<>(); + eventsStates = new ArrayList>(); statesInitialized = false; evaluations = IntegerSequence.Incrementor.create().withMaximalCount(Integer.MAX_VALUE); } @@ -142,7 +142,7 @@ public void addEventHandler(final FieldEventHandler handler, final int maxIterationCount) { addEventHandler(handler, maxCheckInterval, convergence, maxIterationCount, - new FieldBracketingNthOrderBrentSolver<>(field.getZero().add(DEFAULT_RELATIVE_ACCURACY), + new FieldBracketingNthOrderBrentSolver(field.getZero().add(DEFAULT_RELATIVE_ACCURACY), field.getZero().add(convergence), field.getZero().add(DEFAULT_FUNCTION_VALUE_ACCURACY), 5)); @@ -155,14 +155,14 @@ public void addEventHandler(final FieldEventHandler handler, final double convergence, final int maxIterationCount, final BracketedRealFieldUnivariateSolver solver) { - eventsStates.add(new FieldEventState<>(handler, maxCheckInterval, field.getZero().add(convergence), + eventsStates.add(new FieldEventState(handler, maxCheckInterval, field.getZero().add(convergence), maxIterationCount, solver)); } /** {@inheritDoc} */ @Override public Collection> getEventHandlers() { - final List> list = new ArrayList<>(eventsStates.size()); + final List> list = new ArrayList>(eventsStates.size()); for (FieldEventState state : eventsStates) { list.add(state.getEventHandler()); } @@ -223,7 +223,7 @@ protected FieldODEStateAndDerivative initIntegration(final FieldExpandableODE // set up derivatives of initial state final T[] y0Dot = computeDerivatives(t0, y0); - final FieldODEStateAndDerivative state0 = new FieldODEStateAndDerivative<>(t0, y0, y0Dot); + final FieldODEStateAndDerivative state0 = new FieldODEStateAndDerivative(t0, y0, y0Dot); // initialize event handlers for (final FieldEventState state : eventsStates) { @@ -307,7 +307,7 @@ protected FieldODEStateAndDerivative acceptStep(final AbstractFieldStepInterp // search for next events that may occur during the step final int orderingSign = interpolator.isForward() ? +1 : -1; - SortedSet> occurringEvents = new TreeSet<>(new Comparator>() { + SortedSet> occurringEvents = new TreeSet>(new Comparator>() { /** {@inheritDoc} */ @Override 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 e4dd02f9e9..072889a002 100644 --- a/src/main/java/org/apache/commons/math4/ode/AbstractIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/AbstractIntegrator.java @@ -82,10 +82,10 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator { */ public AbstractIntegrator(final String name) { this.name = name; - stepHandlers = new ArrayList<>(); + stepHandlers = new ArrayList(); stepStart = Double.NaN; stepSize = Double.NaN; - eventsStates = new ArrayList<>(); + eventsStates = new ArrayList(); statesInitialized = false; evaluations = IntegerSequence.Incrementor.create().withMaximalCount(Integer.MAX_VALUE); } @@ -145,7 +145,7 @@ public void addEventHandler(final EventHandler handler, /** {@inheritDoc} */ @Override public Collection getEventHandlers() { - final List list = new ArrayList<>(eventsStates.size()); + final List list = new ArrayList(eventsStates.size()); for (EventState state : eventsStates) { list.add(state.getEventHandler()); } @@ -341,7 +341,7 @@ protected double acceptStep(final AbstractStepInterpolator interpolator, // search for next events that may occur during the step final int orderingSign = interpolator.isForward() ? +1 : -1; - SortedSet occurringEvents = new TreeSet<>(new Comparator() { + SortedSet occurringEvents = new TreeSet(new Comparator() { /** {@inheritDoc} */ @Override diff --git a/src/main/java/org/apache/commons/math4/ode/AbstractParameterizable.java b/src/main/java/org/apache/commons/math4/ode/AbstractParameterizable.java index c21365d648..5b4aea7180 100644 --- a/src/main/java/org/apache/commons/math4/ode/AbstractParameterizable.java +++ b/src/main/java/org/apache/commons/math4/ode/AbstractParameterizable.java @@ -33,7 +33,7 @@ public abstract class AbstractParameterizable implements Parameterizable { * @param names names of the supported parameters */ protected AbstractParameterizable(final String ... names) { - parametersNames = new ArrayList<>(); + parametersNames = new ArrayList(); for (final String name : names) { parametersNames.add(name); } @@ -43,7 +43,7 @@ protected AbstractParameterizable(final String ... names) { * @param names names of the supported parameters */ protected AbstractParameterizable(final Collection names) { - parametersNames = new ArrayList<>(); + parametersNames = new ArrayList(); parametersNames.addAll(names); } diff --git a/src/main/java/org/apache/commons/math4/ode/ContinuousOutputFieldModel.java b/src/main/java/org/apache/commons/math4/ode/ContinuousOutputFieldModel.java index b1d8be2156..e8b96a1a7f 100644 --- a/src/main/java/org/apache/commons/math4/ode/ContinuousOutputFieldModel.java +++ b/src/main/java/org/apache/commons/math4/ode/ContinuousOutputFieldModel.java @@ -100,7 +100,7 @@ public class ContinuousOutputFieldModel> * Build an empty continuous output model. */ public ContinuousOutputFieldModel() { - steps = new ArrayList<>(); + steps = new ArrayList>(); initialTime = null; finalTime = null; forward = true; diff --git a/src/main/java/org/apache/commons/math4/ode/ContinuousOutputModel.java b/src/main/java/org/apache/commons/math4/ode/ContinuousOutputModel.java index 8f63847690..e48dff9340 100644 --- a/src/main/java/org/apache/commons/math4/ode/ContinuousOutputModel.java +++ b/src/main/java/org/apache/commons/math4/ode/ContinuousOutputModel.java @@ -111,7 +111,7 @@ public class ContinuousOutputModel * Build an empty continuous output model. */ public ContinuousOutputModel() { - steps = new ArrayList<>(); + steps = new ArrayList(); initialTime = Double.NaN; finalTime = Double.NaN; forward = true; diff --git a/src/main/java/org/apache/commons/math4/ode/ExpandableStatefulODE.java b/src/main/java/org/apache/commons/math4/ode/ExpandableStatefulODE.java index 476b9ffb63..77e50bcf8d 100644 --- a/src/main/java/org/apache/commons/math4/ode/ExpandableStatefulODE.java +++ b/src/main/java/org/apache/commons/math4/ode/ExpandableStatefulODE.java @@ -76,7 +76,7 @@ public ExpandableStatefulODE(final FirstOrderDifferentialEquations primary) { this.time = Double.NaN; this.primaryState = new double[n]; this.primaryStateDot = new double[n]; - this.components = new ArrayList<>(); + this.components = new ArrayList(); } /** Get the primary set of differential equations. @@ -138,7 +138,7 @@ public int addSecondaryEquations(final SecondaryEquations secondary) { final int firstIndex; if (components.isEmpty()) { // lazy creation of the components list - components = new ArrayList<>(); + components = new ArrayList(); firstIndex = primary.getDimension(); } else { final SecondaryComponent last = components.get(components.size() - 1); diff --git a/src/main/java/org/apache/commons/math4/ode/FieldEquationsMapper.java b/src/main/java/org/apache/commons/math4/ode/FieldEquationsMapper.java index cafdd662bb..1febe7d831 100644 --- a/src/main/java/org/apache/commons/math4/ode/FieldEquationsMapper.java +++ b/src/main/java/org/apache/commons/math4/ode/FieldEquationsMapper.java @@ -130,7 +130,7 @@ public FieldODEStateAndDerivative mapStateAndDerivative(final T t, final T[] final T[] state = extractEquationData(index, y); final T[] derivative = extractEquationData(index, yDot); if (n < 2) { - return new FieldODEStateAndDerivative<>(t, state, derivative); + return new FieldODEStateAndDerivative(t, state, derivative); } else { final T[][] secondaryState = MathArrays.buildArray(t.getField(), n - 1, -1); final T[][] secondaryDerivative = MathArrays.buildArray(t.getField(), n - 1, -1); @@ -138,7 +138,7 @@ public FieldODEStateAndDerivative mapStateAndDerivative(final T t, final T[] secondaryState[index - 1] = extractEquationData(index, y); secondaryDerivative[index - 1] = extractEquationData(index, yDot); } - return new FieldODEStateAndDerivative<>(t, state, derivative, secondaryState, secondaryDerivative); + return new FieldODEStateAndDerivative(t, state, derivative, secondaryState, secondaryDerivative); } } diff --git a/src/main/java/org/apache/commons/math4/ode/FieldExpandableODE.java b/src/main/java/org/apache/commons/math4/ode/FieldExpandableODE.java index 8dddaad83e..e5dd205db8 100644 --- a/src/main/java/org/apache/commons/math4/ode/FieldExpandableODE.java +++ b/src/main/java/org/apache/commons/math4/ode/FieldExpandableODE.java @@ -65,8 +65,8 @@ public class FieldExpandableODE> { */ public FieldExpandableODE(final FirstOrderFieldDifferentialEquations primary) { this.primary = primary; - this.components = new ArrayList<>(); - this.mapper = new FieldEquationsMapper<>(null, primary.getDimension()); + this.components = new ArrayList>(); + this.mapper = new FieldEquationsMapper(null, primary.getDimension()); } /** Get the mapper for the set of equations. @@ -86,7 +86,7 @@ public FieldEquationsMapper getMapper() { public int addSecondaryEquations(final FieldSecondaryEquations secondary) { components.add(secondary); - mapper = new FieldEquationsMapper<>(mapper, secondary.getDimension()); + mapper = new FieldEquationsMapper(mapper, secondary.getDimension()); return components.size(); diff --git a/src/main/java/org/apache/commons/math4/ode/JacobianMatrices.java b/src/main/java/org/apache/commons/math4/ode/JacobianMatrices.java index 2efed92c6d..1296620329 100644 --- a/src/main/java/org/apache/commons/math4/ode/JacobianMatrices.java +++ b/src/main/java/org/apache/commons/math4/ode/JacobianMatrices.java @@ -141,7 +141,7 @@ public JacobianMatrices(final MainStateJacobianProvider jode, } this.dirtyParameter = false; - this.jacobianProviders = new ArrayList<>(); + this.jacobianProviders = new ArrayList(); // set the default initial state Jacobian to the identity // and the default initial parameters Jacobian to the null matrix diff --git a/src/main/java/org/apache/commons/math4/ode/MultistepFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/MultistepFieldIntegrator.java index edd65e2614..fdb1d907c3 100644 --- a/src/main/java/org/apache/commons/math4/ode/MultistepFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/MultistepFieldIntegrator.java @@ -130,7 +130,7 @@ protected MultistepFieldIntegrator(final Field field, final String name, nSteps, 2, true); } - starter = new DormandPrince853FieldIntegrator<>(field, minStep, maxStep, + starter = new DormandPrince853FieldIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); this.nSteps = nSteps; @@ -170,7 +170,7 @@ protected MultistepFieldIntegrator(final Field field, final String name, fina final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) { super(field, name, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); - starter = new DormandPrince853FieldIntegrator<>(field, minStep, maxStep, + starter = new DormandPrince853FieldIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); this.nSteps = nSteps; diff --git a/src/main/java/org/apache/commons/math4/ode/ParameterJacobianWrapper.java b/src/main/java/org/apache/commons/math4/ode/ParameterJacobianWrapper.java index e28c185e75..d555aa471d 100644 --- a/src/main/java/org/apache/commons/math4/ode/ParameterJacobianWrapper.java +++ b/src/main/java/org/apache/commons/math4/ode/ParameterJacobianWrapper.java @@ -51,7 +51,7 @@ class ParameterJacobianWrapper implements ParameterJacobianProvider { final ParameterConfiguration[] paramsAndSteps) { this.fode = fode; this.pode = pode; - this.hParam = new HashMap<>(); + this.hParam = new HashMap(); // set up parameters for jacobian computation for (final ParameterConfiguration param : paramsAndSteps) { diff --git a/src/main/java/org/apache/commons/math4/ode/ParameterizedWrapper.java b/src/main/java/org/apache/commons/math4/ode/ParameterizedWrapper.java index 0d2521d6fb..c306ec875f 100644 --- a/src/main/java/org/apache/commons/math4/ode/ParameterizedWrapper.java +++ b/src/main/java/org/apache/commons/math4/ode/ParameterizedWrapper.java @@ -61,7 +61,7 @@ public void computeDerivatives(double t, double[] y, double[] yDot) /** {@inheritDoc} */ @Override public Collection getParametersNames() { - return new ArrayList<>(); + return new ArrayList(); } /** {@inheritDoc} */ diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegrator.java index ebb31f0aa3..977573e3f5 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegrator.java @@ -301,7 +301,7 @@ public FieldODEStateAndDerivative integrate(final FieldExpandableODE equat } // discrete events handling - setStepStart(acceptStep(new AdamsFieldStepInterpolator<>(getStepSize(), stepEnd, + setStepStart(acceptStep(new AdamsFieldStepInterpolator(getStepSize(), stepEnd, predictedScaled, predictedNordsieck, forward, getStepStart(), stepEnd, equations.getMapper()), diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldStepInterpolator.java index feac005cfe..b4b5357c41 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldStepInterpolator.java @@ -103,7 +103,7 @@ private AdamsFieldStepInterpolator(final T stepSize, final FieldODEStateAndDeriv this.scalingH = stepSize; this.reference = reference; this.scaled = scaled.clone(); - this.nordsieck = new Array2DRowFieldMatrix<>(nordsieck.getData(), false); + this.nordsieck = new Array2DRowFieldMatrix(nordsieck.getData(), false); } /** Create a new instance. @@ -121,7 +121,7 @@ protected AdamsFieldStepInterpolator create(boolean newForward, FieldODEStateAndDerivative newSoftPreviousState, FieldODEStateAndDerivative newSoftCurrentState, FieldEquationsMapper newMapper) { - return new AdamsFieldStepInterpolator<>(scalingH, reference, scaled, nordsieck, + return new AdamsFieldStepInterpolator(scalingH, reference, scaled, nordsieck, newForward, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, @@ -181,7 +181,7 @@ public static > FieldODEStateAndDerivative tayl estimatedDerivatives[j].add(scaled[j].multiply(normalizedAbscissa)).divide(x); } - return new FieldODEStateAndDerivative<>(time, estimatedState, estimatedDerivatives); + return new FieldODEStateAndDerivative(time, estimatedState, estimatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegrator.java index 72d4de225b..c659cc003d 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegrator.java @@ -284,8 +284,8 @@ public FieldODEStateAndDerivative integrate(final FieldExpandableODE equat updateHighOrderDerivativesPhase2(predictedScaled, correctedScaled, predictedNordsieck); // discrete events handling - stepEnd = new FieldODEStateAndDerivative<>(stepEnd.getTime(), predictedY, correctedYDot); - setStepStart(acceptStep(new AdamsFieldStepInterpolator<>(getStepSize(), stepEnd, + stepEnd = new FieldODEStateAndDerivative(stepEnd.getTime(), predictedY, correctedYDot); + setStepStart(acceptStep(new AdamsFieldStepInterpolator(getStepSize(), stepEnd, correctedScaled, predictedNordsieck, forward, getStepStart(), stepEnd, equations.getMapper()), diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckFieldTransformer.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckFieldTransformer.java index 7c2b872f70..c1e5beea59 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckFieldTransformer.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckFieldTransformer.java @@ -137,7 +137,8 @@ public class AdamsNordsieckFieldTransformer> { private static final Map>, AdamsNordsieckFieldTransformer>>> CACHE = - new HashMap<>(); + new HashMap>, + AdamsNordsieckFieldTransformer>>>(); /** Field to which the time and state vector elements belong. */ private final Field field; @@ -161,11 +162,11 @@ private AdamsNordsieckFieldTransformer(final Field field, final int n) { // compute coefficients FieldMatrix bigP = buildP(rows); FieldDecompositionSolver pSolver = - new FieldLUDecomposition<>(bigP).getSolver(); + new FieldLUDecomposition(bigP).getSolver(); T[] u = MathArrays.buildArray(field, rows); Arrays.fill(u, field.getOne()); - c1 = pSolver.solve(new ArrayFieldVector<>(u, false)).toArray(); + c1 = pSolver.solve(new ArrayFieldVector(u, false)).toArray(); // update coefficients are computed by combining transform from // Nordsieck to multistep, then shifting rows to represent step advance @@ -177,7 +178,7 @@ private AdamsNordsieckFieldTransformer(final Field field, final int n) { } shiftedP[0] = MathArrays.buildArray(field, rows); Arrays.fill(shiftedP[0], field.getZero()); - update = new Array2DRowFieldMatrix<>(pSolver.solve(new Array2DRowFieldMatrix<>(shiftedP, false)).getData()); + update = new Array2DRowFieldMatrix(pSolver.solve(new Array2DRowFieldMatrix(shiftedP, false)).getData()); } @@ -194,13 +195,14 @@ private AdamsNordsieckFieldTransformer(final Field field, final int n) { Map>, AdamsNordsieckFieldTransformer>> map = CACHE.get(nSteps); if (map == null) { - map = new HashMap<>(); + map = new HashMap>, + AdamsNordsieckFieldTransformer>>(); CACHE.put(nSteps, map); } @SuppressWarnings("unchecked") AdamsNordsieckFieldTransformer t = (AdamsNordsieckFieldTransformer) map.get(field); if (t == null) { - t = new AdamsNordsieckFieldTransformer<>(field, nSteps); + t = new AdamsNordsieckFieldTransformer(field, nSteps); map.put(field, t); } return t; @@ -237,7 +239,7 @@ private FieldMatrix buildP(final int rows) { } } - return new Array2DRowFieldMatrix<>(pData, false); + return new Array2DRowFieldMatrix(pData, false); } @@ -301,12 +303,12 @@ public Array2DRowFieldMatrix initializeHighOrderDerivatives(final T h, final // solve the linear system to get the best estimate of the Nordsieck vector [s2 ... sk], // with the additional terms s(k+1) and c grabbing the parts after the truncated Taylor expansion - final FieldLUDecomposition decomposition = new FieldLUDecomposition<>(new Array2DRowFieldMatrix<>(a, false)); - final FieldMatrix x = decomposition.getSolver().solve(new Array2DRowFieldMatrix<>(b, false)); + final FieldLUDecomposition decomposition = new FieldLUDecomposition(new Array2DRowFieldMatrix(a, false)); + final FieldMatrix x = decomposition.getSolver().solve(new Array2DRowFieldMatrix(b, false)); // extract just the Nordsieck vector [s2 ... sk] final Array2DRowFieldMatrix truncatedX = - new Array2DRowFieldMatrix<>(field, x.getRowDimension() - 1, x.getColumnDimension()); + new Array2DRowFieldMatrix(field, x.getRowDimension() - 1, x.getColumnDimension()); for (int i = 0; i < truncatedX.getRowDimension(); ++i) { for (int j = 0; j < truncatedX.getColumnDimension(); ++j) { truncatedX.setEntry(i, j, x.getEntry(i, j)); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckTransformer.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckTransformer.java index f38e61af8a..86bc871064 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckTransformer.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/AdamsNordsieckTransformer.java @@ -136,7 +136,7 @@ public class AdamsNordsieckTransformer { /** Cache for already computed coefficients. */ private static final Map CACHE = - new HashMap<>(); + new HashMap(); /** Update matrix for the higher order derivatives h2/2 y'', h3/6 y''' ... */ private final Array2DRowRealMatrix update; @@ -155,11 +155,11 @@ private AdamsNordsieckTransformer(final int n) { // compute exact coefficients FieldMatrix bigP = buildP(rows); FieldDecompositionSolver pSolver = - new FieldLUDecomposition<>(bigP).getSolver(); + new FieldLUDecomposition(bigP).getSolver(); BigFraction[] u = new BigFraction[rows]; Arrays.fill(u, BigFraction.ONE); - BigFraction[] bigC1 = pSolver.solve(new ArrayFieldVector<>(u, false)).toArray(); + BigFraction[] bigC1 = pSolver.solve(new ArrayFieldVector(u, false)).toArray(); // update coefficients are computed by combining transform from // Nordsieck to multistep, then shifting rows to represent step advance @@ -172,7 +172,7 @@ private AdamsNordsieckTransformer(final int n) { shiftedP[0] = new BigFraction[rows]; Arrays.fill(shiftedP[0], BigFraction.ZERO); FieldMatrix bigMSupdate = - pSolver.solve(new Array2DRowFieldMatrix<>(shiftedP, false)); + pSolver.solve(new Array2DRowFieldMatrix(shiftedP, false)); // convert coefficients to double update = MatrixUtils.bigFractionMatrixToRealMatrix(bigMSupdate); @@ -239,7 +239,7 @@ private FieldMatrix buildP(final int rows) { } } - return new Array2DRowFieldMatrix<>(pData, false); + return new Array2DRowFieldMatrix(pData, false); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java index 56add60dee..315924a906 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java @@ -105,7 +105,7 @@ public T[] getB() { final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new ClassicalRungeKuttaFieldStepInterpolator<>(getField(), forward, yDotK, + return new ClassicalRungeKuttaFieldStepInterpolator(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldStepInterpolator.java index c4d1263fd3..522530b515 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldStepInterpolator.java @@ -89,7 +89,7 @@ protected ClassicalRungeKuttaFieldStepInterpolator create(final Field newF final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new ClassicalRungeKuttaFieldStepInterpolator<>(newField, newForward, newYDotK, + return new ClassicalRungeKuttaFieldStepInterpolator(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -129,7 +129,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(coeffDot1, coeffDot23, coeffDot23, coeffDot4); } - return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegrator.java index 12d7a64751..b8ec110e84 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegrator.java @@ -193,7 +193,7 @@ public T[] getB() { createInterpolator(final boolean forward, T[][] yDotK, final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new DormandPrince54FieldStepInterpolator<>(getField(), forward, yDotK, + return new DormandPrince54FieldStepInterpolator(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolator.java index 61548ce76e..16a2fe4151 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolator.java @@ -114,7 +114,7 @@ protected DormandPrince54FieldStepInterpolator create(final Field newField final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new DormandPrince54FieldStepInterpolator<>(newField, newForward, newYDotK, + return new DormandPrince54FieldStepInterpolator(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -242,7 +242,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(coeffDot0, coeffDot1, coeffDot2, coeffDot3, coeffDot4, coeffDot5, coeffDot6); } - return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegrator.java index b40eb5088d..171b46524d 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegrator.java @@ -399,7 +399,7 @@ public T[] getB() { createInterpolator(final boolean forward, T[][] yDotK, final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new DormandPrince853FieldStepInterpolator<>(getField(), forward, yDotK, + return new DormandPrince853FieldStepInterpolator(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolator.java index 5228dd2117..e4d7ee526b 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolator.java @@ -195,7 +195,7 @@ protected DormandPrince853FieldStepInterpolator create(final Field newFiel final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new DormandPrince853FieldStepInterpolator<>(newField, newForward, newYDotK, + return new DormandPrince853FieldStepInterpolator(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -295,7 +295,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f q[8], q[9], q[10], q[11], q[12], q[13], q[14], q[15]); } - return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegrator.java index 6238953fb0..acba7a5134 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegrator.java @@ -309,7 +309,7 @@ public FieldODEStateAndDerivative integrate(final FieldExpandableODE equat } final T stepEnd = getStepStart().getTime().add(getStepSize()); final T[] yDotTmp = (fsal >= 0) ? yDotK[fsal] : computeDerivatives(stepEnd, yTmp); - final FieldODEStateAndDerivative stateTmp = new FieldODEStateAndDerivative<>(stepEnd, yTmp, yDotTmp); + final FieldODEStateAndDerivative stateTmp = new FieldODEStateAndDerivative(stepEnd, yTmp, yDotTmp); // local error is small enough: accept the step, trigger events and step handlers System.arraycopy(yTmp, 0, y, 0, y0.length); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegrator.java index 503231c2a6..ce87431110 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegrator.java @@ -90,7 +90,7 @@ public T[] getB() { final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new EulerFieldStepInterpolator<>(getField(), forward, yDotK, + return new EulerFieldStepInterpolator(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolator.java index 43b8a53779..e57865ac85 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolator.java @@ -79,7 +79,7 @@ protected EulerFieldStepInterpolator create(final Field newField, final bo final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new EulerFieldStepInterpolator<>(newField, newForward, newYDotK, + return new EulerFieldStepInterpolator(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -101,7 +101,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(time.getField().getOne()); } - return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegrator.java index 0ee8b5dedc..1fc66887c2 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegrator.java @@ -115,7 +115,7 @@ public T[] getB() { final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new GillFieldStepInterpolator<>(getField(), forward, yDotK, + return new GillFieldStepInterpolator(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolator.java index df474308e9..bb00d04d6b 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolator.java @@ -97,7 +97,7 @@ protected GillFieldStepInterpolator create(final Field newField, final boo final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new GillFieldStepInterpolator<>(newField, newForward, newYDotK, + return new GillFieldStepInterpolator(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -141,7 +141,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(coeffDot1, coeffDot2, coeffDot3, coeffDot4); } - return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegrator.java index e88467e95a..0f8353af46 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegrator.java @@ -168,7 +168,7 @@ public T[] getB() { createInterpolator(final boolean forward, T[][] yDotK, final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new HighamHall54FieldStepInterpolator<>(getField(), forward, yDotK, + return new HighamHall54FieldStepInterpolator(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolator.java index fd8f5cff24..a915e26487 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolator.java @@ -65,7 +65,7 @@ protected HighamHall54FieldStepInterpolator create(final Field newField, f final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new HighamHall54FieldStepInterpolator<>(newField, newForward, newYDotK, + return new HighamHall54FieldStepInterpolator(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -109,7 +109,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(bDot0, bDot1, bDot2, bDot3, bDot4, bDot5); } - return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegrator.java index b3c1424429..1c3301c8b6 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegrator.java @@ -140,7 +140,7 @@ public T[] getB() { final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new LutherFieldStepInterpolator<>(getField(), forward, yDotK, + return new LutherFieldStepInterpolator(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolator.java index df5ea6a25a..438e09e41a 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolator.java @@ -125,7 +125,7 @@ protected LutherFieldStepInterpolator create(final Field newField, final b final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new LutherFieldStepInterpolator<>(newField, newForward, newYDotK, + return new LutherFieldStepInterpolator(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -217,7 +217,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(coeffDot1, coeffDot2, coeffDot3, coeffDot4, coeffDot5, coeffDot6, coeffDot7); } - return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegrator.java index 3b604e37f8..af5a867f39 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegrator.java @@ -90,7 +90,7 @@ public T[] getB() { final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new MidpointFieldStepInterpolator<>(getField(), forward, yDotK, + return new MidpointFieldStepInterpolator(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolator.java index f64012eabe..03bd70d848 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolator.java @@ -81,7 +81,7 @@ protected MidpointFieldStepInterpolator create(final Field newField, final final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new MidpointFieldStepInterpolator<>(newField, newForward, newYDotK, + return new MidpointFieldStepInterpolator(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -111,7 +111,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(coeffDot1, coeffDot2); } - return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegrator.java index f07bbae731..8956fa4e27 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegrator.java @@ -177,7 +177,7 @@ public FieldODEStateAndDerivative integrate(final FieldExpandableODE equat } final T stepEnd = getStepStart().getTime().add(getStepSize()); final T[] yDotTmp = computeDerivatives(stepEnd, yTmp); - final FieldODEStateAndDerivative stateTmp = new FieldODEStateAndDerivative<>(stepEnd, yTmp, yDotTmp); + final FieldODEStateAndDerivative stateTmp = new FieldODEStateAndDerivative(stepEnd, yTmp, yDotTmp); // discrete events handling System.arraycopy(yTmp, 0, y, 0, y0.length); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegrator.java index 8169d75398..4a786f55ed 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegrator.java @@ -104,7 +104,7 @@ public T[] getB() { final FieldODEStateAndDerivative globalPreviousState, final FieldODEStateAndDerivative globalCurrentState, final FieldEquationsMapper mapper) { - return new ThreeEighthesFieldStepInterpolator<>(getField(), forward, yDotK, + return new ThreeEighthesFieldStepInterpolator(getField(), forward, yDotK, globalPreviousState, globalCurrentState, globalPreviousState, globalCurrentState, mapper); diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolator.java index b41f91a550..69df7f8054 100644 --- a/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolator.java @@ -91,7 +91,7 @@ protected ThreeEighthesFieldStepInterpolator create(final Field newField, final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new ThreeEighthesFieldStepInterpolator<>(newField, newForward, newYDotK, + return new ThreeEighthesFieldStepInterpolator(newField, newForward, newYDotK, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); @@ -132,7 +132,7 @@ protected FieldODEStateAndDerivative computeInterpolatedStateAndDerivatives(f interpolatedDerivatives = derivativeLinearCombination(coeffDot1, coeffDot2, coeffDot3, coeffDot4); } - return new FieldODEStateAndDerivative<>(time, interpolatedState, interpolatedDerivatives); + return new FieldODEStateAndDerivative(time, interpolatedState, interpolatedDerivatives); } diff --git a/src/main/java/org/apache/commons/math4/optim/linear/LinearConstraintSet.java b/src/main/java/org/apache/commons/math4/optim/linear/LinearConstraintSet.java index 3dcc2a1af9..7a31698714 100644 --- a/src/main/java/org/apache/commons/math4/optim/linear/LinearConstraintSet.java +++ b/src/main/java/org/apache/commons/math4/optim/linear/LinearConstraintSet.java @@ -30,7 +30,7 @@ */ public class LinearConstraintSet implements OptimizationData { /** Set of constraints. */ - private final Set linearConstraints = new LinkedHashSet<>(); + private final Set linearConstraints = new LinkedHashSet(); /** * Creates a set containing the given constraints. diff --git a/src/main/java/org/apache/commons/math4/optim/linear/SimplexSolver.java b/src/main/java/org/apache/commons/math4/optim/linear/SimplexSolver.java index 04b6ab94d8..a835765ea7 100644 --- a/src/main/java/org/apache/commons/math4/optim/linear/SimplexSolver.java +++ b/src/main/java/org/apache/commons/math4/optim/linear/SimplexSolver.java @@ -247,7 +247,7 @@ private boolean isValidPivotColumn(SimplexTableau tableau, int col) { */ private Integer getPivotRow(SimplexTableau tableau, final int col) { // create a list of all the rows that tie for the lowest score in the minimum ratio test - List minRatioPositions = new ArrayList<>(); + List minRatioPositions = new ArrayList(); double minRatio = Double.MAX_VALUE; for (int i = tableau.getNumObjectiveFunctions(); i < tableau.getHeight(); i++) { final double rhs = tableau.getEntry(i, tableau.getWidth() - 1); diff --git a/src/main/java/org/apache/commons/math4/optim/linear/SimplexTableau.java b/src/main/java/org/apache/commons/math4/optim/linear/SimplexTableau.java index 02ee6641d3..7d6c8f0035 100644 --- a/src/main/java/org/apache/commons/math4/optim/linear/SimplexTableau.java +++ b/src/main/java/org/apache/commons/math4/optim/linear/SimplexTableau.java @@ -78,7 +78,7 @@ class SimplexTableau implements Serializable { private final boolean restrictToNonNegative; /** The variables each column represents */ - private final List columnLabels = new ArrayList<>(); + private final List columnLabels = new ArrayList(); /** Simple tableau. */ private transient Array2DRowRealMatrix tableau; @@ -272,7 +272,7 @@ protected Array2DRowRealMatrix createTableau(final boolean maximize) { * @return new versions of the constraints */ public List normalizeConstraints(Collection originalConstraints) { - List normalized = new ArrayList<>(originalConstraints.size()); + List normalized = new ArrayList(originalConstraints.size()); for (LinearConstraint constraint : originalConstraints) { normalized.add(normalize(constraint)); } @@ -395,7 +395,7 @@ protected void dropPhase1Objective() { return; } - final Set columnsToDrop = new TreeSet<>(); + final Set columnsToDrop = new TreeSet(); columnsToDrop.add(0); // positive cost non-artificial variables @@ -469,7 +469,7 @@ protected PointValuePair getSolution() { Integer negativeVarBasicRow = negativeVarColumn > 0 ? getBasicRow(negativeVarColumn) : null; double mostNegative = negativeVarBasicRow == null ? 0 : getEntry(negativeVarBasicRow, getRhsOffset()); - final Set usedBasicRows = new HashSet<>(); + final Set usedBasicRows = new HashSet(); final double[] coefficients = new double[getOriginalNumDecisionVariables()]; for (int i = 0; i < coefficients.length; i++) { int colIndex = columnLabels.indexOf("x" + i); diff --git a/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizer.java b/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizer.java index 49bf465c87..d059868310 100644 --- a/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizer.java +++ b/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizer.java @@ -41,7 +41,7 @@ public class MultiStartMultivariateOptimizer /** Underlying optimizer. */ private final MultivariateOptimizer optimizer; /** Found optima. */ - private final List optima = new ArrayList<>(); + private final List optima = new ArrayList(); /** * Create a multi-start optimizer from a single-start optimizer. diff --git a/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java b/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java index 2a62609659..727fd18481 100644 --- a/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java +++ b/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java @@ -199,13 +199,13 @@ public class CMAESOptimizer private final RandomGenerator random; /** History of sigma values. */ - private final List statisticsSigmaHistory = new ArrayList<>(); + private final List statisticsSigmaHistory = new ArrayList(); /** History of mean matrix. */ - private final List statisticsMeanHistory = new ArrayList<>(); + private final List statisticsMeanHistory = new ArrayList(); /** History of fitness values. */ - private final List statisticsFitnessHistory = new ArrayList<>(); + private final List statisticsFitnessHistory = new ArrayList(); /** History of D matrix. */ - private final List statisticsDHistory = new ArrayList<>(); + private final List statisticsDHistory = new ArrayList(); /** * @param maxIterations Maximal number of iterations. diff --git a/src/main/java/org/apache/commons/math4/primes/SmallPrimes.java b/src/main/java/org/apache/commons/math4/primes/SmallPrimes.java index 6f329e3c4c..0738cd2490 100644 --- a/src/main/java/org/apache/commons/math4/primes/SmallPrimes.java +++ b/src/main/java/org/apache/commons/math4/primes/SmallPrimes.java @@ -125,7 +125,7 @@ public static int boundedTrialDivision(int n, int maxFactor, List facto * @return the list of prime factors of n */ public static List trialDivision(int n){ - final List factors = new ArrayList<>(32); + final List factors = new ArrayList(32); n = smallTrialDivision(n, factors); if (1 == n) { return factors; diff --git a/src/main/java/org/apache/commons/math4/random/EmpiricalDistribution.java b/src/main/java/org/apache/commons/math4/random/EmpiricalDistribution.java index f774ce386f..6d2722e133 100644 --- a/src/main/java/org/apache/commons/math4/random/EmpiricalDistribution.java +++ b/src/main/java/org/apache/commons/math4/random/EmpiricalDistribution.java @@ -195,7 +195,7 @@ private EmpiricalDistribution(int binCount, } this.binCount = binCount; this.randomData = randomData; - binStats = new ArrayList<>(); + binStats = new ArrayList(); } /** diff --git a/src/main/java/org/apache/commons/math4/stat/Frequency.java b/src/main/java/org/apache/commons/math4/stat/Frequency.java index f6767200b3..d032c75dd6 100644 --- a/src/main/java/org/apache/commons/math4/stat/Frequency.java +++ b/src/main/java/org/apache/commons/math4/stat/Frequency.java @@ -74,7 +74,7 @@ public class Frequency implements Serializable { * Default constructor. */ public Frequency() { - freqTable = new TreeMap<>(); + freqTable = new TreeMap, Long>(); } /** @@ -84,7 +84,7 @@ public Frequency() { */ @SuppressWarnings("unchecked") // TODO is the cast OK? public Frequency(Comparator comparator) { - freqTable = new TreeMap<>((Comparator>) comparator); + freqTable = new TreeMap, Long>((Comparator>) comparator); } /** @@ -574,7 +574,7 @@ public List> getMode() { } } - List> modeList = new ArrayList<>(); + List> modeList = new ArrayList>(); for (Entry, Long> ent : freqTable.entrySet()) { long frequency = ent.getValue().longValue(); if (frequency == mostPopular) { diff --git a/src/main/java/org/apache/commons/math4/stat/correlation/KendallsCorrelation.java b/src/main/java/org/apache/commons/math4/stat/correlation/KendallsCorrelation.java index 32ed6d01f9..8df17eabb0 100644 --- a/src/main/java/org/apache/commons/math4/stat/correlation/KendallsCorrelation.java +++ b/src/main/java/org/apache/commons/math4/stat/correlation/KendallsCorrelation.java @@ -164,7 +164,7 @@ public double correlation(final double[] xArray, final double[] yArray) @SuppressWarnings("unchecked") Pair[] pairs = new Pair[n]; for (int i = 0; i < n; i++) { - pairs[i] = new Pair<>(xArray[i], yArray[i]); + pairs[i] = new Pair(xArray[i], yArray[i]); } Arrays.sort(pairs, new Comparator>() { diff --git a/src/main/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentile.java b/src/main/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentile.java index c81a4d1514..7ba2d16aeb 100644 --- a/src/main/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentile.java +++ b/src/main/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentile.java @@ -81,7 +81,7 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic * Initial list of 5 numbers corresponding to 5 markers. NOTE:watch * out for the add methods that are overloaded */ - private final List initialFive = new FixedCapacityList<>(PSQUARE_CONSTANT); + private final List initialFive = new FixedCapacityList(PSQUARE_CONSTANT); /** * The quantile needed should be in range of 0-1. The constructor diff --git a/src/main/java/org/apache/commons/math4/stat/inference/KolmogorovSmirnovTest.java b/src/main/java/org/apache/commons/math4/stat/inference/KolmogorovSmirnovTest.java index b331ff5c84..04296a3014 100644 --- a/src/main/java/org/apache/commons/math4/stat/inference/KolmogorovSmirnovTest.java +++ b/src/main/java/org/apache/commons/math4/stat/inference/KolmogorovSmirnovTest.java @@ -821,7 +821,7 @@ private FieldMatrix createExactH(double d, int n) } } } - return new Array2DRowFieldMatrix<>(BigFractionField.getInstance(), Hdata); + return new Array2DRowFieldMatrix(BigFractionField.getInstance(), Hdata); } /*** @@ -1181,7 +1181,7 @@ private static void fixTies(double[] x, double[] y) { * @return true if x and y together contain ties */ private static boolean hasTies(double[] x, double[] y) { - final HashSet values = new HashSet<>(); + final HashSet values = new HashSet(); for (int i = 0; i < x.length; i++) { if (!values.add(x[i])) { return true; diff --git a/src/main/java/org/apache/commons/math4/stat/inference/OneWayAnova.java b/src/main/java/org/apache/commons/math4/stat/inference/OneWayAnova.java index 5afaa4a703..90f4e9680a 100644 --- a/src/main/java/org/apache/commons/math4/stat/inference/OneWayAnova.java +++ b/src/main/java/org/apache/commons/math4/stat/inference/OneWayAnova.java @@ -195,7 +195,7 @@ private AnovaStats anovaStats(final Collection categoryData) MathUtils.checkNotNull(categoryData); final Collection categoryDataSummaryStatistics = - new ArrayList<>(categoryData.size()); + new ArrayList(categoryData.size()); // convert arrays to SummaryStatistics for (final double[] data : categoryData) { diff --git a/src/main/java/org/apache/commons/math4/stat/ranking/NaturalRanking.java b/src/main/java/org/apache/commons/math4/stat/ranking/NaturalRanking.java index e301959880..d6efc09e69 100644 --- a/src/main/java/org/apache/commons/math4/stat/ranking/NaturalRanking.java +++ b/src/main/java/org/apache/commons/math4/stat/ranking/NaturalRanking.java @@ -230,7 +230,7 @@ public double[] rank(double[] data) { double[] out = new double[ranks.length]; int pos = 1; // position in sorted array out[ranks[0].getPosition()] = pos; - List tiesTrace = new ArrayList<>(); + List tiesTrace = new ArrayList(); tiesTrace.add(ranks[0].getPosition()); for (int i = 1; i < ranks.length; i++) { if (Double.compare(ranks[i].getValue(), ranks[i - 1].getValue()) > 0) { @@ -239,7 +239,7 @@ public double[] rank(double[] data) { if (tiesTrace.size() > 1) { // if seq is nontrivial, resolve resolveTie(out, tiesTrace); } - tiesTrace = new ArrayList<>(); + tiesTrace = new ArrayList(); tiesTrace.add(ranks[i].getPosition()); } else { // tie sequence continues @@ -410,7 +410,7 @@ private void restoreNaNs(double[] ranks, List nanPositions) { * @return list of indexes i such that ranks[i] = NaN */ private List getNanPositions(IntDoublePair[] ranks) { - ArrayList out = new ArrayList<>(); + ArrayList out = new ArrayList(); for (int i = 0; i < ranks.length; i++) { if (Double.isNaN(ranks[i].getValue())) { out.add(Integer.valueOf(i)); diff --git a/src/main/java/org/apache/commons/math4/util/CombinatoricsUtils.java b/src/main/java/org/apache/commons/math4/util/CombinatoricsUtils.java index 0594deef53..08a9829cb8 100644 --- a/src/main/java/org/apache/commons/math4/util/CombinatoricsUtils.java +++ b/src/main/java/org/apache/commons/math4/util/CombinatoricsUtils.java @@ -43,7 +43,7 @@ public final class CombinatoricsUtils { 6402373705728000l, 121645100408832000l, 2432902008176640000l }; /** Stirling numbers of the second kind. */ - static final AtomicReference STIRLING_S2 = new AtomicReference<> (null); + static final AtomicReference STIRLING_S2 = new AtomicReference (null); /** * Default implementation of {@link #factorialLog(int)} method: diff --git a/src/main/java/org/apache/commons/math4/util/IterationManager.java b/src/main/java/org/apache/commons/math4/util/IterationManager.java index 550bd2582e..4437a8f1a0 100644 --- a/src/main/java/org/apache/commons/math4/util/IterationManager.java +++ b/src/main/java/org/apache/commons/math4/util/IterationManager.java @@ -43,7 +43,7 @@ public class IterationManager { */ public IterationManager(final int maxIterations) { this.iterations = new Incrementor(maxIterations); - this.listeners = new CopyOnWriteArrayList<>(); + this.listeners = new CopyOnWriteArrayList(); } /** @@ -58,7 +58,7 @@ public IterationManager(final int maxIterations) { public IterationManager(final int maxIterations, final Incrementor.MaxCountExceededCallback callBack) { this.iterations = new Incrementor(maxIterations, callBack); - this.listeners = new CopyOnWriteArrayList<>(); + this.listeners = new CopyOnWriteArrayList(); } /** diff --git a/src/main/java/org/apache/commons/math4/util/MathArrays.java b/src/main/java/org/apache/commons/math4/util/MathArrays.java index 8c850db11b..c50f44c25c 100644 --- a/src/main/java/org/apache/commons/math4/util/MathArrays.java +++ b/src/main/java/org/apache/commons/math4/util/MathArrays.java @@ -844,7 +844,7 @@ public static void sortInPlace(double[] x, // Associate each abscissa "x[i]" with its index "i". final List list - = new ArrayList<>(len); + = new ArrayList(len); for (int i = 0; i < len; i++) { list.add(new PairDoubleInteger(x[i], i)); } @@ -1921,7 +1921,7 @@ public static double[] concatenate(double[] ...x) { * @since 3.6 */ public static double[] unique(double[] data) { - TreeSet values = new TreeSet<>(); + TreeSet values = new TreeSet(); for (int i = 0; i < data.length; i++) { values.add(data[i]); } diff --git a/src/main/java/org/apache/commons/math4/util/Pair.java b/src/main/java/org/apache/commons/math4/util/Pair.java index f56de9b952..487cdced6f 100644 --- a/src/main/java/org/apache/commons/math4/util/Pair.java +++ b/src/main/java/org/apache/commons/math4/util/Pair.java @@ -151,6 +151,6 @@ public String toString() { * @since 3.3 */ public static Pair create(K k, V v) { - return new Pair<>(k, v); + return new Pair(k, v); } } diff --git a/src/main/java/org/apache/commons/math4/util/TransformerMap.java b/src/main/java/org/apache/commons/math4/util/TransformerMap.java index 78bb86c65c..374b9f6f22 100644 --- a/src/main/java/org/apache/commons/math4/util/TransformerMap.java +++ b/src/main/java/org/apache/commons/math4/util/TransformerMap.java @@ -49,7 +49,7 @@ public class TransformerMap implements NumberTransformer, Serializable { * Build a map containing only the default transformer. */ public TransformerMap() { - map = new HashMap<>(); + map = new HashMap, NumberTransformer>(); defaultTransformer = new DefaultTransformer(); } diff --git a/src/test/java/org/apache/commons/math4/analysis/differentiation/DSCompilerTest.java b/src/test/java/org/apache/commons/math4/analysis/differentiation/DSCompilerTest.java index 4284505414..e54d7a3e07 100644 --- a/src/test/java/org/apache/commons/math4/analysis/differentiation/DSCompilerTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/differentiation/DSCompilerTest.java @@ -155,7 +155,7 @@ public void testSymmetry() { @Test public void testMultiplicationRules() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { - Map referenceRules = new HashMap<>(); + Map referenceRules = new HashMap(); referenceRules.put("(f*g)", "f * g"); referenceRules.put("d(f*g)/dx", "f * dg/dx + df/dx * g"); referenceRules.put("d(f*g)/dy", referenceRules.get("d(f*g)/dx").replaceAll("x", "y")); @@ -246,7 +246,7 @@ public void testSymmetry() { // the following reference rules have all been computed independently from the library, // using only pencil and paper and some search and replace to handle symmetries - Map referenceRules = new HashMap<>(); + Map referenceRules = new HashMap(); referenceRules.put("(f(g))", "(f(g))"); referenceRules.put("d(f(g))/dx", "d(f(g))/dg * dg/dx"); referenceRules.put("d(f(g))/dy", referenceRules.get("d(f(g))/dx").replaceAll("x", "y")); diff --git a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactoryTest.java b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactoryTest.java index 6eda1615c5..89c05de3b1 100644 --- a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactoryTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactoryTest.java @@ -51,7 +51,7 @@ public void testConcurrentCreation() throws InterruptedException, new ArrayBlockingQueue(2)); final List>> results - = new ArrayList<>(); + = new ArrayList>>(); for (int i = 0; i < numTasks; i++) { results.add(exec.submit(new RuleBuilder())); } @@ -103,7 +103,7 @@ protected Pair computeRule(int order) { p[i] = new Double(i); w[i] = new Double(i); } - return new Pair<>(p, w); + return new Pair(p, w); } public int getNumberOfCalls() { diff --git a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorTest.java b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorTest.java index 07e067582b..8270d3b1e9 100644 --- a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorTest.java @@ -34,7 +34,7 @@ public void testGetWeights() { final double[] weights = { 9.8, 7.6, 5.4 }; final GaussIntegrator integrator - = new GaussIntegrator(new Pair<>(points, weights)); + = new GaussIntegrator(new Pair(points, weights)); Assert.assertEquals(weights.length, integrator.getNumberOfPoints()); @@ -49,7 +49,7 @@ public void testGetPoints() { final double[] weights = { 9.8, 7.6, 5.4 }; final GaussIntegrator integrator - = new GaussIntegrator(new Pair<>(points, weights)); + = new GaussIntegrator(new Pair(points, weights)); Assert.assertEquals(points.length, integrator.getNumberOfPoints()); @@ -64,7 +64,7 @@ public void testIntegrate() { final double[] weights = { 1, 1, 1, 1, 1, 1 }; final GaussIntegrator integrator - = new GaussIntegrator(new Pair<>(points, weights)); + = new GaussIntegrator(new Pair(points, weights)); final double val = 123.456; final UnivariateFunction c = new Constant(val); diff --git a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/HermiteParametricTest.java b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/HermiteParametricTest.java index 5bba84e86f..8eb304fdbd 100644 --- a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/HermiteParametricTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/HermiteParametricTest.java @@ -72,7 +72,7 @@ public HermiteParametricTest(int numberOfPoints, @SuppressWarnings("boxing") // OK here @Parameters public static Collection getParameters() { - final ArrayList parameters = new ArrayList<>(); + final ArrayList parameters = new ArrayList(); for (int k = 1; k <= MAX_NUM_POINTS; k++) { parameters.add(new Object[] { k, 2 * k - 1, Math.ulp(1d), 195 }); } diff --git a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionParametricTest.java b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionParametricTest.java index 896f8e09bb..976488fd3f 100644 --- a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionParametricTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionParametricTest.java @@ -70,7 +70,7 @@ public LegendreHighPrecisionParametricTest(int numberOfPoints, @SuppressWarnings("boxing") // OK here @Parameters public static Collection getParameters() { - final ArrayList parameters = new ArrayList<>(); + final ArrayList parameters = new ArrayList(); for (int k = 1; k <= MAX_NUM_POINTS; k++) { parameters.add(new Object[] { k, 2 * k - 1, Math.ulp(1d), 13d }); } diff --git a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreParametricTest.java b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreParametricTest.java index 812611194d..3f0fc63951 100644 --- a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreParametricTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/LegendreParametricTest.java @@ -70,7 +70,7 @@ public LegendreParametricTest(int numberOfPoints, @SuppressWarnings("boxing") // OK here @Parameters public static Collection getParameters() { - final ArrayList parameters = new ArrayList<>(); + final ArrayList parameters = new ArrayList(); for (int k = 1; k <= MAX_NUM_POINTS; k++) { parameters.add(new Object[] { k, 2 * k - 1, Math.ulp(1d), 91d }); } diff --git a/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java b/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java index 33fab5de94..1e5b031f8c 100644 --- a/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java @@ -33,7 +33,7 @@ public class FieldHermiteInterpolatorTest { @Test public void testZero() { - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); interpolator.addSamplePoint(new BigFraction(0), new BigFraction[] { new BigFraction(0) }); for (int x = -10; x < 10; x++) { BigFraction y = interpolator.value(new BigFraction(x))[0]; @@ -46,7 +46,7 @@ public void testZero() { @Test public void testQuadratic() { - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); interpolator.addSamplePoint(new BigFraction(0), new BigFraction[] { new BigFraction(2) }); interpolator.addSamplePoint(new BigFraction(1), new BigFraction[] { new BigFraction(0) }); interpolator.addSamplePoint(new BigFraction(2), new BigFraction[] { new BigFraction(0) }); @@ -63,7 +63,7 @@ public void testQuadratic() { @Test public void testMixedDerivatives() { - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); interpolator.addSamplePoint(new BigFraction(0), new BigFraction[] { new BigFraction(1) }, new BigFraction[] { new BigFraction(2) }); interpolator.addSamplePoint(new BigFraction(1), new BigFraction[] { new BigFraction(4) }); interpolator.addSamplePoint(new BigFraction(2), new BigFraction[] { new BigFraction(5) }, new BigFraction[] { new BigFraction(2) }); @@ -107,7 +107,7 @@ public void testRandomPolynomialsValuesOnly() { DfpField field = new DfpField(30); Dfp step = field.getOne().divide(field.newDfp(10)); - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); for (int j = 0; j < 1 + maxDegree; ++j) { Dfp x = field.newDfp(j).multiply(step); Dfp[] values = new Dfp[p.length]; @@ -151,7 +151,7 @@ public void testRandomPolynomialsFirstDerivative() { DfpField field = new DfpField(30); Dfp step = field.getOne().divide(field.newDfp(10)); - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); for (int j = 0; j < 1 + maxDegree / 2; ++j) { Dfp x = field.newDfp(j).multiply(step); Dfp[] values = new Dfp[p.length]; @@ -186,7 +186,7 @@ public void testRandomPolynomialsFirstDerivative() { @Test public void testSine() { DfpField field = new DfpField(30); - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); for (Dfp x = field.getZero(); x.getReal() < FastMath.PI; x = x.add(0.5)) { interpolator.addSamplePoint(x, new Dfp[] { x.sin() }); } @@ -199,7 +199,7 @@ public void testSine() { @Test public void testSquareRoot() { DfpField field = new DfpField(30); - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); for (Dfp x = field.getOne(); x.getReal() < 3.6; x = x.add(0.5)) { interpolator.addSamplePoint(x, new Dfp[] { x.sqrt() }); } @@ -213,7 +213,7 @@ public void testSquareRoot() { public void testWikipedia() { // this test corresponds to the example from Wikipedia page: // http://en.wikipedia.org/wiki/Hermite_interpolation - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); interpolator.addSamplePoint(new BigFraction(-1), new BigFraction[] { new BigFraction( 2) }, new BigFraction[] { new BigFraction(-8) }, @@ -237,7 +237,7 @@ public void testWikipedia() { @Test public void testOnePointParabola() { - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); interpolator.addSamplePoint(new BigFraction(0), new BigFraction[] { new BigFraction(1) }, new BigFraction[] { new BigFraction(1) }, @@ -268,7 +268,7 @@ public void testEmptySampleDerivative() { @Test(expected=MathIllegalArgumentException.class) public void testDuplicatedAbscissa() { - FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>(); + FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator(); interpolator.addSamplePoint(new BigFraction(1), new BigFraction[] { new BigFraction(0) }); interpolator.addSamplePoint(new BigFraction(1), new BigFraction[] { new BigFraction(1) }); } diff --git a/src/test/java/org/apache/commons/math4/analysis/solvers/FieldBracketingNthOrderBrentSolverTest.java b/src/test/java/org/apache/commons/math4/analysis/solvers/FieldBracketingNthOrderBrentSolverTest.java index d50e06c07f..a1d5587f79 100644 --- a/src/test/java/org/apache/commons/math4/analysis/solvers/FieldBracketingNthOrderBrentSolverTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/solvers/FieldBracketingNthOrderBrentSolverTest.java @@ -36,14 +36,14 @@ public final class FieldBracketingNthOrderBrentSolverTest { @Test(expected=NumberIsTooSmallException.class) public void testInsufficientOrder3() { - new FieldBracketingNthOrderBrentSolver<>(relativeAccuracy, absoluteAccuracy, + new FieldBracketingNthOrderBrentSolver(relativeAccuracy, absoluteAccuracy, functionValueAccuracy, 1); } @Test public void testConstructorOK() { FieldBracketingNthOrderBrentSolver solver = - new FieldBracketingNthOrderBrentSolver<>(relativeAccuracy, absoluteAccuracy, + new FieldBracketingNthOrderBrentSolver(relativeAccuracy, absoluteAccuracy, functionValueAccuracy, 2); Assert.assertEquals(2, solver.getMaximalOrder()); } @@ -51,7 +51,7 @@ public void testConstructorOK() { @Test public void testConvergenceOnFunctionAccuracy() { FieldBracketingNthOrderBrentSolver solver = - new FieldBracketingNthOrderBrentSolver<>(relativeAccuracy, absoluteAccuracy, + new FieldBracketingNthOrderBrentSolver(relativeAccuracy, absoluteAccuracy, field.newDfp(1.0e-20), 20); RealFieldUnivariateFunction f = new RealFieldUnivariateFunction() { public Dfp value(Dfp x) { @@ -127,7 +127,7 @@ public Dfp value(Dfp x) { private void check(RealFieldUnivariateFunction f, int maxEval, double min, double max, AllowedSolution allowedSolution) { FieldBracketingNthOrderBrentSolver solver = - new FieldBracketingNthOrderBrentSolver<>(relativeAccuracy, absoluteAccuracy, + new FieldBracketingNthOrderBrentSolver(relativeAccuracy, absoluteAccuracy, functionValueAccuracy, 20); Dfp xResult = solver.solve(maxEval, f, field.newDfp(min), field.newDfp(max), allowedSolution); diff --git a/src/test/java/org/apache/commons/math4/distribution/EnumeratedRealDistributionTest.java b/src/test/java/org/apache/commons/math4/distribution/EnumeratedRealDistributionTest.java index f903cbc3f7..f1cf6521d3 100644 --- a/src/test/java/org/apache/commons/math4/distribution/EnumeratedRealDistributionTest.java +++ b/src/test/java/org/apache/commons/math4/distribution/EnumeratedRealDistributionTest.java @@ -192,10 +192,10 @@ public void testSample() { @Test public void testIssue942() { - List> list = new ArrayList<>(); + List> list = new ArrayList>(); list.add(new Pair(new Object() {}, new Double(0))); list.add(new Pair(new Object() {}, new Double(1))); - Assert.assertEquals(1, new EnumeratedDistribution<>(list).sample(1).length); + Assert.assertEquals(1, new EnumeratedDistribution(list).sample(1).length); } @Test diff --git a/src/test/java/org/apache/commons/math4/distribution/MultivariateNormalMixtureModelDistributionTest.java b/src/test/java/org/apache/commons/math4/distribution/MultivariateNormalMixtureModelDistributionTest.java index aedaba0e76..8bed770001 100644 --- a/src/test/java/org/apache/commons/math4/distribution/MultivariateNormalMixtureModelDistributionTest.java +++ b/src/test/java/org/apache/commons/math4/distribution/MultivariateNormalMixtureModelDistributionTest.java @@ -151,12 +151,12 @@ private MultivariateNormalMixtureModelDistribution create(double[] weights, double[][] means, double[][][] covariances) { final List> mvns - = new ArrayList<>(); + = new ArrayList>(); for (int i = 0; i < weights.length; i++) { final MultivariateNormalDistribution dist = new MultivariateNormalDistribution(means[i], covariances[i]); - mvns.add(new Pair<>(weights[i], dist)); + mvns.add(new Pair(weights[i], dist)); } return new MultivariateNormalMixtureModelDistribution(mvns); diff --git a/src/test/java/org/apache/commons/math4/distribution/RealDistributionAbstractTest.java b/src/test/java/org/apache/commons/math4/distribution/RealDistributionAbstractTest.java index 1a5e2109f0..9fffeaf6a1 100644 --- a/src/test/java/org/apache/commons/math4/distribution/RealDistributionAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/distribution/RealDistributionAbstractTest.java @@ -357,7 +357,7 @@ public double value(double x) { return distribution.density(x); } }; - final ArrayList integrationTestPoints = new ArrayList<>(); + final ArrayList integrationTestPoints = new ArrayList(); for (int i = 0; i < cumulativeTestPoints.length; i++) { if (Double.isNaN(cumulativeTestValues[i]) || cumulativeTestValues[i] < 1.0e-5 || diff --git a/src/test/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximizationTest.java b/src/test/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximizationTest.java index f31f4c80dc..cb6860357d 100644 --- a/src/test/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximizationTest.java +++ b/src/test/java/org/apache/commons/math4/distribution/fitting/MultivariateNormalMixtureExpectationMaximizationTest.java @@ -129,10 +129,10 @@ public void testIncompatibleIntialMixture() { // Create components and mixture List> components = - new ArrayList<>(); - components.add(new Pair<>( + new ArrayList>(); + components.add(new Pair( weights[0], mvns[0])); - components.add(new Pair<>( + components.add(new Pair( weights[1], mvns[1])); MixtureMultivariateNormalDistribution badInitialMix diff --git a/src/test/java/org/apache/commons/math4/exception/util/ArgUtilsTest.java b/src/test/java/org/apache/commons/math4/exception/util/ArgUtilsTest.java index e7fddf6921..46ed1893ce 100644 --- a/src/test/java/org/apache/commons/math4/exception/util/ArgUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/exception/util/ArgUtilsTest.java @@ -30,7 +30,7 @@ public class ArgUtilsTest { @Test public void testFlatten() { - final List orig = new ArrayList<>(); + final List orig = new ArrayList(); final Object[] struct = new Object[] { new Object[] { diff --git a/src/test/java/org/apache/commons/math4/fitting/HarmonicCurveFitterTest.java b/src/test/java/org/apache/commons/math4/fitting/HarmonicCurveFitterTest.java index e3b1959477..17097f56d3 100644 --- a/src/test/java/org/apache/commons/math4/fitting/HarmonicCurveFitterTest.java +++ b/src/test/java/org/apache/commons/math4/fitting/HarmonicCurveFitterTest.java @@ -170,7 +170,7 @@ public void testMath844() { 0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 3, 2, 1, 0 }; - final List points = new ArrayList<>(); + final List points = new ArrayList(); for (int i = 0; i < y.length; i++) { points.add(new WeightedObservedPoint(1, i, y[i])); } diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleProblem.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleProblem.java index 016bf8bc01..377726d7e7 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleProblem.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleProblem.java @@ -57,7 +57,7 @@ class CircleProblem { public CircleProblem(double xError, double yError, int searchResolution) { - points = new ArrayList<>(); + points = new ArrayList(); xSigma = xError; ySigma = yError; resolution = searchResolution; diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java index 87a2b6f849..3c88431fda 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java @@ -29,7 +29,7 @@ class CircleVectorial { private ArrayList points; public CircleVectorial() { - points = new ArrayList<>(); + points = new ArrayList(); } public void addPoint(double px, double py) { diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTest.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTest.java index bffb95b8ee..b34dcafe2a 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTest.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTest.java @@ -262,7 +262,7 @@ public void testLazyEvaluationPrecondition() { // "MultivariateJacobianFunction". final MultivariateJacobianFunction m1 = new MultivariateJacobianFunction() { public Pair value(RealVector notUsed) { - return new Pair<>(null, null); + return new Pair(null, null); } }; @@ -276,7 +276,7 @@ public Pair value(RealVector notUsed) { final MultivariateJacobianFunction m2 = new ValueAndJacobianFunction() { public Pair value(RealVector notUsed) { - return new Pair<>(null, null); + return new Pair(null, null); } public RealVector computeValue(final double[] params) { return null; diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTestValidation.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTestValidation.java index 3c637aeb34..6642854271 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTestValidation.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTestValidation.java @@ -232,7 +232,7 @@ public void testParametersErrorMonteCarloParameters() { // Index 0 = slope // Index 1 = offset // Index 2 = normalized chi2 - final List paramsAndChi2 = new ArrayList<>(gridSize * gridSize); + final List paramsAndChi2 = new ArrayList(gridSize * gridSize); final double slopeRange = 10 * sigma.getEntry(0); final double offsetRange = 10 * sigma.getEntry(1); diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java index 9b9c55d26f..6198eb71cb 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java @@ -360,8 +360,8 @@ private static class BevingtonProblem { private List count; public BevingtonProblem() { - time = new ArrayList<>(); - count = new ArrayList<>(); + time = new ArrayList(); + count = new ArrayList(); } public void addPoint(double t, double c) { diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/StatisticalReferenceDataset.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/StatisticalReferenceDataset.java index 08c60f7082..f78b318d28 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/StatisticalReferenceDataset.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/StatisticalReferenceDataset.java @@ -68,7 +68,7 @@ public abstract class StatisticalReferenceDataset { public StatisticalReferenceDataset(final BufferedReader in) throws IOException { - final ArrayList lines = new ArrayList<>(); + final ArrayList lines = new ArrayList(); for (String line = in.readLine(); line != null; line = in.readLine()) { lines.add(line); } diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/StraightLineProblem.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/StraightLineProblem.java index 7ce8323c65..b59e703be2 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/StraightLineProblem.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/StraightLineProblem.java @@ -46,7 +46,7 @@ class StraightLineProblem { * @param error Assumed error for the y-coordinate. */ public StraightLineProblem(double error) { - points = new ArrayList<>(); + points = new ArrayList(); sigma = error; } diff --git a/src/test/java/org/apache/commons/math4/genetics/ChromosomeTest.java b/src/test/java/org/apache/commons/math4/genetics/ChromosomeTest.java index 3c1a6edb23..126d5c3987 100644 --- a/src/test/java/org/apache/commons/math4/genetics/ChromosomeTest.java +++ b/src/test/java/org/apache/commons/math4/genetics/ChromosomeTest.java @@ -92,7 +92,7 @@ public double fitness() { } }; - List popChr = new ArrayList<>(); + List popChr = new ArrayList(); popChr.add(c1); popChr.add(c2); popChr.add(c3); diff --git a/src/test/java/org/apache/commons/math4/genetics/FitnessCachingTest.java b/src/test/java/org/apache/commons/math4/genetics/FitnessCachingTest.java index 0903c49798..71ae818bda 100644 --- a/src/test/java/org/apache/commons/math4/genetics/FitnessCachingTest.java +++ b/src/test/java/org/apache/commons/math4/genetics/FitnessCachingTest.java @@ -81,7 +81,7 @@ public void testFitnessCaching() { * Initializes a random population. */ private static ElitisticListPopulation randomPopulation() { - List popList = new LinkedList<>(); + List popList = new LinkedList(); for (int i=0; i popList = new LinkedList<>(); + List popList = new LinkedList(); for (int i=0; i sequence = new ArrayList<>(); + private static final List sequence = new ArrayList(); static { for (int i=0; i popList = new ArrayList<>(); + List popList = new ArrayList(); for (int i=0; i chromosomes = new ArrayList<> (); + ArrayList chromosomes = new ArrayList (); chromosomes.add(c1); chromosomes.add(c2); chromosomes.add(c3); @@ -67,7 +67,7 @@ public Population nextGeneration() { @Test public void testChromosomes() { - final ArrayList chromosomes = new ArrayList<> (); + final ArrayList chromosomes = new ArrayList (); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); @@ -112,7 +112,7 @@ public Population nextGeneration() { @Test(expected = NotPositiveException.class) public void testChromosomeListConstructorPopulationLimitNotPositive() { - final ArrayList chromosomes = new ArrayList<> (); + final ArrayList chromosomes = new ArrayList (); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); new ListPopulation(chromosomes, -10) { public Population nextGeneration() { @@ -124,7 +124,7 @@ public Population nextGeneration() { @Test(expected = NumberIsTooLargeException.class) public void testConstructorListOfChromosomesBiggerThanPopulationSize() { - final ArrayList chromosomes = new ArrayList<> (); + final ArrayList chromosomes = new ArrayList (); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); @@ -138,7 +138,7 @@ public Population nextGeneration() { @Test(expected=NumberIsTooLargeException.class) public void testAddTooManyChromosomes() { - final ArrayList chromosomes = new ArrayList<> (); + final ArrayList chromosomes = new ArrayList (); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); @@ -170,7 +170,7 @@ public Population nextGeneration() { @Test(expected = UnsupportedOperationException.class) public void testIterator() { - final ArrayList chromosomes = new ArrayList<>(); + final ArrayList chromosomes = new ArrayList(); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); @@ -193,7 +193,7 @@ public Population nextGeneration() { @Test(expected=NumberIsTooSmallException.class) public void testSetPopulationLimitTooSmall() { - final ArrayList chromosomes = new ArrayList<> (); + final ArrayList chromosomes = new ArrayList (); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); diff --git a/src/test/java/org/apache/commons/math4/genetics/NPointCrossoverTest.java b/src/test/java/org/apache/commons/math4/genetics/NPointCrossoverTest.java index 2a1231f2e5..4f05d81b3f 100644 --- a/src/test/java/org/apache/commons/math4/genetics/NPointCrossoverTest.java +++ b/src/test/java/org/apache/commons/math4/genetics/NPointCrossoverTest.java @@ -94,7 +94,7 @@ public void testCrossover() { BinaryChromosome p2c = new DummyBinaryChromosome(p2); final int order = 3; - NPointCrossover npc = new NPointCrossover<>(order); + NPointCrossover npc = new NPointCrossover(order); // the two parent chromosomes are different at each position, so it is easy to detect // the number of crossovers that happened for each child diff --git a/src/test/java/org/apache/commons/math4/genetics/OnePointCrossoverTest.java b/src/test/java/org/apache/commons/math4/genetics/OnePointCrossoverTest.java index 482aad007f..6f431e2cf3 100644 --- a/src/test/java/org/apache/commons/math4/genetics/OnePointCrossoverTest.java +++ b/src/test/java/org/apache/commons/math4/genetics/OnePointCrossoverTest.java @@ -34,7 +34,7 @@ public void testCrossover() { BinaryChromosome p1c = new DummyBinaryChromosome(p1); BinaryChromosome p2c = new DummyBinaryChromosome(p2); - OnePointCrossover opc = new OnePointCrossover<>(); + OnePointCrossover opc = new OnePointCrossover(); // how to test a stochastic method? for (int i=0; i<20; i++) { diff --git a/src/test/java/org/apache/commons/math4/genetics/OrderedCrossoverTest.java b/src/test/java/org/apache/commons/math4/genetics/OrderedCrossoverTest.java index 2290fabdb9..9379da1ce2 100644 --- a/src/test/java/org/apache/commons/math4/genetics/OrderedCrossoverTest.java +++ b/src/test/java/org/apache/commons/math4/genetics/OrderedCrossoverTest.java @@ -42,8 +42,8 @@ public void testCrossover() { final CrossoverPolicy cp = new OrderedCrossover(); for (int i = 0; i < 20; i++) { - final Set parentSet1 = new HashSet<>(Arrays.asList(p1)); - final Set parentSet2 = new HashSet<>(Arrays.asList(p2)); + final Set parentSet1 = new HashSet(Arrays.asList(p1)); + final Set parentSet2 = new HashSet(Arrays.asList(p2)); final ChromosomePair pair = cp.crossover(p1c, p2c); diff --git a/src/test/java/org/apache/commons/math4/genetics/UniformCrossoverTest.java b/src/test/java/org/apache/commons/math4/genetics/UniformCrossoverTest.java index 73c6052dc7..45e2a2b295 100644 --- a/src/test/java/org/apache/commons/math4/genetics/UniformCrossoverTest.java +++ b/src/test/java/org/apache/commons/math4/genetics/UniformCrossoverTest.java @@ -33,8 +33,8 @@ public class UniformCrossoverTest { private static final int LEN = 10000; - private static final List p1 = new ArrayList<>(LEN); - private static final List p2 = new ArrayList<>(LEN); + private static final List p1 = new ArrayList(LEN); + private static final List p2 = new ArrayList(LEN); @SuppressWarnings("boxing") @BeforeClass diff --git a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java index f0daa4cfe1..3729574e60 100644 --- a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java @@ -37,7 +37,7 @@ public class WelzlEncloser2DTest { public void testNullList() { DiskGenerator generator = new DiskGenerator(); WelzlEncloser encloser = - new WelzlEncloser<>(1.0e-10, generator); + new WelzlEncloser(1.0e-10, generator); EnclosingBall ball = encloser.enclose(null); Assert.assertTrue(ball.getRadius() < 0); } @@ -46,7 +46,7 @@ public void testNullList() { public void testNoPoints() { DiskGenerator generator = new DiskGenerator(); WelzlEncloser encloser = - new WelzlEncloser<>(1.0e-10, generator); + new WelzlEncloser(1.0e-10, generator); EnclosingBall ball = encloser.enclose(new ArrayList()); Assert.assertTrue(ball.getRadius() < 0); } @@ -87,7 +87,7 @@ public void testLargeSamples() { RandomGenerator random = new Well1024a(0xa2a63cad12c01fb2l); for (int k = 0; k < 100; ++k) { int nbPoints = random.nextInt(10000); - List points = new ArrayList<>(); + List points = new ArrayList(); for (int i = 0; i < nbPoints; ++i) { double x = random.nextDouble(); double y = random.nextDouble(); @@ -98,7 +98,7 @@ public void testLargeSamples() { } private List buildList(final double ... coordinates) { - List list = new ArrayList<>(coordinates.length / 2); + List list = new ArrayList(coordinates.length / 2); for (int i = 0; i < coordinates.length; i += 2) { list.add(new Vector2D(coordinates[i], coordinates[i + 1])); } @@ -129,7 +129,7 @@ private void checkDisk(List points, List refSupport) { // check removing any point of the support disk fails to enclose the point for (int i = 0; i < disk.getSupportSize(); ++i) { - List reducedSupport = new ArrayList<>(); + List reducedSupport = new ArrayList(); int count = 0; for (Vector2D s : disk.getSupport()) { if (count++ != i) { @@ -151,7 +151,7 @@ private void checkDisk(List points, List refSupport) { private EnclosingBall checkDisk(List points) { WelzlEncloser encloser = - new WelzlEncloser<>(1.0e-10, new DiskGenerator()); + new WelzlEncloser(1.0e-10, new DiskGenerator()); EnclosingBall disk = encloser.enclose(points); // all points are enclosed diff --git a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java index f8ef012f18..aaa4c43466 100644 --- a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java @@ -39,7 +39,7 @@ public class WelzlEncloser3DTest { public void testNullList() { SphereGenerator generator = new SphereGenerator(); WelzlEncloser encloser = - new WelzlEncloser<>(1.0e-10, generator); + new WelzlEncloser(1.0e-10, generator); EnclosingBall ball = encloser.enclose(null); Assert.assertTrue(ball.getRadius() < 0); } @@ -48,7 +48,7 @@ public void testNullList() { public void testNoPoints() { SphereGenerator generator = new SphereGenerator(); WelzlEncloser encloser = - new WelzlEncloser<>(1.0e-10, generator); + new WelzlEncloser(1.0e-10, generator); EnclosingBall ball = encloser.enclose(new ArrayList()); Assert.assertTrue(ball.getRadius() < 0); } @@ -68,7 +68,7 @@ public void testReducingBall() { new Vector3D(-7.140322188726825, -16.574152894557717, 11.710305611121410), new Vector3D(-7.141116131477088, -16.574061164624560, 11.712938509321699)); WelzlEncloser encloser = - new WelzlEncloser<>(1.0e-10, new SphereGenerator()); + new WelzlEncloser(1.0e-10, new SphereGenerator()); EnclosingBall ball = encloser.enclose(list); Assert.assertTrue(ball.getRadius() > 0); } @@ -97,7 +97,7 @@ public void testInfiniteLoop() { new Vector3D( -0.98034899533935820, -3.34004481162763960, 13.03245014017556800)); WelzlEncloser encloser = - new WelzlEncloser<>(1.0e-10, new SphereGenerator()); + new WelzlEncloser(1.0e-10, new SphereGenerator()); EnclosingBall ball = encloser.enclose(list); Assert.assertTrue(ball.getRadius() > 0); } @@ -114,7 +114,7 @@ public void testLargeSamples() throws IOException { Vector3D refCenter = new Vector3D(d, new Vector3D(sr.nextVector())); // set up a large sample inside the reference sphere int nbPoints = random.nextInt(1000); - List points = new ArrayList<>(); + List points = new ArrayList(); for (int i = 0; i < nbPoints; ++i) { double r = refRadius * random.nextDouble(); points.add(new Vector3D(1.0, refCenter, r, new Vector3D(sr.nextVector()))); @@ -135,7 +135,7 @@ private void checkSphere(List points, double refRadius) { // check removing any point of the support Sphere fails to enclose the point for (int i = 0; i < sphere.getSupportSize(); ++i) { - List reducedSupport = new ArrayList<>(); + List reducedSupport = new ArrayList(); int count = 0; for (Vector3D s : sphere.getSupport()) { if (count++ != i) { @@ -158,7 +158,7 @@ private void checkSphere(List points, double refRadius) { private EnclosingBall checkSphere(List points) { WelzlEncloser encloser = - new WelzlEncloser<>(1.0e-10, new SphereGenerator()); + new WelzlEncloser(1.0e-10, new SphereGenerator()); EnclosingBall Sphere = encloser.enclose(points); // all points are enclosed diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java index b7c839913b..a8b00dcafd 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java @@ -66,7 +66,7 @@ public void testInfinite() { @Test public void testMultiple() { - RegionFactory factory = new RegionFactory<>(); + RegionFactory factory = new RegionFactory(); IntervalsSet set = (IntervalsSet) factory.intersection(factory.union(factory.difference(new IntervalsSet(1.0, 6.0, 1.0e-10), new IntervalsSet(3.0, 5.0, 1.0e-10)), diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java index d9308fdf2c..5b352eb178 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java @@ -66,7 +66,7 @@ public void testIdentity() { @Deprecated public void testAxisAngleDeprecated() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation<>(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3)); + FieldRotation r = new FieldRotation(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3)); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 1, 0)); checkVector(r.applyTo(createVector(0, 1, 0)), createVector(0, 0, 1)); checkVector(r.applyTo(createVector(0, 0, 1)), createVector(1, 0, 0)); @@ -75,16 +75,16 @@ public void testAxisAngleDeprecated() throws MathIllegalArgumentException { checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new FieldRotation<>(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3)); + new FieldRotation(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3)); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new FieldRotation<>(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI)); + r = new FieldRotation(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI)); checkVector(r.getAxis(), createVector(0, 0, -1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new FieldRotation<>(createAxis(0, 1, 0), createAngle(FastMath.PI)); + r = new FieldRotation(createAxis(0, 1, 0), createAngle(FastMath.PI)); checkVector(r.getAxis(), createVector(0, 1, 0)); checkAngle(r.getAngle(), FastMath.PI); @@ -95,7 +95,7 @@ public void testAxisAngleDeprecated() throws MathIllegalArgumentException { @Test public void testAxisAngleVectorOperator() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation<>(createAxis(10, 10, 10), + FieldRotation r = new FieldRotation(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3) , RotationConvention.VECTOR_OPERATOR); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 1, 0)); @@ -107,21 +107,21 @@ public void testAxisAngleVectorOperator() throws MathIllegalArgumentException { checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new FieldRotation<>(createAxis(0, 0, 0), + new FieldRotation(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3), RotationConvention.VECTOR_OPERATOR); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new FieldRotation<>(createAxis(0, 0, 1), + r = new FieldRotation(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI), RotationConvention.VECTOR_OPERATOR); checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, 0, -1)); checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, 0, +1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new FieldRotation<>(createAxis(0, 1, 0), + r = new FieldRotation(createAxis(0, 1, 0), createAngle(FastMath.PI), RotationConvention.VECTOR_OPERATOR); checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, +1, 0)); @@ -136,7 +136,7 @@ public void testAxisAngleVectorOperator() throws MathIllegalArgumentException { @Test public void testAxisAngleFrameTransform() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation<>(createAxis(10, 10, 10), + FieldRotation r = new FieldRotation(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3) , RotationConvention.FRAME_TRANSFORM); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 0, 1)); @@ -148,21 +148,21 @@ public void testAxisAngleFrameTransform() throws MathIllegalArgumentException { checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new FieldRotation<>(createAxis(0, 0, 0), + new FieldRotation(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3), RotationConvention.FRAME_TRANSFORM); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new FieldRotation<>(createAxis(0, 0, 1), + r = new FieldRotation(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI), RotationConvention.FRAME_TRANSFORM); checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, 0, -1)); checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, 0, +1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new FieldRotation<>(createAxis(0, 1, 0), + r = new FieldRotation(createAxis(0, 1, 0), createAngle(FastMath.PI), RotationConvention.FRAME_TRANSFORM); checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, +1, 0)); @@ -395,13 +395,13 @@ public void testVectorOnePair() throws MathArithmeticException { FieldVector3D u = createVector(3, 2, 1); FieldVector3D v = createVector(-4, 2, 2); - FieldRotation r = new FieldRotation<>(u, v); + FieldRotation r = new FieldRotation(u, v); checkVector(r.applyTo(u.scalarMultiply(v.getNorm())), v.scalarMultiply(u.getNorm())); - checkAngle(new FieldRotation<>(u, u.negate()).getAngle(), FastMath.PI); + checkAngle(new FieldRotation(u, u.negate()).getAngle(), FastMath.PI); try { - new FieldRotation<>(u, createVector(0, 0, 0)); + new FieldRotation(u, createVector(0, 0, 0)); Assert.fail("an exception should have been thrown"); } catch (MathArithmeticException e) { // expected behavior @@ -416,11 +416,11 @@ public void testVectorTwoPairs() throws MathArithmeticException { FieldVector3D u2 = createVector(0, 5, 0); FieldVector3D v1 = createVector(0, 0, 2); FieldVector3D v2 = createVector(-2, 0, 2); - FieldRotation r = new FieldRotation<>(u1, u2, v1, v2); + FieldRotation r = new FieldRotation(u1, u2, v1, v2); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 0, 1)); checkVector(r.applyTo(createVector(0, 1, 0)), createVector(-1, 0, 0)); - r = new FieldRotation<>(u1, u2, u1.negate(), u2.negate()); + r = new FieldRotation(u1, u2, u1.negate(), u2.negate()); FieldVector3D axis = r.getAxis(RotationConvention.VECTOR_OPERATOR); if (FieldVector3D.dotProduct(axis, createVector(0, 0, 1)).getReal() > 0) { checkVector(axis, createVector(0, 0, 1)); @@ -430,18 +430,18 @@ public void testVectorTwoPairs() throws MathArithmeticException { checkAngle(r.getAngle(), FastMath.PI); double sqrt = FastMath.sqrt(2) / 2; - r = new FieldRotation<>(createVector(1, 0, 0), createVector(0, 1, 0), + r = new FieldRotation(createVector(1, 0, 0), createVector(0, 1, 0), createVector(0.5, 0.5, sqrt), createVector(0.5, 0.5, -sqrt)); checkRotationDS(r, sqrt, 0.5, 0.5, 0); - r = new FieldRotation<>(u1, u2, u1, FieldVector3D.crossProduct(u1, u2)); + r = new FieldRotation(u1, u2, u1, FieldVector3D.crossProduct(u1, u2)); checkRotationDS(r, sqrt, -sqrt, 0, 0); - checkRotationDS(new FieldRotation<>(u1, u2, u1, u2), 1, 0, 0, 0); + checkRotationDS(new FieldRotation(u1, u2, u1, u2), 1, 0, 0, 0); try { - new FieldRotation<>(u1, u2, createVector(0, 0, 0), v2); + new FieldRotation(u1, u2, createVector(0, 0, 0), v2); Assert.fail("an exception should have been thrown"); } catch (MathArithmeticException e) { // expected behavior @@ -571,11 +571,11 @@ public void testMatrix() } checkVector(r.applyTo(createVector(1, 0, 0)), - new FieldVector3D<>(m3[0][0], m3[1][0], m3[2][0])); + new FieldVector3D(m3[0][0], m3[1][0], m3[2][0])); checkVector(r.applyTo(createVector(0, 1, 0)), - new FieldVector3D<>(m3[0][1], m3[1][1], m3[2][1])); + new FieldVector3D(m3[0][1], m3[1][1], m3[2][1])); checkVector(r.applyTo(createVector(0, 0, 1)), - new FieldVector3D<>(m3[0][2], m3[1][2], m3[2][2])); + new FieldVector3D(m3[0][2], m3[1][2], m3[2][2])); double[][] m4 = { { 1.0, 0.0, 0.0 }, { 0.0, -1.0, 0.0 }, @@ -609,7 +609,7 @@ public void testAnglesDeprecated() for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 0.3) { for (double alpha2 = -1.55; alpha2 < 1.55; alpha2 += 0.3) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 0.3) { - FieldRotation r = new FieldRotation<>(CardanOrders[i], + FieldRotation r = new FieldRotation(CardanOrders[i], new DerivativeStructure(3, 1, 0, alpha1), new DerivativeStructure(3, 1, 1, alpha2), new DerivativeStructure(3, 1, 2, alpha3)); @@ -631,7 +631,7 @@ public void testAnglesDeprecated() for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 0.3) { for (double alpha2 = 0.05; alpha2 < 3.1; alpha2 += 0.3) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 0.3) { - FieldRotation r = new FieldRotation<>(EulerOrders[i], + FieldRotation r = new FieldRotation(EulerOrders[i], new DerivativeStructure(3, 1, 0, alpha1), new DerivativeStructure(3, 1, 1, alpha2), new DerivativeStructure(3, 1, 2, alpha3)); @@ -661,7 +661,7 @@ public void testAngles() for (double alpha2 = -1.55; alpha2 < 1.55; alpha2 += 0.3) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 0.3) { FieldRotation r = - new FieldRotation<>(CardanOrders[i], + new FieldRotation(CardanOrders[i], convention, new DerivativeStructure(3, 1, 0, alpha1), new DerivativeStructure(3, 1, 1, alpha2), @@ -685,7 +685,7 @@ public void testAngles() for (double alpha2 = 0.05; alpha2 < 3.1; alpha2 += 0.3) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 0.3) { FieldRotation r = - new FieldRotation<>(EulerOrders[i], + new FieldRotation(EulerOrders[i], convention, new DerivativeStructure(3, 1, 0, alpha1), new DerivativeStructure(3, 1, 1, alpha2), @@ -715,7 +715,7 @@ public void testSingularities() { for (int i = 0; i < CardanOrders.length; ++i) { for (int j = 0; j < singularCardanAngle.length; ++j) { FieldRotation r = - new FieldRotation<>(CardanOrders[i], + new FieldRotation(CardanOrders[i], convention, new DerivativeStructure(3, 1, 0, 0.1), new DerivativeStructure(3, 1, 1, singularCardanAngle[j]), @@ -738,7 +738,7 @@ public void testSingularities() { for (int i = 0; i < EulerOrders.length; ++i) { for (int j = 0; j < singularEulerAngle.length; ++j) { FieldRotation r = - new FieldRotation<>(EulerOrders[i], + new FieldRotation(EulerOrders[i], convention, new DerivativeStructure(3, 1, 0, 0.1), new DerivativeStructure(3, 1, 1, singularEulerAngle[j]), @@ -758,11 +758,11 @@ public void testSingularities() { @Test public void testQuaternion() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); double n = 23.5; - FieldRotation r2 = new FieldRotation<>(r1.getQ0().multiply(n), r1.getQ1().multiply(n), + FieldRotation r2 = new FieldRotation(r1.getQ0().multiply(n), r1.getQ1().multiply(n), r1.getQ2().multiply(n), r1.getQ3().multiply(n), true); for (double x = -0.9; x < 0.9; x += 0.2) { @@ -788,10 +788,10 @@ public void testQuaternion() throws MathIllegalArgumentException { @Test public void testApplyToRotation() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.applyTo(r1); @@ -816,10 +816,10 @@ public void testApplyToRotation() throws MathIllegalArgumentException { @Test public void testComposeVectorOperator() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.compose(r1, RotationConvention.VECTOR_OPERATOR); @@ -845,10 +845,10 @@ public void testComposeVectorOperator() throws MathIllegalArgumentException { @Test public void testComposeFrameTransform() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.FRAME_TRANSFORM); - FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.FRAME_TRANSFORM); FieldRotation r3 = r2.compose(r1, RotationConvention.FRAME_TRANSFORM); @@ -874,10 +874,10 @@ public void testComposeFrameTransform() throws MathIllegalArgumentException { @Test public void testApplyInverseToRotation() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.applyInverseTo(r1); @@ -902,10 +902,10 @@ public void testApplyInverseToRotation() throws MathIllegalArgumentException { @Test public void testComposeInverseVectorOperator() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.composeInverse(r1, RotationConvention.VECTOR_OPERATOR); @@ -931,10 +931,10 @@ public void testComposeInverseVectorOperator() throws MathIllegalArgumentExcepti @Test public void testComposeInverseframeTransform() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.FRAME_TRANSFORM); - FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.FRAME_TRANSFORM); FieldRotation r3 = r2.composeInverse(r1, RotationConvention.FRAME_TRANSFORM); @@ -964,7 +964,7 @@ public void testDoubleVectors() throws MathIllegalArgumentException { UnitSphereRandomVectorGenerator g = new UnitSphereRandomVectorGenerator(3, random); for (int i = 0; i < 10; ++i) { double[] unit = g.nextVector(); - FieldRotation r = new FieldRotation<>(createVector(unit[0], unit[1], unit[2]), + FieldRotation r = new FieldRotation(createVector(unit[0], unit[1], unit[2]), createAngle(random.nextDouble()), RotationConvention.VECTOR_OPERATOR); @@ -982,9 +982,9 @@ public void testDoubleVectors() throws MathIllegalArgumentException { DerivativeStructure[] rIuArray = new DerivativeStructure[3]; r.applyInverseTo(new double[] { x, y, z}, rIuArray); checkVector(ruds, ru); - checkVector(ruds, new FieldVector3D<>(ruArray)); + checkVector(ruds, new FieldVector3D(ruArray)); checkVector(rIuds, rIu); - checkVector(rIuds, new FieldVector3D<>(rIuArray)); + checkVector(rIuds, new FieldVector3D(rIuArray)); } } } @@ -1001,13 +1001,13 @@ public void testDoubleRotations() throws MathIllegalArgumentException { double[] unit1 = g.nextVector(); Rotation r1 = new Rotation(new Vector3D(unit1[0], unit1[1], unit1[2]), random.nextDouble(), RotationConvention.VECTOR_OPERATOR); - FieldRotation r1Prime = new FieldRotation<>(new DerivativeStructure(4, 1, 0, r1.getQ0()), + FieldRotation r1Prime = new FieldRotation(new DerivativeStructure(4, 1, 0, r1.getQ0()), new DerivativeStructure(4, 1, 1, r1.getQ1()), new DerivativeStructure(4, 1, 2, r1.getQ2()), new DerivativeStructure(4, 1, 3, r1.getQ3()), false); double[] unit2 = g.nextVector(); - FieldRotation r2 = new FieldRotation<>(createVector(unit2[0], unit2[1], unit2[2]), + FieldRotation r2 = new FieldRotation(createVector(unit2[0], unit2[1], unit2[2]), createAngle(random.nextDouble()), RotationConvention.VECTOR_OPERATOR); @@ -1047,7 +1047,7 @@ public void testDerivatives() { double theta = 1.7; double cosTheta = FastMath.cos(theta); double sinTheta = FastMath.sin(theta); - FieldRotation r = new FieldRotation<>(createAxis(kx, ky, kz), + FieldRotation r = new FieldRotation(createAxis(kx, ky, kz), createAngle(theta), RotationConvention.VECTOR_OPERATOR); Vector3D a = new Vector3D(kx / n, ky / n, kz / n); @@ -1113,7 +1113,7 @@ public void testDerivatives() { @Test public void testArray() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation<>(createAxis(2, -3, 5), + FieldRotation r = new FieldRotation(createAxis(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); @@ -1143,7 +1143,7 @@ public void testApplyInverseTo() throws MathIllegalArgumentException { DerivativeStructure[] in = new DerivativeStructure[3]; DerivativeStructure[] out = new DerivativeStructure[3]; DerivativeStructure[] rebuilt = new DerivativeStructure[3]; - FieldRotation r = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); for (double lambda = 0; lambda < 6.2; lambda += 0.2) { @@ -1176,7 +1176,7 @@ public void testApplyInverseTo() throws MathIllegalArgumentException { } } - r = new FieldRotation<>(createVector(0, 0, 1), + r = new FieldRotation(createVector(0, 0, 1), createAngle(FastMath.PI), RotationConvention.VECTOR_OPERATOR); for (double lambda = 0; lambda < 6.2; lambda += 0.2) { @@ -1199,7 +1199,7 @@ public void testIssue639() throws MathArithmeticException{ FieldVector3D u2 =createVector( -5712344449280879.0 / 2097152.0, -2275058564560979.0 / 1048576.0, 4423475992255071.0 / 65536.0); - FieldRotation rot = new FieldRotation<>(u1, u2, createVector(1, 0, 0),createVector(0, 0, 1)); + FieldRotation rot = new FieldRotation(u1, u2, createVector(1, 0, 0),createVector(0, 0, 1)); Assert.assertEquals( 0.6228370359608200639829222, rot.getQ0().getReal(), 1.0e-15); Assert.assertEquals( 0.0257707621456498790029987, rot.getQ1().getReal(), 1.0e-15); Assert.assertEquals(-0.0000000002503012255839931, rot.getQ2().getReal(), 1.0e-15); @@ -1214,7 +1214,7 @@ public void testIssue801() throws MathArithmeticException { FieldVector3D v1 = createVector(0.9999999999999999, 0.0, 0.0); FieldVector3D v2 = createVector(0.0, 0.0, -1.0); - FieldRotation quat = new FieldRotation<>(u1, u2, v1, v2); + FieldRotation quat = new FieldRotation(u1, u2, v1, v2); double q2 = quat.getQ0().getReal() * quat.getQ0().getReal() + quat.getQ1().getReal() * quat.getQ1().getReal() + quat.getQ2().getReal() * quat.getQ2().getReal() + @@ -1236,7 +1236,7 @@ private void checkRotationDS(FieldRotation r, double q0, do private FieldRotation createRotation(double q0, double q1, double q2, double q3, boolean needsNormalization) { - return new FieldRotation<>(new DerivativeStructure(4, 1, 0, q0), + return new FieldRotation(new DerivativeStructure(4, 1, 0, q0), new DerivativeStructure(4, 1, 1, q1), new DerivativeStructure(4, 1, 2, q2), new DerivativeStructure(4, 1, 3, q3), @@ -1252,17 +1252,17 @@ private FieldRotation createRotation(double[][] m, double t index = (index + 1) % 4; } } - return new FieldRotation<>(mds, threshold); + return new FieldRotation(mds, threshold); } private FieldVector3D createVector(double x, double y, double z) { - return new FieldVector3D<>(new DerivativeStructure(4, 1, x), + return new FieldVector3D(new DerivativeStructure(4, 1, x), new DerivativeStructure(4, 1, y), new DerivativeStructure(4, 1, z)); } private FieldVector3D createAxis(double x, double y, double z) { - return new FieldVector3D<>(new DerivativeStructure(4, 1, 0, x), + return new FieldVector3D(new DerivativeStructure(4, 1, 0, x), new DerivativeStructure(4, 1, 1, y), new DerivativeStructure(4, 1, 2, z)); } diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java index 386e6432bc..e7df1b0c67 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java @@ -65,7 +65,7 @@ public void testIdentity() { @Deprecated public void testAxisAngleDeprecated() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation<>(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3)); + FieldRotation r = new FieldRotation(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3)); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 1, 0)); checkVector(r.applyTo(createVector(0, 1, 0)), createVector(0, 0, 1)); checkVector(r.applyTo(createVector(0, 0, 1)), createVector(1, 0, 0)); @@ -74,16 +74,16 @@ public void testAxisAngleDeprecated() throws MathIllegalArgumentException { checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new FieldRotation<>(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3)); + new FieldRotation(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3)); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new FieldRotation<>(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI)); + r = new FieldRotation(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI)); checkVector(r.getAxis(), createVector(0, 0, -1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new FieldRotation<>(createAxis(0, 1, 0), createAngle(FastMath.PI)); + r = new FieldRotation(createAxis(0, 1, 0), createAngle(FastMath.PI)); checkVector(r.getAxis(), createVector(0, 1, 0)); checkAngle(r.getAngle(), FastMath.PI); @@ -94,7 +94,7 @@ public void testAxisAngleDeprecated() throws MathIllegalArgumentException { @Test public void testAxisAngleVectorOperator() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation<>(createAxis(10, 10, 10), + FieldRotation r = new FieldRotation(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3) , RotationConvention.VECTOR_OPERATOR); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 1, 0)); @@ -106,21 +106,21 @@ public void testAxisAngleVectorOperator() throws MathIllegalArgumentException { checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new FieldRotation<>(createAxis(0, 0, 0), + new FieldRotation(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3), RotationConvention.VECTOR_OPERATOR); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new FieldRotation<>(createAxis(0, 0, 1), + r = new FieldRotation(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI), RotationConvention.VECTOR_OPERATOR); checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, 0, -1)); checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, 0, +1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new FieldRotation<>(createAxis(0, 1, 0), + r = new FieldRotation(createAxis(0, 1, 0), createAngle(FastMath.PI), RotationConvention.VECTOR_OPERATOR); checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, +1, 0)); @@ -135,7 +135,7 @@ public void testAxisAngleVectorOperator() throws MathIllegalArgumentException { @Test public void testAxisAngleFrameTransform() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation<>(createAxis(10, 10, 10), + FieldRotation r = new FieldRotation(createAxis(10, 10, 10), createAngle(2 * FastMath.PI / 3) , RotationConvention.FRAME_TRANSFORM); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 0, 1)); @@ -147,21 +147,21 @@ public void testAxisAngleFrameTransform() throws MathIllegalArgumentException { checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new FieldRotation<>(createAxis(0, 0, 0), + new FieldRotation(createAxis(0, 0, 0), createAngle(2 * FastMath.PI / 3), RotationConvention.FRAME_TRANSFORM); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new FieldRotation<>(createAxis(0, 0, 1), + r = new FieldRotation(createAxis(0, 0, 1), createAngle(1.5 * FastMath.PI), RotationConvention.FRAME_TRANSFORM); checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, 0, -1)); checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, 0, +1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new FieldRotation<>(createAxis(0, 1, 0), + r = new FieldRotation(createAxis(0, 1, 0), createAngle(FastMath.PI), RotationConvention.FRAME_TRANSFORM); checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, +1, 0)); @@ -235,13 +235,13 @@ public void testVectorOnePair() throws MathArithmeticException { FieldVector3D u = createVector(3, 2, 1); FieldVector3D v = createVector(-4, 2, 2); - FieldRotation r = new FieldRotation<>(u, v); + FieldRotation r = new FieldRotation(u, v); checkVector(r.applyTo(u.scalarMultiply(v.getNorm())), v.scalarMultiply(u.getNorm())); - checkAngle(new FieldRotation<>(u, u.negate()).getAngle(), FastMath.PI); + checkAngle(new FieldRotation(u, u.negate()).getAngle(), FastMath.PI); try { - new FieldRotation<>(u, createVector(0, 0, 0)); + new FieldRotation(u, createVector(0, 0, 0)); Assert.fail("an exception should have been thrown"); } catch (MathArithmeticException e) { // expected behavior @@ -256,11 +256,11 @@ public void testVectorTwoPairs() throws MathArithmeticException { FieldVector3D u2 = createVector(0, 5, 0); FieldVector3D v1 = createVector(0, 0, 2); FieldVector3D v2 = createVector(-2, 0, 2); - FieldRotation r = new FieldRotation<>(u1, u2, v1, v2); + FieldRotation r = new FieldRotation(u1, u2, v1, v2); checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 0, 1)); checkVector(r.applyTo(createVector(0, 1, 0)), createVector(-1, 0, 0)); - r = new FieldRotation<>(u1, u2, u1.negate(), u2.negate()); + r = new FieldRotation(u1, u2, u1.negate(), u2.negate()); FieldVector3D axis = r.getAxis(RotationConvention.VECTOR_OPERATOR); if (FieldVector3D.dotProduct(axis, createVector(0, 0, 1)).getReal() > 0) { checkVector(axis, createVector(0, 0, 1)); @@ -270,18 +270,18 @@ public void testVectorTwoPairs() throws MathArithmeticException { checkAngle(r.getAngle(), FastMath.PI); double sqrt = FastMath.sqrt(2) / 2; - r = new FieldRotation<>(createVector(1, 0, 0), createVector(0, 1, 0), + r = new FieldRotation(createVector(1, 0, 0), createVector(0, 1, 0), createVector(0.5, 0.5, sqrt), createVector(0.5, 0.5, -sqrt)); checkRotationDS(r, sqrt, 0.5, 0.5, 0); - r = new FieldRotation<>(u1, u2, u1, FieldVector3D.crossProduct(u1, u2)); + r = new FieldRotation(u1, u2, u1, FieldVector3D.crossProduct(u1, u2)); checkRotationDS(r, sqrt, -sqrt, 0, 0); - checkRotationDS(new FieldRotation<>(u1, u2, u1, u2), 1, 0, 0, 0); + checkRotationDS(new FieldRotation(u1, u2, u1, u2), 1, 0, 0, 0); try { - new FieldRotation<>(u1, u2, createVector(0, 0, 0), v2); + new FieldRotation(u1, u2, createVector(0, 0, 0), v2); Assert.fail("an exception should have been thrown"); } catch (MathArithmeticException e) { // expected behavior @@ -411,11 +411,11 @@ public void testMatrix() } checkVector(r.applyTo(createVector(1, 0, 0)), - new FieldVector3D<>(m3[0][0], m3[1][0], m3[2][0])); + new FieldVector3D(m3[0][0], m3[1][0], m3[2][0])); checkVector(r.applyTo(createVector(0, 1, 0)), - new FieldVector3D<>(m3[0][1], m3[1][1], m3[2][1])); + new FieldVector3D(m3[0][1], m3[1][1], m3[2][1])); checkVector(r.applyTo(createVector(0, 0, 1)), - new FieldVector3D<>(m3[0][2], m3[1][2], m3[2][2])); + new FieldVector3D(m3[0][2], m3[1][2], m3[2][2])); double[][] m4 = { { 1.0, 0.0, 0.0 }, { 0.0, -1.0, 0.0 }, @@ -451,7 +451,7 @@ public void testAnglesDeprecated() for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 2.0) { for (double alpha2 = -1.55; alpha2 < 1.55; alpha2 += 0.8) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 2.0) { - FieldRotation r = new FieldRotation<>(CardanOrders[i], + FieldRotation r = new FieldRotation(CardanOrders[i], field.newDfp(alpha1), field.newDfp(alpha2), field.newDfp(alpha3)); @@ -473,7 +473,7 @@ public void testAnglesDeprecated() for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 2.0) { for (double alpha2 = 0.05; alpha2 < 3.1; alpha2 += 0.8) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 2.0) { - FieldRotation r = new FieldRotation<>(EulerOrders[i], + FieldRotation r = new FieldRotation(EulerOrders[i], field.newDfp(alpha1), field.newDfp(alpha2), field.newDfp(alpha3)); @@ -504,7 +504,7 @@ public void testAngles() for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 2.0) { for (double alpha2 = -1.55; alpha2 < 1.55; alpha2 += 0.8) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 2.0) { - FieldRotation r = new FieldRotation<>(CardanOrders[i], + FieldRotation r = new FieldRotation(CardanOrders[i], convention, field.newDfp(alpha1), field.newDfp(alpha2), @@ -527,7 +527,7 @@ public void testAngles() for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 2.0) { for (double alpha2 = 0.05; alpha2 < 3.1; alpha2 += 0.8) { for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 2.0) { - FieldRotation r = new FieldRotation<>(EulerOrders[i], + FieldRotation r = new FieldRotation(EulerOrders[i], convention, field.newDfp(alpha1), field.newDfp(alpha2), @@ -557,7 +557,7 @@ public void testSingularities() { double[] singularCardanAngle = { FastMath.PI / 2, -FastMath.PI / 2 }; for (int i = 0; i < CardanOrders.length; ++i) { for (int j = 0; j < singularCardanAngle.length; ++j) { - FieldRotation r = new FieldRotation<>(CardanOrders[i], + FieldRotation r = new FieldRotation(CardanOrders[i], convention, field.newDfp(0.1), field.newDfp(singularCardanAngle[j]), @@ -579,7 +579,7 @@ public void testSingularities() { double[] singularEulerAngle = { 0, FastMath.PI }; for (int i = 0; i < EulerOrders.length; ++i) { for (int j = 0; j < singularEulerAngle.length; ++j) { - FieldRotation r = new FieldRotation<>(EulerOrders[i], + FieldRotation r = new FieldRotation(EulerOrders[i], convention, field.newDfp(0.1), field.newDfp(singularEulerAngle[j]), @@ -599,11 +599,11 @@ public void testSingularities() { @Test public void testQuaternion() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); double n = 23.5; - FieldRotation r2 = new FieldRotation<>(r1.getQ0().multiply(n), r1.getQ1().multiply(n), + FieldRotation r2 = new FieldRotation(r1.getQ0().multiply(n), r1.getQ1().multiply(n), r1.getQ2().multiply(n), r1.getQ3().multiply(n), true); for (double x = -0.9; x < 0.9; x += 0.2) { @@ -625,10 +625,10 @@ public void testQuaternion() throws MathIllegalArgumentException { @Test public void testApplyToRotation() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.applyTo(r1); @@ -653,10 +653,10 @@ public void testApplyToRotation() throws MathIllegalArgumentException { @Test public void testComposeVectorOperator() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.compose(r1, RotationConvention.VECTOR_OPERATOR); @@ -682,10 +682,10 @@ public void testComposeVectorOperator() throws MathIllegalArgumentException { @Test public void testComposeFrameTransform() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.FRAME_TRANSFORM); - FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.FRAME_TRANSFORM); FieldRotation r3 = r2.compose(r1, RotationConvention.FRAME_TRANSFORM); @@ -713,10 +713,10 @@ public void testComposeFrameTransform() throws MathIllegalArgumentException { @Test public void testApplyInverseToRotation() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.applyInverseTo(r1); @@ -741,10 +741,10 @@ public void testApplyInverseToRotation() throws MathIllegalArgumentException { @Test public void testComposeInverseVectorOperator() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); - FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.VECTOR_OPERATOR); FieldRotation r3 = r2.composeInverse(r1, RotationConvention.VECTOR_OPERATOR); @@ -770,10 +770,10 @@ public void testComposeInverseVectorOperator() throws MathIllegalArgumentExcepti @Test public void testComposeInverseFrameTransform() throws MathIllegalArgumentException { - FieldRotation r1 = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r1 = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.FRAME_TRANSFORM); - FieldRotation r2 = new FieldRotation<>(createVector(-1, 3, 2), + FieldRotation r2 = new FieldRotation(createVector(-1, 3, 2), createAngle(0.3), RotationConvention.FRAME_TRANSFORM); FieldRotation r3 = r2.composeInverse(r1, RotationConvention.FRAME_TRANSFORM); @@ -805,7 +805,7 @@ public void testDoubleVectors() throws MathIllegalArgumentException { UnitSphereRandomVectorGenerator g = new UnitSphereRandomVectorGenerator(3, random); for (int i = 0; i < 10; ++i) { double[] unit = g.nextVector(); - FieldRotation r = new FieldRotation<>(createVector(unit[0], unit[1], unit[2]), + FieldRotation r = new FieldRotation(createVector(unit[0], unit[1], unit[2]), createAngle(random.nextDouble()), RotationConvention.VECTOR_OPERATOR); @@ -823,9 +823,9 @@ public void testDoubleVectors() throws MathIllegalArgumentException { Dfp[] rIuArray = new Dfp[3]; r.applyInverseTo(new double[] { x, y, z}, rIuArray); checkVector(ruds, ru); - checkVector(ruds, new FieldVector3D<>(ruArray)); + checkVector(ruds, new FieldVector3D(ruArray)); checkVector(rIuds, rIu); - checkVector(rIuds, new FieldVector3D<>(rIuArray)); + checkVector(rIuds, new FieldVector3D(rIuArray)); } } } @@ -843,13 +843,13 @@ public void testDoubleRotations() throws MathIllegalArgumentException { double[] unit1 = g.nextVector(); Rotation r1 = new Rotation(new Vector3D(unit1[0], unit1[1], unit1[2]), random.nextDouble(), RotationConvention.VECTOR_OPERATOR); - FieldRotation r1Prime = new FieldRotation<>(field.newDfp(r1.getQ0()), + FieldRotation r1Prime = new FieldRotation(field.newDfp(r1.getQ0()), field.newDfp(r1.getQ1()), field.newDfp(r1.getQ2()), field.newDfp(r1.getQ3()), false); double[] unit2 = g.nextVector(); - FieldRotation r2 = new FieldRotation<>(createVector(unit2[0], unit2[1], unit2[2]), + FieldRotation r2 = new FieldRotation(createVector(unit2[0], unit2[1], unit2[2]), createAngle(random.nextDouble()), RotationConvention.VECTOR_OPERATOR); @@ -880,7 +880,7 @@ public void testDoubleRotations() throws MathIllegalArgumentException { @Test public void testArray() throws MathIllegalArgumentException { - FieldRotation r = new FieldRotation<>(createAxis(2, -3, 5), + FieldRotation r = new FieldRotation(createAxis(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); @@ -910,7 +910,7 @@ public void testApplyInverseTo() throws MathIllegalArgumentException { Dfp[] in = new Dfp[3]; Dfp[] out = new Dfp[3]; Dfp[] rebuilt = new Dfp[3]; - FieldRotation r = new FieldRotation<>(createVector(2, -3, 5), + FieldRotation r = new FieldRotation(createVector(2, -3, 5), createAngle(1.7), RotationConvention.VECTOR_OPERATOR); for (double lambda = 0; lambda < 6.2; lambda += 0.2) { @@ -943,7 +943,7 @@ public void testApplyInverseTo() throws MathIllegalArgumentException { } } - r = new FieldRotation<>(createVector(0, 0, 1), createAngle(FastMath.PI), RotationConvention.VECTOR_OPERATOR); + r = new FieldRotation(createVector(0, 0, 1), createAngle(FastMath.PI), RotationConvention.VECTOR_OPERATOR); for (double lambda = 0; lambda < 6.2; lambda += 0.2) { for (double phi = -1.55; phi < 1.55; phi += 0.2) { FieldVector3D u = createVector(FastMath.cos(lambda) * FastMath.cos(phi), @@ -964,7 +964,7 @@ public void testIssue639() throws MathArithmeticException{ FieldVector3D u2 =createVector( -5712344449280879.0 / 2097152.0, -2275058564560979.0 / 1048576.0, 4423475992255071.0 / 65536.0); - FieldRotation rot = new FieldRotation<>(u1, u2, createVector(1, 0, 0),createVector(0, 0, 1)); + FieldRotation rot = new FieldRotation(u1, u2, createVector(1, 0, 0),createVector(0, 0, 1)); Assert.assertEquals( 0.6228370359608200639829222, rot.getQ0().getReal(), 1.0e-15); Assert.assertEquals( 0.0257707621456498790029987, rot.getQ1().getReal(), 1.0e-15); Assert.assertEquals(-0.0000000002503012255839931, rot.getQ2().getReal(), 1.0e-15); @@ -979,7 +979,7 @@ public void testIssue801() throws MathArithmeticException { FieldVector3D v1 = createVector(0.9999999999999999, 0.0, 0.0); FieldVector3D v2 = createVector(0.0, 0.0, -1.0); - FieldRotation quat = new FieldRotation<>(u1, u2, v1, v2); + FieldRotation quat = new FieldRotation(u1, u2, v1, v2); double q2 = quat.getQ0().getReal() * quat.getQ0().getReal() + quat.getQ1().getReal() * quat.getQ1().getReal() + quat.getQ2().getReal() * quat.getQ2().getReal() + @@ -1002,7 +1002,7 @@ private void checkRotationDS(FieldRotation r, double q0, double q1, double private FieldRotation createRotation(double q0, double q1, double q2, double q3, boolean needsNormalization) { DfpField field = new DfpField(20); - return new FieldRotation<>(field.newDfp(q0), + return new FieldRotation(field.newDfp(q0), field.newDfp(q1), field.newDfp(q2), field.newDfp(q3), @@ -1017,17 +1017,17 @@ private FieldRotation createRotation(double[][] m, double threshold) { mds[i][j] = field.newDfp(m[i][j]); } } - return new FieldRotation<>(mds, threshold); + return new FieldRotation(mds, threshold); } private FieldVector3D createVector(double x, double y, double z) { DfpField field = new DfpField(20); - return new FieldVector3D<>(field.newDfp(x), field.newDfp(y), field.newDfp(z)); + return new FieldVector3D(field.newDfp(x), field.newDfp(y), field.newDfp(z)); } private FieldVector3D createAxis(double x, double y, double z) { DfpField field = new DfpField(20); - return new FieldVector3D<>(field.newDfp(x), field.newDfp(y), field.newDfp(z)); + return new FieldVector3D(field.newDfp(x), field.newDfp(y), field.newDfp(z)); } private Dfp createAngle(double alpha) { diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java index 758e870057..24e5515046 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java @@ -41,8 +41,8 @@ public void testConstructors() throws DimensionMismatchException { double sinAlpha = FastMath.sqrt(3) / 2.0; double cosDelta = FastMath.sqrt(2) / 2.0; double sinDelta = -FastMath.sqrt(2) / 2.0; - FieldVector3D u = new FieldVector3D<>(2, - new FieldVector3D<>(new DerivativeStructure(2, 1, 0, FastMath.PI / 3), + FieldVector3D u = new FieldVector3D(2, + new FieldVector3D(new DerivativeStructure(2, 1, 0, FastMath.PI / 3), new DerivativeStructure(2, 1, 1, -FastMath.PI / 4))); checkVector(u, 2 * cosAlpha * cosDelta, 2 * sinAlpha * cosDelta, 2 * sinDelta); Assert.assertEquals(-2 * sinAlpha * cosDelta, u.getX().getPartialDerivative(1, 0), 1.0e-12); @@ -52,41 +52,41 @@ public void testConstructors() throws DimensionMismatchException { Assert.assertEquals(-2 * sinAlpha * sinDelta, u.getY().getPartialDerivative(0, 1), 1.0e-12); Assert.assertEquals(2 * cosDelta, u.getZ().getPartialDerivative(0, 1), 1.0e-12); - checkVector(new FieldVector3D<>(2, createVector(1, 0, 0, 3)), + checkVector(new FieldVector3D(2, createVector(1, 0, 0, 3)), 2, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2); - checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), createVector(1, 0, 0, 4)), 2, 0, 0, 2, 0, 0, 1, 0, 2, 0, 0, 0, 0, 2, 0); - checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), new Vector3D(1, 0, 0)), 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0); - checkVector(new FieldVector3D<>(2, createVector(1, 0, 0, 3), + checkVector(new FieldVector3D(2, createVector(1, 0, 0, 3), -3, createVector(0, 0, -1, 3)), 2, 0, 3, -1, 0, 0, 0, -1, 0, 0, 0, -1); - checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), createVector(1, 0, 0, 4), new DerivativeStructure(4, 1, 3, -3.0), createVector(0, 0, -1, 4)), 2, 0, 3, -1, 0, 0, 1, 0, -1, 0, 0, 0, 0, -1, -1); - checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), new Vector3D(1, 0, 0), new DerivativeStructure(4, 1, 3, -3.0), new Vector3D(0, 0, -1)), 2, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1); - checkVector(new FieldVector3D<>(2, createVector(1, 0, 0, 3), + checkVector(new FieldVector3D(2, createVector(1, 0, 0, 3), 5, createVector(0, 1, 0, 3), -3, createVector(0, 0, -1, 3)), 2, 5, 3, 4, 0, 0, 0, 4, 0, 0, 0, 4); - checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), createVector(1, 0, 0, 4), new DerivativeStructure(4, 1, 3, 5.0), createVector(0, 1, 0, 4), new DerivativeStructure(4, 1, 3, -3.0), createVector(0, 0, -1, 4)), 2, 5, 3, 4, 0, 0, 1, 0, 4, 0, 1, 0, 0, 4, -1); - checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), new Vector3D(1, 0, 0), new DerivativeStructure(4, 1, 3, 5.0), new Vector3D(0, 1, 0), @@ -94,12 +94,12 @@ public void testConstructors() throws DimensionMismatchException { new Vector3D(0, 0, -1)), 2, 5, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, -1); - checkVector(new FieldVector3D<>(2, createVector(1, 0, 0, 3), + checkVector(new FieldVector3D(2, createVector(1, 0, 0, 3), 5, createVector(0, 1, 0, 3), 5, createVector(0, -1, 0, 3), -3, createVector(0, 0, -1, 3)), 2, 0, 3, 9, 0, 0, 0, 9, 0, 0, 0, 9); - checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), createVector(1, 0, 0, 4), new DerivativeStructure(4, 1, 3, 5.0), createVector(0, 1, 0, 4), @@ -108,7 +108,7 @@ public void testConstructors() throws DimensionMismatchException { new DerivativeStructure(4, 1, 3, -3.0), createVector(0, 0, -1, 4)), 2, 0, 3, 9, 0, 0, 1, 0, 9, 0, 0, 0, 0, 9, -1); - checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0), + checkVector(new FieldVector3D(new DerivativeStructure(4, 1, 3, 2.0), new Vector3D(1, 0, 0), new DerivativeStructure(4, 1, 3, 5.0), new Vector3D(0, 1, 0), @@ -118,7 +118,7 @@ public void testConstructors() throws DimensionMismatchException { new Vector3D(0, 0, -1)), 2, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1); - checkVector(new FieldVector3D<>(new DerivativeStructure[] { + checkVector(new FieldVector3D(new DerivativeStructure[] { new DerivativeStructure(3, 1, 2, 2), new DerivativeStructure(3, 1, 1, 5), new DerivativeStructure(3, 1, 0, -3) @@ -132,16 +132,16 @@ public void testEquals() { FieldVector3D u1 = createVector(1, 2, 3, 3); FieldVector3D v = createVector(1, 2, 3 + 10 * Precision.EPSILON, 3); Assert.assertTrue(u1.equals(u1)); - Assert.assertTrue(u1.equals(new FieldVector3D<>(new DerivativeStructure(3, 1, 0, 1.0), + Assert.assertTrue(u1.equals(new FieldVector3D(new DerivativeStructure(3, 1, 0, 1.0), new DerivativeStructure(3, 1, 1, 2.0), new DerivativeStructure(3, 1, 2, 3.0)))); - Assert.assertFalse(u1.equals(new FieldVector3D<>(new DerivativeStructure(3, 1, 1.0), + Assert.assertFalse(u1.equals(new FieldVector3D(new DerivativeStructure(3, 1, 1.0), new DerivativeStructure(3, 1, 1, 2.0), new DerivativeStructure(3, 1, 2, 3.0)))); - Assert.assertFalse(u1.equals(new FieldVector3D<>(new DerivativeStructure(3, 1, 0, 1.0), + Assert.assertFalse(u1.equals(new FieldVector3D(new DerivativeStructure(3, 1, 0, 1.0), new DerivativeStructure(3, 1, 2.0), new DerivativeStructure(3, 1, 2, 3.0)))); - Assert.assertFalse(u1.equals(new FieldVector3D<>(new DerivativeStructure(3, 1, 0, 1.0), + Assert.assertFalse(u1.equals(new FieldVector3D(new DerivativeStructure(3, 1, 0, 1.0), new DerivativeStructure(3, 1, 1, 2.0), new DerivativeStructure(3, 1, 3.0)))); Assert.assertFalse(u1.equals(v)); @@ -184,7 +184,7 @@ public void testToString() { @Test(expected=DimensionMismatchException.class) public void testWrongDimension() throws DimensionMismatchException { - new FieldVector3D<>(new DerivativeStructure[] { + new FieldVector3D(new DerivativeStructure[] { new DerivativeStructure(3, 1, 0, 2), new DerivativeStructure(3, 1, 0, 5) }); @@ -475,8 +475,8 @@ public void testCrossProductCancellation() { checkVector(FieldVector3D.crossProduct(v1, v2), -1, 2, 1); double scale = FastMath.scalb(1.0, 100); - FieldVector3D big1 = new FieldVector3D<>(scale, v1); - FieldVector3D small2 = new FieldVector3D<>(1 / scale, v2); + FieldVector3D big1 = new FieldVector3D(scale, v1); + FieldVector3D small2 = new FieldVector3D(1 / scale, v2); checkVector(FieldVector3D.crossProduct(big1, small2), -1, 2, 1); } @@ -637,7 +637,7 @@ public void testAccurateCrossProduct() { final FieldVector3D u3 = createVector(12753243807587107.0 / 18446744073709551616.0, -2313766922703915.0 / 18446744073709551616.0, -227970081415313.0 / 288230376151711744.0, 3); - FieldVector3D cNaive = new FieldVector3D<>(u1.getY().multiply(u2.getZ()).subtract(u1.getZ().multiply(u2.getY())), + FieldVector3D cNaive = new FieldVector3D(u1.getY().multiply(u2.getZ()).subtract(u1.getZ().multiply(u2.getY())), u1.getZ().multiply(u2.getX()).subtract(u1.getX().multiply(u2.getZ())), u1.getX().multiply(u2.getY()).subtract(u1.getY().multiply(u2.getX()))); FieldVector3D cAccurate = FieldVector3D.crossProduct(u1, u2); @@ -679,7 +679,7 @@ public void testCrossProduct() { } private FieldVector3D createVector(double x, double y, double z, int params) { - return new FieldVector3D<>(new DerivativeStructure(params, 1, 0, x), + return new FieldVector3D(new DerivativeStructure(params, 1, 0, x), new DerivativeStructure(params, 1, 1, y), new DerivativeStructure(params, 1, 2, z)); } diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PLYParser.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PLYParser.java index 7670e69ad3..f65663cc25 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PLYParser.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PLYParser.java @@ -214,7 +214,7 @@ private void complain() throws ParseException { */ private List parseNextLine() throws IOException, ParseException { - final List fields = new ArrayList<>(); + final List fields = new ArrayList(); line = br.readLine(); if (line == null) { throw new EOFException(); diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java index d8b1d7dbb4..b1b902ad52 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java @@ -243,7 +243,7 @@ public void testCross() { new PolyhedronsSet(x - w, x + w, y - l, y + l, z - w, z + w, 1.0e-10); PolyhedronsSet zBeam = new PolyhedronsSet(x - w, x + w, y - w, y + w, z - l, z + l, 1.0e-10); - RegionFactory factory = new RegionFactory<>(); + RegionFactory factory = new RegionFactory(); PolyhedronsSet tree = (PolyhedronsSet) factory.union(xBeam, factory.union(yBeam, zBeam)); Vector3D barycenter = (Vector3D) tree.getBarycenter(); @@ -273,7 +273,7 @@ public void testIssue780() throws MathArithmeticException { 1, 5, 6, 1, 6, 2, 2, 6, 7, 2, 7, 3, 4, 0, 3, 4, 3, 7}; - ArrayList> subHyperplaneList = new ArrayList<>(); + ArrayList> subHyperplaneList = new ArrayList>(); for (int idx = 0; idx < indices.length; idx += 3) { int idxA = indices[idx] * 3; int idxB = indices[idx + 1] * 3; @@ -283,7 +283,7 @@ public void testIssue780() throws MathArithmeticException { Vector3D v_3 = new Vector3D(coords[idxC], coords[idxC + 1], coords[idxC + 2]); Vector3D[] vertices = {v_1, v_2, v_3}; Plane polyPlane = new Plane(v_1, v_2, v_3, 1.0e-10); - ArrayList> lines = new ArrayList<>(); + ArrayList> lines = new ArrayList>(); Vector2D[] projPts = new Vector2D[vertices.length]; for (int ptIdx = 0; ptIdx < projPts.length; ptIdx++) { diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGeneratorTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGeneratorTest.java index 81b9b2382b..5fdc4f6feb 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGeneratorTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGeneratorTest.java @@ -143,7 +143,7 @@ public void testRandom() { double d = 25 * random.nextDouble(); double refRadius = 10 * random.nextDouble(); Vector3D refCenter = new Vector3D(d, new Vector3D(sr.nextVector())); - List support = new ArrayList<>(); + List support = new ArrayList(); for (int j = 0; j < 5; ++j) { support.add(new Vector3D(1.0, refCenter, refRadius, new Vector3D(sr.nextVector()))); } diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGeneratorTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGeneratorTest.java index 8c5268245f..5ca929589e 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGeneratorTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGeneratorTest.java @@ -108,7 +108,7 @@ public void testRandom() { double d = 25 * random.nextDouble(); double refRadius = 10 * random.nextDouble(); Vector2D refCenter = new Vector2D(d, new Vector2D(sr.nextVector())); - List support = new ArrayList<>(); + List support = new ArrayList(); for (int j = 0; j < 3; ++j) { support.add(new Vector2D(1.0, refCenter, refRadius, new Vector2D(sr.nextVector()))); } diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java index bb4e51bb29..28b5eda93d 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java @@ -675,15 +675,15 @@ public void testChoppedHexagon() { hyp[4] = (SubLine) hyp[4].split(hyp[3].getHyperplane()).getMinus().split(hyp[0].getHyperplane()).getMinus(); hyp[5] = (SubLine) hyp[5].split(hyp[4].getHyperplane()).getMinus().split(hyp[0].getHyperplane()).getMinus(); hyp[6] = (SubLine) hyp[6].split(hyp[3].getHyperplane()).getMinus().split(hyp[1].getHyperplane()).getMinus(); - BSPTree tree = new BSPTree<>(Boolean.TRUE); + BSPTree tree = new BSPTree(Boolean.TRUE); for (int i = hyp.length - 1; i >= 0; --i) { - tree = new BSPTree<>(hyp[i], new BSPTree(Boolean.FALSE), tree, null); + tree = new BSPTree(hyp[i], new BSPTree(Boolean.FALSE), tree, null); } PolygonsSet set = new PolygonsSet(tree, 1.0e-10); SubLine splitter = new Line(new Vector2D(-2.0 * sqrt3 / 3.0, 0.0), 9 * pi6, 1.0e-10).wholeHyperplane(); PolygonsSet slice = - new PolygonsSet(new BSPTree<>(splitter, + new PolygonsSet(new BSPTree(splitter, set.getTree(false).split(splitter).getPlus(), new BSPTree(Boolean.FALSE), null), 1.0e-10); @@ -726,85 +726,85 @@ public void testConcentric() { @Test public void testBug20040520() { BSPTree a0 = - new BSPTree<>(buildSegment(new Vector2D(0.85, -0.05), + new BSPTree(buildSegment(new Vector2D(0.85, -0.05), new Vector2D(0.90, -0.10)), new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null); BSPTree a1 = - new BSPTree<>(buildSegment(new Vector2D(0.85, -0.10), + new BSPTree(buildSegment(new Vector2D(0.85, -0.10), new Vector2D(0.90, -0.10)), new BSPTree(Boolean.FALSE), a0, null); BSPTree a2 = - new BSPTree<>(buildSegment(new Vector2D(0.90, -0.05), + new BSPTree(buildSegment(new Vector2D(0.90, -0.05), new Vector2D(0.85, -0.05)), new BSPTree(Boolean.FALSE), a1, null); BSPTree a3 = - new BSPTree<>(buildSegment(new Vector2D(0.82, -0.05), + new BSPTree(buildSegment(new Vector2D(0.82, -0.05), new Vector2D(0.82, -0.08)), new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null); BSPTree a4 = - new BSPTree<>(buildHalfLine(new Vector2D(0.85, -0.05), + new BSPTree(buildHalfLine(new Vector2D(0.85, -0.05), new Vector2D(0.80, -0.05), false), new BSPTree(Boolean.FALSE), a3, null); BSPTree a5 = - new BSPTree<>(buildSegment(new Vector2D(0.82, -0.08), + new BSPTree(buildSegment(new Vector2D(0.82, -0.08), new Vector2D(0.82, -0.18)), new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null); BSPTree a6 = - new BSPTree<>(buildHalfLine(new Vector2D(0.82, -0.18), + new BSPTree(buildHalfLine(new Vector2D(0.82, -0.18), new Vector2D(0.85, -0.15), true), new BSPTree(Boolean.FALSE), a5, null); BSPTree a7 = - new BSPTree<>(buildHalfLine(new Vector2D(0.85, -0.05), + new BSPTree(buildHalfLine(new Vector2D(0.85, -0.05), new Vector2D(0.82, -0.08), false), a4, a6, null); BSPTree a8 = - new BSPTree<>(buildLine(new Vector2D(0.85, -0.25), + new BSPTree(buildLine(new Vector2D(0.85, -0.25), new Vector2D(0.85, 0.05)), a2, a7, null); BSPTree a9 = - new BSPTree<>(buildLine(new Vector2D(0.90, 0.05), + new BSPTree(buildLine(new Vector2D(0.90, 0.05), new Vector2D(0.90, -0.50)), a8, new BSPTree(Boolean.FALSE), null); BSPTree b0 = - new BSPTree<>(buildSegment(new Vector2D(0.92, -0.12), + new BSPTree(buildSegment(new Vector2D(0.92, -0.12), new Vector2D(0.92, -0.08)), new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null); BSPTree b1 = - new BSPTree<>(buildHalfLine(new Vector2D(0.92, -0.08), + new BSPTree(buildHalfLine(new Vector2D(0.92, -0.08), new Vector2D(0.90, -0.10), true), new BSPTree(Boolean.FALSE), b0, null); BSPTree b2 = - new BSPTree<>(buildSegment(new Vector2D(0.92, -0.18), + new BSPTree(buildSegment(new Vector2D(0.92, -0.18), new Vector2D(0.92, -0.12)), new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null); BSPTree b3 = - new BSPTree<>(buildSegment(new Vector2D(0.85, -0.15), + new BSPTree(buildSegment(new Vector2D(0.85, -0.15), new Vector2D(0.90, -0.20)), new BSPTree(Boolean.FALSE), b2, null); BSPTree b4 = - new BSPTree<>(buildSegment(new Vector2D(0.95, -0.15), + new BSPTree(buildSegment(new Vector2D(0.95, -0.15), new Vector2D(0.85, -0.05)), b1, b3, null); BSPTree b5 = - new BSPTree<>(buildHalfLine(new Vector2D(0.85, -0.05), + new BSPTree(buildHalfLine(new Vector2D(0.85, -0.05), new Vector2D(0.85, -0.25), true), new BSPTree(Boolean.FALSE), b4, null); BSPTree b6 = - new BSPTree<>(buildLine(new Vector2D(0.0, -1.10), + new BSPTree(buildLine(new Vector2D(0.0, -1.10), new Vector2D(1.0, -0.10)), new BSPTree(Boolean.FALSE), b5, null); @@ -866,7 +866,7 @@ public void testBug20041003() { }; BSPTree node1 = - new BSPTree<>(new SubLine(l[0], + new BSPTree(new SubLine(l[0], new IntervalsSet(intersectionAbscissa(l[0], l[1]), intersectionAbscissa(l[0], l[2]), 1.0e-10)), @@ -874,7 +874,7 @@ public void testBug20041003() { new BSPTree(Boolean.FALSE), null); BSPTree node2 = - new BSPTree<>(new SubLine(l[1], + new BSPTree(new SubLine(l[1], new IntervalsSet(intersectionAbscissa(l[1], l[2]), intersectionAbscissa(l[1], l[3]), 1.0e-10)), @@ -882,14 +882,14 @@ public void testBug20041003() { new BSPTree(Boolean.FALSE), null); BSPTree node3 = - new BSPTree<>(new SubLine(l[2], + new BSPTree(new SubLine(l[2], new IntervalsSet(intersectionAbscissa(l[2], l[3]), Double.POSITIVE_INFINITY, 1.0e-10)), node2, new BSPTree(Boolean.FALSE), null); BSPTree node4 = - new BSPTree<>(l[3].wholeHyperplane(), + new BSPTree(l[3].wholeHyperplane(), node3, new BSPTree(Boolean.FALSE), null); @@ -1126,7 +1126,7 @@ public void testIssue1162() { @Test public void testThinRectangle() { - RegionFactory factory = new RegionFactory<>(); + RegionFactory factory = new RegionFactory(); Vector2D pA = new Vector2D(0.0, 1.0); Vector2D pB = new Vector2D(0.0, 0.0); Vector2D pC = new Vector2D(1.0 / 64.0, 0.0); @@ -1236,7 +1236,7 @@ public int getLeafNodes() { } private PolygonsSet buildSet(Vector2D[][] vertices) { - ArrayList> edges = new ArrayList<>(); + ArrayList> edges = new ArrayList>(); for (int i = 0; i < vertices.length; ++i) { int l = vertices[i].length; for (int j = 0; j < l; ++j) { diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java index d1af7a5284..717b2644c4 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java @@ -93,7 +93,7 @@ public void testTwoPoints() { @Test public void testAllIdentical() { - final Collection points = new ArrayList<>(); + final Collection points = new ArrayList(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(1, 1)); points.add(new Vector2D(1, 1)); @@ -118,7 +118,7 @@ public void testConvexHull() { @Test public void testCollinearPoints() { - final Collection points = new ArrayList<>(); + final Collection points = new ArrayList(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(2, 2)); points.add(new Vector2D(2, 4)); @@ -131,7 +131,7 @@ public void testCollinearPoints() { @Test public void testCollinearPointsReverse() { - final Collection points = new ArrayList<>(); + final Collection points = new ArrayList(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(2, 2)); points.add(new Vector2D(2, 4)); @@ -144,7 +144,7 @@ public void testCollinearPointsReverse() { @Test public void testCollinearPointsIncluded() { - final Collection points = new ArrayList<>(); + final Collection points = new ArrayList(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(2, 2)); points.add(new Vector2D(2, 4)); @@ -157,7 +157,7 @@ public void testCollinearPointsIncluded() { @Test public void testCollinearPointsIncludedReverse() { - final Collection points = new ArrayList<>(); + final Collection points = new ArrayList(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(2, 2)); points.add(new Vector2D(2, 4)); @@ -170,7 +170,7 @@ public void testCollinearPointsIncludedReverse() { @Test public void testIdenticalPoints() { - final Collection points = new ArrayList<>(); + final Collection points = new ArrayList(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(2, 2)); points.add(new Vector2D(2, 4)); @@ -183,7 +183,7 @@ public void testIdenticalPoints() { @Test public void testIdenticalPoints2() { - final Collection points = new ArrayList<>(); + final Collection points = new ArrayList(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(2, 2)); points.add(new Vector2D(2, 4)); @@ -196,7 +196,7 @@ public void testIdenticalPoints2() { @Test public void testClosePoints() { - final Collection points = new ArrayList<>(); + final Collection points = new ArrayList(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(2, 2)); points.add(new Vector2D(2, 4)); @@ -211,7 +211,7 @@ public void testClosePoints() { public void testCollinearPointOnExistingBoundary() { // MATH-1135: check that collinear points on the hull are handled correctly // when only a minimal hull shall be constructed - final Collection points = new ArrayList<>(); + final Collection points = new ArrayList(); points.add(new Vector2D(7.3152, 34.7472)); points.add(new Vector2D(6.400799999999997, 34.747199999999985)); points.add(new Vector2D(5.486399999999997, 34.7472)); @@ -233,7 +233,7 @@ public void testCollinearPointsInAnyOrder() { // make sure that they are processed in the proper order // for each algorithm. - List points = new ArrayList<>(); + List points = new ArrayList(); // first case: 3 points are collinear points.add(new Vector2D(16.078200000000184, -36.52519999989808)); @@ -270,7 +270,7 @@ public void testCollinearPointsInAnyOrder() { @Test public void testIssue1123() { - List points = new ArrayList<>(); + List points = new ArrayList(); int[][] data = new int[][] { { -11, -1 }, { -11, 0 }, { -11, 1 }, { -10, -3 }, { -10, -2 }, { -10, -1 }, { -10, 0 }, { -10, 1 }, @@ -367,7 +367,7 @@ public void testIssue1123() { protected final List createRandomPoints(int size) { // create the cloud container - List points = new ArrayList<>(size); + List points = new ArrayList(size); // fill the cloud with a random distribution of points for (int i = 0; i < size; i++) { points.add(new Vector2D(random.nextDouble() * 2.0 - 1.0, random.nextDouble() * 2.0 - 1.0)); diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java index 7860b9db5a..ebc2f6cebe 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java @@ -40,7 +40,7 @@ protected ConvexHullGenerator2D createConvexHullGenerator(boolean includeColline @Test(expected=ConvergenceException.class) public void testConvergenceException() { - final Collection points = new ArrayList<>(); + final Collection points = new ArrayList(); points.add(new Vector2D(1, 1)); points.add(new Vector2D(1, 5)); diff --git a/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java b/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java index ced1989783..29e48f33ee 100644 --- a/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java +++ b/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java @@ -211,7 +211,7 @@ public TreeBuilder(final String type, final String s) getWord(TOLERANCE); tolerance = getNumber(); getWord(PLUS); - root = new BSPTree<>(); + root = new BSPTree(); parseTree(root); if (tokenizer.hasMoreTokens()) { throw new ParseException("unexpected " + tokenizer.nextToken(), 0); diff --git a/src/test/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSetTest.java index 6f868579a9..e57286b0d6 100644 --- a/src/test/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSetTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSetTest.java @@ -170,7 +170,7 @@ public void testTiny() { @Test public void testSpecialConstruction() { - List> boundary = new ArrayList<>(); + List> boundary = new ArrayList>(); boundary.add(new LimitAngle(new S1Point(0.0), false, 1.0e-10).wholeHyperplane()); boundary.add(new LimitAngle(new S1Point(MathUtils.TWO_PI - 1.0e-11), true, 1.0e-10).wholeHyperplane()); ArcsSet set = new ArcsSet(boundary, 1.0e-10); @@ -271,7 +271,7 @@ public void testIntersection() { @Test public void testMultiple() { - RegionFactory factory = new RegionFactory<>(); + RegionFactory factory = new RegionFactory(); ArcsSet set = (ArcsSet) factory.intersection(factory.union(factory.difference(new ArcsSet(1.0, 6.0, 1.0e-10), new ArcsSet(3.0, 5.0, 1.0e-10)), @@ -347,9 +347,9 @@ public void testShiftedAngles() { for (int k = -2; k < 3; ++k) { SubLimitAngle l1 = new LimitAngle(new S1Point(1.0 + k * MathUtils.TWO_PI), false, 1.0e-10).wholeHyperplane(); SubLimitAngle l2 = new LimitAngle(new S1Point(1.5 + k * MathUtils.TWO_PI), true, 1.0e-10).wholeHyperplane(); - ArcsSet set = new ArcsSet(new BSPTree<>(l1, + ArcsSet set = new ArcsSet(new BSPTree(l1, new BSPTree(Boolean.FALSE), - new BSPTree<>(l2, + new BSPTree(l2, new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null), @@ -371,10 +371,10 @@ public void testInconsistentState() { SubLimitAngle l1 = new LimitAngle(new S1Point(1.0), false, 1.0e-10).wholeHyperplane(); SubLimitAngle l2 = new LimitAngle(new S1Point(2.0), true, 1.0e-10).wholeHyperplane(); SubLimitAngle l3 = new LimitAngle(new S1Point(3.0), false, 1.0e-10).wholeHyperplane(); - new ArcsSet(new BSPTree<>(l1, + new ArcsSet(new BSPTree(l1, new BSPTree(Boolean.FALSE), - new BSPTree<>(l2, - new BSPTree<>(l3, + new BSPTree(l2, + new BSPTree(l3, new BSPTree(Boolean.FALSE), new BSPTree(Boolean.TRUE), null), diff --git a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSetTest.java index 4b0368e171..e9fbe475a0 100644 --- a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSetTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSetTest.java @@ -110,7 +110,7 @@ public void testSouthHemisphere() { public void testPositiveOctantByIntersection() { double tol = 0.01; double sinTol = FastMath.sin(tol); - RegionFactory factory = new RegionFactory<>(); + RegionFactory factory = new RegionFactory(); SphericalPolygonsSet plusX = new SphericalPolygonsSet(Vector3D.PLUS_I, tol); SphericalPolygonsSet plusY = new SphericalPolygonsSet(Vector3D.PLUS_J, tol); SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Vector3D.PLUS_K, tol); @@ -198,7 +198,7 @@ public void testPositiveOctantByVertices() { public void testNonConvex() { double tol = 0.01; double sinTol = FastMath.sin(tol); - RegionFactory factory = new RegionFactory<>(); + RegionFactory factory = new RegionFactory(); SphericalPolygonsSet plusX = new SphericalPolygonsSet(Vector3D.PLUS_I, tol); SphericalPolygonsSet plusY = new SphericalPolygonsSet(Vector3D.PLUS_J, tol); SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Vector3D.PLUS_K, tol); @@ -267,7 +267,7 @@ public void testNonConvex() { @Test public void testModeratlyComplexShape() { double tol = 0.01; - List> boundary = new ArrayList<>(); + List> boundary = new ArrayList>(); boundary.add(create(Vector3D.MINUS_J, Vector3D.PLUS_I, Vector3D.PLUS_K, tol, 0.0, 0.5 * FastMath.PI)); boundary.add(create(Vector3D.MINUS_I, Vector3D.PLUS_K, Vector3D.PLUS_J, tol, 0.0, 0.5 * FastMath.PI)); boundary.add(create(Vector3D.PLUS_K, Vector3D.PLUS_J, Vector3D.MINUS_I, tol, 0.0, 0.5 * FastMath.PI)); @@ -324,7 +324,7 @@ public void testModeratlyComplexShape() { public void testSeveralParts() { double tol = 0.01; double sinTol = FastMath.sin(tol); - List> boundary = new ArrayList<>(); + List> boundary = new ArrayList>(); // first part: +X, +Y, +Z octant boundary.add(create(Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_I, tol, 0.0, 0.5 * FastMath.PI)); @@ -406,7 +406,7 @@ public void testConcentricSubParts() { SphericalPolygonsSet triOut = new SphericalPolygonsSet(center, Vector3D.PLUS_K, 0.25, 3, tol); SphericalPolygonsSet triIn = new SphericalPolygonsSet(center, Vector3D.PLUS_K, 0.15, 3, tol); - RegionFactory factory = new RegionFactory<>(); + RegionFactory factory = new RegionFactory(); SphericalPolygonsSet hexa = (SphericalPolygonsSet) factory.difference(hexaOut, hexaIn); SphericalPolygonsSet penta = (SphericalPolygonsSet) factory.difference(pentaOut, pentaIn); SphericalPolygonsSet quadri = (SphericalPolygonsSet) factory.difference(quadriOut, quadriIn); @@ -467,7 +467,7 @@ public void testGeographicalMap() { { 42.15249, 9.56001 }, { 43.00998, 9.39000 }, { 42.62812, 8.74600 }, { 42.25651, 8.54421 }, { 41.58361, 8.77572 }, { 41.38000, 9.22975 } }); - RegionFactory factory = new RegionFactory<>(); + RegionFactory factory = new RegionFactory(); SphericalPolygonsSet zone = (SphericalPolygonsSet) factory.union(continental, corsica); EnclosingBall enclosing = zone.getEnclosingCap(); Vector3D enclosingCenter = ((S2Point) enclosing.getCenter()).getVector(); @@ -525,7 +525,7 @@ public void testGeographicalMap() { private SubCircle create(Vector3D pole, Vector3D x, Vector3D y, double tolerance, double ... limits) { - RegionFactory factory = new RegionFactory<>(); + RegionFactory factory = new RegionFactory(); Circle circle = new Circle(pole, tolerance); Circle phased = (Circle) Circle.getTransform(new Rotation(circle.getXAxis(), circle.getYAxis(), x, y)).apply(circle); diff --git a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SubCircleTest.java b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SubCircleTest.java index 34b6278f79..891f6207f6 100644 --- a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SubCircleTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SubCircleTest.java @@ -127,7 +127,7 @@ public void testSideSplitConsistency() { private SubCircle create(Vector3D pole, Vector3D x, Vector3D y, double tolerance, double ... limits) { - RegionFactory factory = new RegionFactory<>(); + RegionFactory factory = new RegionFactory(); Circle circle = new Circle(pole, tolerance); Circle phased = (Circle) Circle.getTransform(new Rotation(circle.getXAxis(), circle.getYAxis(), x, y)).apply(circle); diff --git a/src/test/java/org/apache/commons/math4/linear/ArrayFieldVectorTest.java b/src/test/java/org/apache/commons/math4/linear/ArrayFieldVectorTest.java index 1268b262c5..a9f7ac7911 100644 --- a/src/test/java/org/apache/commons/math4/linear/ArrayFieldVectorTest.java +++ b/src/test/java/org/apache/commons/math4/linear/ArrayFieldVectorTest.java @@ -139,7 +139,7 @@ public FieldVector mapMultiply(T d) { for (int i = 0; i < data.length; i++) { out[i] = data[i].multiply(d); } - return new FieldVectorTestImpl<>(out); + return new FieldVectorTestImpl(out); } public FieldVector mapMultiplyToSelf(T d) { @@ -263,70 +263,70 @@ public T[] toArray() { @Test public void testConstructors() { - ArrayFieldVector v0 = new ArrayFieldVector<>(FractionField.getInstance()); + ArrayFieldVector v0 = new ArrayFieldVector(FractionField.getInstance()); Assert.assertEquals(0, v0.getDimension()); - ArrayFieldVector v1 = new ArrayFieldVector<>(FractionField.getInstance(), 7); + ArrayFieldVector v1 = new ArrayFieldVector(FractionField.getInstance(), 7); Assert.assertEquals(7, v1.getDimension()); Assert.assertEquals(Fraction.ZERO, v1.getEntry(6)); - ArrayFieldVector v2 = new ArrayFieldVector<>(5, new Fraction(123, 100)); + ArrayFieldVector v2 = new ArrayFieldVector(5, new Fraction(123, 100)); Assert.assertEquals(5, v2.getDimension()); Assert.assertEquals(new Fraction(123, 100), v2.getEntry(4)); - ArrayFieldVector v3 = new ArrayFieldVector<>(FractionField.getInstance(), vec1); + ArrayFieldVector v3 = new ArrayFieldVector(FractionField.getInstance(), vec1); Assert.assertEquals(3, v3.getDimension()); Assert.assertEquals(new Fraction(2), v3.getEntry(1)); - ArrayFieldVector v4 = new ArrayFieldVector<>(FractionField.getInstance(), vec4, 3, 2); + ArrayFieldVector v4 = new ArrayFieldVector(FractionField.getInstance(), vec4, 3, 2); Assert.assertEquals(2, v4.getDimension()); Assert.assertEquals(new Fraction(4), v4.getEntry(0)); try { - new ArrayFieldVector<>(vec4, 8, 3); + new ArrayFieldVector(vec4, 8, 3); Assert.fail("MathIllegalArgumentException expected"); } catch (MathIllegalArgumentException ex) { // expected behavior } - FieldVector v5_i = new ArrayFieldVector<>(dvec1); + FieldVector v5_i = new ArrayFieldVector(dvec1); Assert.assertEquals(9, v5_i.getDimension()); Assert.assertEquals(new Fraction(9), v5_i.getEntry(8)); - ArrayFieldVector v5 = new ArrayFieldVector<>(dvec1); + ArrayFieldVector v5 = new ArrayFieldVector(dvec1); Assert.assertEquals(9, v5.getDimension()); Assert.assertEquals(new Fraction(9), v5.getEntry(8)); - ArrayFieldVector v6 = new ArrayFieldVector<>(dvec1, 3, 2); + ArrayFieldVector v6 = new ArrayFieldVector(dvec1, 3, 2); Assert.assertEquals(2, v6.getDimension()); Assert.assertEquals(new Fraction(4), v6.getEntry(0)); try { - new ArrayFieldVector<>(dvec1, 8, 3); + new ArrayFieldVector(dvec1, 8, 3); Assert.fail("MathIllegalArgumentException expected"); } catch (MathIllegalArgumentException ex) { // expected behavior } - ArrayFieldVector v7 = new ArrayFieldVector<>(v1); + ArrayFieldVector v7 = new ArrayFieldVector(v1); Assert.assertEquals(7, v7.getDimension()); Assert.assertEquals(Fraction.ZERO, v7.getEntry(6)); - FieldVectorTestImpl v7_i = new FieldVectorTestImpl<>(vec1); + FieldVectorTestImpl v7_i = new FieldVectorTestImpl(vec1); - ArrayFieldVector v7_2 = new ArrayFieldVector<>(v7_i); + ArrayFieldVector v7_2 = new ArrayFieldVector(v7_i); Assert.assertEquals(3, v7_2.getDimension()); Assert.assertEquals(new Fraction(2), v7_2.getEntry(1)); - ArrayFieldVector v8 = new ArrayFieldVector<>(v1, true); + ArrayFieldVector v8 = new ArrayFieldVector(v1, true); Assert.assertEquals(7, v8.getDimension()); Assert.assertEquals(Fraction.ZERO, v8.getEntry(6)); Assert.assertNotSame("testData not same object ", v1.getDataRef(), v8.getDataRef()); - ArrayFieldVector v8_2 = new ArrayFieldVector<>(v1, false); + ArrayFieldVector v8_2 = new ArrayFieldVector(v1, false); Assert.assertEquals(7, v8_2.getDimension()); Assert.assertEquals(Fraction.ZERO, v8_2.getEntry(6)); Assert.assertArrayEquals(v1.getDataRef(), v8_2.getDataRef()); - ArrayFieldVector v9 = new ArrayFieldVector<>((FieldVector) v1, (FieldVector) v3); + ArrayFieldVector v9 = new ArrayFieldVector((FieldVector) v1, (FieldVector) v3); Assert.assertEquals(10, v9.getDimension()); Assert.assertEquals(new Fraction(1), v9.getEntry(7)); @@ -335,10 +335,10 @@ public void testConstructors() { @Test public void testDataInOut() { - ArrayFieldVector v1 = new ArrayFieldVector<>(vec1); - ArrayFieldVector v2 = new ArrayFieldVector<>(vec2); - ArrayFieldVector v4 = new ArrayFieldVector<>(vec4); - FieldVectorTestImpl v2_t = new FieldVectorTestImpl<>(vec2); + ArrayFieldVector v1 = new ArrayFieldVector(vec1); + ArrayFieldVector v2 = new ArrayFieldVector(vec2); + ArrayFieldVector v4 = new ArrayFieldVector(vec4); + FieldVectorTestImpl v2_t = new FieldVectorTestImpl(vec2); FieldVector v_append_1 = v1.append(v2); Assert.assertEquals(6, v_append_1.getDimension()); @@ -430,7 +430,7 @@ public void testDataInOut() { @Test public void testMapFunctions() { - ArrayFieldVector v1 = new ArrayFieldVector<>(vec1); + ArrayFieldVector v1 = new ArrayFieldVector(vec1); //octave = v1 .+ 2.0 FieldVector v_mapAdd = v1.mapAdd(new Fraction(2)); @@ -491,18 +491,18 @@ public void testMapFunctions() { @Test public void testBasicFunctions() { - ArrayFieldVector v1 = new ArrayFieldVector<>(vec1); - ArrayFieldVector v2 = new ArrayFieldVector<>(vec2); - new ArrayFieldVector<>(vec_null); + ArrayFieldVector v1 = new ArrayFieldVector(vec1); + ArrayFieldVector v2 = new ArrayFieldVector(vec2); + new ArrayFieldVector(vec_null); - FieldVectorTestImpl v2_t = new FieldVectorTestImpl<>(vec2); + FieldVectorTestImpl v2_t = new FieldVectorTestImpl(vec2); //octave = v1 + v2 ArrayFieldVector v_add = v1.add(v2); Fraction[] result_add = {new Fraction(5), new Fraction(7), new Fraction(9)}; checkArray("compare vect" ,v_add.toArray(),result_add); - FieldVectorTestImpl vt2 = new FieldVectorTestImpl<>(vec2); + FieldVectorTestImpl vt2 = new FieldVectorTestImpl(vec2); FieldVector v_add_i = v1.add(vt2); Fraction[] result_add_i = {new Fraction(5), new Fraction(7), new Fraction(9)}; checkArray("compare vect" ,v_add_i.toArray(),result_add_i); @@ -560,9 +560,9 @@ public void testBasicFunctions() { @Test public void testMisc() { - ArrayFieldVector v1 = new ArrayFieldVector<>(vec1); - ArrayFieldVector v4 = new ArrayFieldVector<>(vec4); - FieldVector v4_2 = new ArrayFieldVector<>(vec4); + ArrayFieldVector v1 = new ArrayFieldVector(vec1); + ArrayFieldVector v4 = new ArrayFieldVector(vec4); + FieldVector v4_2 = new ArrayFieldVector(vec4); String out1 = v1.toString(); Assert.assertTrue("some output ", out1.length()!=0); @@ -596,7 +596,7 @@ public void testMisc() { @Test public void testSerial() { - ArrayFieldVector v = new ArrayFieldVector<>(vec1); + ArrayFieldVector v = new ArrayFieldVector(vec1); Assert.assertEquals(v,TestUtils.serializeAndRecover(v)); } @@ -605,40 +605,40 @@ public void testZeroVectors() { // when the field is not specified, array cannot be empty try { - new ArrayFieldVector<>(new Fraction[0]); + new ArrayFieldVector(new Fraction[0]); Assert.fail("MathIllegalArgumentException expected"); } catch (MathIllegalArgumentException ex) { // expected behavior } try { - new ArrayFieldVector<>(new Fraction[0], true); + new ArrayFieldVector(new Fraction[0], true); Assert.fail("MathIllegalArgumentException expected"); } catch (MathIllegalArgumentException ex) { // expected behavior } try { - new ArrayFieldVector<>(new Fraction[0], false); + new ArrayFieldVector(new Fraction[0], false); Assert.fail("MathIllegalArgumentException expected"); } catch (MathIllegalArgumentException ex) { // expected behavior } // when the field is specified, array can be empty - Assert.assertEquals(0, new ArrayFieldVector<>(FractionField.getInstance(), new Fraction[0]).getDimension()); - Assert.assertEquals(0, new ArrayFieldVector<>(FractionField.getInstance(), new Fraction[0], true).getDimension()); - Assert.assertEquals(0, new ArrayFieldVector<>(FractionField.getInstance(), new Fraction[0], false).getDimension()); + Assert.assertEquals(0, new ArrayFieldVector(FractionField.getInstance(), new Fraction[0]).getDimension()); + Assert.assertEquals(0, new ArrayFieldVector(FractionField.getInstance(), new Fraction[0], true).getDimension()); + Assert.assertEquals(0, new ArrayFieldVector(FractionField.getInstance(), new Fraction[0], false).getDimension()); } @Test public void testOuterProduct() { final ArrayFieldVector u - = new ArrayFieldVector<>(FractionField.getInstance(), + = new ArrayFieldVector(FractionField.getInstance(), new Fraction[] {new Fraction(1), new Fraction(2), new Fraction(-3)}); final ArrayFieldVector v - = new ArrayFieldVector<>(FractionField.getInstance(), + = new ArrayFieldVector(FractionField.getInstance(), new Fraction[] {new Fraction(4), new Fraction(-2)}); @@ -675,7 +675,7 @@ public void testWalkInDefaultOrderPreservingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector<>(data); + final ArrayFieldVector v = new ArrayFieldVector(data); final FieldVectorPreservingVisitor visitor; visitor = new FieldVectorPreservingVisitor() { @@ -762,7 +762,7 @@ public void testWalkInDefaultOrderPreservingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector<>(data); + final ArrayFieldVector v = new ArrayFieldVector(data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorPreservingVisitor visitor; @@ -800,7 +800,7 @@ public void testWalkInOptimizedOrderPreservingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector<>(data); + final ArrayFieldVector v = new ArrayFieldVector(data); final FieldVectorPreservingVisitor visitor; visitor = new FieldVectorPreservingVisitor() { private final boolean[] visited = new boolean[data.length]; @@ -889,7 +889,7 @@ public void testWalkInOptimizedOrderPreservingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector<>(data); + final ArrayFieldVector v = new ArrayFieldVector(data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorPreservingVisitor visitor; @@ -929,7 +929,7 @@ public void testWalkInDefaultOrderChangingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector<>(data); + final ArrayFieldVector v = new ArrayFieldVector(data); final FieldVectorChangingVisitor visitor; visitor = new FieldVectorChangingVisitor() { @@ -1020,7 +1020,7 @@ public void testWalkInDefaultOrderChangingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector<>(data); + final ArrayFieldVector v = new ArrayFieldVector(data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorChangingVisitor visitor; @@ -1062,7 +1062,7 @@ public void testWalkInOptimizedOrderChangingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector<>(data); + final ArrayFieldVector v = new ArrayFieldVector(data); final FieldVectorChangingVisitor visitor; visitor = new FieldVectorChangingVisitor() { private final boolean[] visited = new boolean[data.length]; @@ -1155,7 +1155,7 @@ public void testWalkInOptimizedOrderChangingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final ArrayFieldVector v = new ArrayFieldVector<>(data); + final ArrayFieldVector v = new ArrayFieldVector(data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorChangingVisitor visitor; @@ -1196,6 +1196,6 @@ private ArrayFieldVector create(int n) { for (int i = 0; i < n; ++i) { t[i] = Fraction.ZERO; } - return new ArrayFieldVector<>(t); + return new ArrayFieldVector(t); } } diff --git a/src/test/java/org/apache/commons/math4/linear/BlockFieldMatrixTest.java b/src/test/java/org/apache/commons/math4/linear/BlockFieldMatrixTest.java index 57c9cb7de7..00dde9df66 100644 --- a/src/test/java/org/apache/commons/math4/linear/BlockFieldMatrixTest.java +++ b/src/test/java/org/apache/commons/math4/linear/BlockFieldMatrixTest.java @@ -167,8 +167,8 @@ public final class BlockFieldMatrixTest { /** test dimensions */ @Test public void testDimensions() { - BlockFieldMatrix m = new BlockFieldMatrix<>(testData); - BlockFieldMatrix m2 = new BlockFieldMatrix<>(testData2); + BlockFieldMatrix m = new BlockFieldMatrix(testData); + BlockFieldMatrix m2 = new BlockFieldMatrix(testData2); Assert.assertEquals("testData row dimension",3,m.getRowDimension()); Assert.assertEquals("testData column dimension",3,m.getColumnDimension()); Assert.assertTrue("testData is square",m.isSquare()); @@ -182,18 +182,18 @@ public void testDimensions() { public void testCopyFunctions() { Random r = new Random(66636328996002l); BlockFieldMatrix m1 = createRandomMatrix(r, 47, 83); - BlockFieldMatrix m2 = new BlockFieldMatrix<>(m1.getData()); + BlockFieldMatrix m2 = new BlockFieldMatrix(m1.getData()); Assert.assertEquals(m1, m2); - BlockFieldMatrix m3 = new BlockFieldMatrix<>(testData); - BlockFieldMatrix m4 = new BlockFieldMatrix<>(m3.getData()); + BlockFieldMatrix m3 = new BlockFieldMatrix(testData); + BlockFieldMatrix m4 = new BlockFieldMatrix(m3.getData()); Assert.assertEquals(m3, m4); } /** test add */ @Test public void testAdd() { - BlockFieldMatrix m = new BlockFieldMatrix<>(testData); - BlockFieldMatrix mInv = new BlockFieldMatrix<>(testDataInv); + BlockFieldMatrix m = new BlockFieldMatrix(testData); + BlockFieldMatrix mInv = new BlockFieldMatrix(testDataInv); FieldMatrix mPlusMInv = m.add(mInv); Fraction[][] sumEntries = mPlusMInv.getData(); for (int row = 0; row < m.getRowDimension(); row++) { @@ -206,8 +206,8 @@ public void testAdd() { /** test add failure */ @Test public void testAddFail() { - BlockFieldMatrix m = new BlockFieldMatrix<>(testData); - BlockFieldMatrix m2 = new BlockFieldMatrix<>(testData2); + BlockFieldMatrix m = new BlockFieldMatrix(testData); + BlockFieldMatrix m2 = new BlockFieldMatrix(testData2); try { m.add(m2); Assert.fail("MathIllegalArgumentException expected"); @@ -219,11 +219,11 @@ public void testAddFail() { /** test m-n = m + -n */ @Test public void testPlusMinus() { - BlockFieldMatrix m = new BlockFieldMatrix<>(testData); - BlockFieldMatrix m2 = new BlockFieldMatrix<>(testDataInv); + BlockFieldMatrix m = new BlockFieldMatrix(testData); + BlockFieldMatrix m2 = new BlockFieldMatrix(testDataInv); TestUtils.assertEquals(m.subtract(m2), m2.scalarMultiply(new Fraction(-1)).add(m)); try { - m.subtract(new BlockFieldMatrix<>(testData2)); + m.subtract(new BlockFieldMatrix(testData2)); Assert.fail("Expecting illegalArgumentException"); } catch (MathIllegalArgumentException ex) { // ignored @@ -233,17 +233,17 @@ public void testPlusMinus() { /** test multiply */ @Test public void testMultiply() { - BlockFieldMatrix m = new BlockFieldMatrix<>(testData); - BlockFieldMatrix mInv = new BlockFieldMatrix<>(testDataInv); - BlockFieldMatrix identity = new BlockFieldMatrix<>(id); - BlockFieldMatrix m2 = new BlockFieldMatrix<>(testData2); + BlockFieldMatrix m = new BlockFieldMatrix(testData); + BlockFieldMatrix mInv = new BlockFieldMatrix(testDataInv); + BlockFieldMatrix identity = new BlockFieldMatrix(id); + BlockFieldMatrix m2 = new BlockFieldMatrix(testData2); TestUtils.assertEquals(m.multiply(mInv), identity); TestUtils.assertEquals(mInv.multiply(m), identity); TestUtils.assertEquals(m.multiply(identity), m); TestUtils.assertEquals(identity.multiply(mInv), mInv); TestUtils.assertEquals(m2.multiply(identity), m2); try { - m.multiply(new BlockFieldMatrix<>(bigSingular)); + m.multiply(new BlockFieldMatrix(bigSingular)); Assert.fail("Expecting illegalArgumentException"); } catch (MathIllegalArgumentException ex) { // expected @@ -253,7 +253,7 @@ public void testMultiply() { @Test public void testSeveralBlocks() { FieldMatrix m = - new BlockFieldMatrix<>(FractionField.getInstance(), 37, 41); + new BlockFieldMatrix(FractionField.getInstance(), 37, 41); for (int i = 0; i < m.getRowDimension(); ++i) { for (int j = 0; j < m.getColumnDimension(); ++j) { m.setEntry(i, j, new Fraction(i * 11 + j, 11)); @@ -351,18 +351,18 @@ public void testSeveralBlocks() { @Test public void testMultiply2() { - FieldMatrix m3 = new BlockFieldMatrix<>(d3); - FieldMatrix m4 = new BlockFieldMatrix<>(d4); - FieldMatrix m5 = new BlockFieldMatrix<>(d5); + FieldMatrix m3 = new BlockFieldMatrix(d3); + FieldMatrix m4 = new BlockFieldMatrix(d4); + FieldMatrix m5 = new BlockFieldMatrix(d5); TestUtils.assertEquals(m3.multiply(m4), m5); } /** test trace */ @Test public void testTrace() { - FieldMatrix m = new BlockFieldMatrix<>(id); + FieldMatrix m = new BlockFieldMatrix(id); Assert.assertEquals(new Fraction(3),m.getTrace()); - m = new BlockFieldMatrix<>(testData2); + m = new BlockFieldMatrix(testData2); try { m.getTrace(); Assert.fail("Expecting NonSquareMatrixException"); @@ -374,18 +374,18 @@ public void testTrace() { /** test scalarAdd */ @Test public void testScalarAdd() { - FieldMatrix m = new BlockFieldMatrix<>(testData); - TestUtils.assertEquals(new BlockFieldMatrix<>(testDataPlus2), + FieldMatrix m = new BlockFieldMatrix(testData); + TestUtils.assertEquals(new BlockFieldMatrix(testDataPlus2), m.scalarAdd(new Fraction(2))); } /** test operate */ @Test public void testOperate() { - FieldMatrix m = new BlockFieldMatrix<>(id); + FieldMatrix m = new BlockFieldMatrix(id); TestUtils.assertEquals(testVector, m.operate(testVector)); - TestUtils.assertEquals(testVector, m.operate(new ArrayFieldVector<>(testVector)).toArray()); - m = new BlockFieldMatrix<>(bigSingular); + TestUtils.assertEquals(testVector, m.operate(new ArrayFieldVector(testVector)).toArray()); + m = new BlockFieldMatrix(bigSingular); try { m.operate(testVector); Assert.fail("Expecting illegalArgumentException"); @@ -425,7 +425,7 @@ public void testOperatePremultiplyLarge() { /** test issue MATH-209 */ @Test public void testMath209() { - FieldMatrix a = new BlockFieldMatrix<>(new Fraction[][] { + FieldMatrix a = new BlockFieldMatrix(new Fraction[][] { { new Fraction(1), new Fraction(2) }, { new Fraction(3), new Fraction(4) }, { new Fraction(5), new Fraction(6) } @@ -440,23 +440,23 @@ public void testMath209() { /** test transpose */ @Test public void testTranspose() { - FieldMatrix m = new BlockFieldMatrix<>(testData); - FieldMatrix mIT = new FieldLUDecomposition<>(m).getSolver().getInverse().transpose(); - FieldMatrix mTI = new FieldLUDecomposition<>(m.transpose()).getSolver().getInverse(); + FieldMatrix m = new BlockFieldMatrix(testData); + FieldMatrix mIT = new FieldLUDecomposition(m).getSolver().getInverse().transpose(); + FieldMatrix mTI = new FieldLUDecomposition(m.transpose()).getSolver().getInverse(); TestUtils.assertEquals(mIT, mTI); - m = new BlockFieldMatrix<>(testData2); - FieldMatrix mt = new BlockFieldMatrix<>(testData2T); + m = new BlockFieldMatrix(testData2); + FieldMatrix mt = new BlockFieldMatrix(testData2T); TestUtils.assertEquals(mt, m.transpose()); } /** test preMultiply by vector */ @Test public void testPremultiplyVector() { - FieldMatrix m = new BlockFieldMatrix<>(testData); + FieldMatrix m = new BlockFieldMatrix(testData); TestUtils.assertEquals(m.preMultiply(testVector), preMultTest); - TestUtils.assertEquals(m.preMultiply(new ArrayFieldVector<>(testVector).toArray()), + TestUtils.assertEquals(m.preMultiply(new ArrayFieldVector(testVector).toArray()), preMultTest); - m = new BlockFieldMatrix<>(bigSingular); + m = new BlockFieldMatrix(bigSingular); try { m.preMultiply(testVector); Assert.fail("expecting MathIllegalArgumentException"); @@ -467,20 +467,20 @@ public void testPremultiplyVector() { @Test public void testPremultiply() { - FieldMatrix m3 = new BlockFieldMatrix<>(d3); - FieldMatrix m4 = new BlockFieldMatrix<>(d4); - FieldMatrix m5 = new BlockFieldMatrix<>(d5); + FieldMatrix m3 = new BlockFieldMatrix(d3); + FieldMatrix m4 = new BlockFieldMatrix(d4); + FieldMatrix m5 = new BlockFieldMatrix(d5); TestUtils.assertEquals(m4.preMultiply(m3), m5); - BlockFieldMatrix m = new BlockFieldMatrix<>(testData); - BlockFieldMatrix mInv = new BlockFieldMatrix<>(testDataInv); - BlockFieldMatrix identity = new BlockFieldMatrix<>(id); + BlockFieldMatrix m = new BlockFieldMatrix(testData); + BlockFieldMatrix mInv = new BlockFieldMatrix(testDataInv); + BlockFieldMatrix identity = new BlockFieldMatrix(id); TestUtils.assertEquals(m.preMultiply(mInv), identity); TestUtils.assertEquals(mInv.preMultiply(m), identity); TestUtils.assertEquals(m.preMultiply(identity), m); TestUtils.assertEquals(identity.preMultiply(mInv), mInv); try { - m.preMultiply(new BlockFieldMatrix<>(bigSingular)); + m.preMultiply(new BlockFieldMatrix(bigSingular)); Assert.fail("Expecting illegalArgumentException"); } catch (MathIllegalArgumentException ex) { // ignored @@ -489,7 +489,7 @@ public void testPremultiply() { @Test public void testGetVectors() { - FieldMatrix m = new BlockFieldMatrix<>(testData); + FieldMatrix m = new BlockFieldMatrix(testData); TestUtils.assertEquals(m.getRow(0), testDataRow1); TestUtils.assertEquals(m.getColumn(2), testDataCol3); try { @@ -508,7 +508,7 @@ public void testGetVectors() { @Test public void testGetEntry() { - FieldMatrix m = new BlockFieldMatrix<>(testData); + FieldMatrix m = new BlockFieldMatrix(testData); Assert.assertEquals(m.getEntry(0,1),new Fraction(2)); try { m.getEntry(10, 4); @@ -526,20 +526,20 @@ public void testExamples() { {new Fraction(1),new Fraction(2),new Fraction(3)}, {new Fraction(2),new Fraction(5),new Fraction(3)} }; - FieldMatrix m = new BlockFieldMatrix<>(matrixData); + FieldMatrix m = new BlockFieldMatrix(matrixData); // One more with three rows, two columns Fraction[][] matrixData2 = { {new Fraction(1),new Fraction(2)}, {new Fraction(2),new Fraction(5)}, {new Fraction(1), new Fraction(7)} }; - FieldMatrix n = new BlockFieldMatrix<>(matrixData2); + FieldMatrix n = new BlockFieldMatrix(matrixData2); // Now multiply m by n FieldMatrix p = m.multiply(n); Assert.assertEquals(2, p.getRowDimension()); Assert.assertEquals(2, p.getColumnDimension()); // Invert p - FieldMatrix pInverse = new FieldLUDecomposition<>(p).getSolver().getInverse(); + FieldMatrix pInverse = new FieldLUDecomposition(p).getSolver().getInverse(); Assert.assertEquals(2, pInverse.getRowDimension()); Assert.assertEquals(2, pInverse.getColumnDimension()); @@ -549,14 +549,14 @@ public void testExamples() { {new Fraction(-1), new Fraction(7), new Fraction(6)}, {new Fraction(4), new Fraction(-3), new Fraction(-5)} }; - FieldMatrix coefficients = new BlockFieldMatrix<>(coefficientsData); + FieldMatrix coefficients = new BlockFieldMatrix(coefficientsData); Fraction[] constants = { new Fraction(1), new Fraction(-2), new Fraction(1) }; Fraction[] solution; - solution = new FieldLUDecomposition<>(coefficients) + solution = new FieldLUDecomposition(coefficients) .getSolver() - .solve(new ArrayFieldVector<>(constants, false)).toArray(); + .solve(new ArrayFieldVector(constants, false)).toArray(); Assert.assertEquals(new Fraction(2).multiply(solution[0]). add(new Fraction(3).multiply(solution[1])). subtract(new Fraction(2).multiply(solution[2])), @@ -575,7 +575,7 @@ public void testExamples() { // test submatrix accessors @Test public void testGetSubMatrix() { - FieldMatrix m = new BlockFieldMatrix<>(subTestData); + FieldMatrix m = new BlockFieldMatrix(subTestData); checkGetSubMatrix(m, subRows23Cols00, 2 , 3 , 0, 0); checkGetSubMatrix(m, subRows00Cols33, 0 , 0 , 3, 3); checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3); @@ -598,7 +598,7 @@ private void checkGetSubMatrix(FieldMatrix m, Fraction[][] reference, try { FieldMatrix sub = m.getSubMatrix(startRow, endRow, startColumn, endColumn); if (reference != null) { - Assert.assertEquals(new BlockFieldMatrix<>(reference), sub); + Assert.assertEquals(new BlockFieldMatrix(reference), sub); } else { Assert.fail("Expecting OutOfRangeException or NotStrictlyPositiveException" + " or NumberIsTooSmallException or NoDataException"); @@ -627,7 +627,7 @@ private void checkGetSubMatrix(FieldMatrix m, Fraction[][] reference, try { FieldMatrix sub = m.getSubMatrix(selectedRows, selectedColumns); if (reference != null) { - Assert.assertEquals(new BlockFieldMatrix<>(reference), sub); + Assert.assertEquals(new BlockFieldMatrix(reference), sub); } else { Assert.fail("Expecting OutOfRangeException"); } @@ -654,9 +654,9 @@ private void checkGetSubMatrix(FieldMatrix m, Fraction[][] reference, public void testGetSetMatrixLarge() { int n = 3 * BlockFieldMatrix.BLOCK_SIZE; FieldMatrix m = - new BlockFieldMatrix<>(FractionField.getInstance(), n, n); + new BlockFieldMatrix(FractionField.getInstance(), n, n); FieldMatrix sub = - new BlockFieldMatrix<>(FractionField.getInstance(), n - 4, n - 4).scalarAdd(new Fraction(1)); + new BlockFieldMatrix(FractionField.getInstance(), n - 4, n - 4).scalarAdd(new Fraction(1)); m.setSubMatrix(sub.getData(), 2, 2); for (int i = 0; i < n; ++i) { @@ -673,7 +673,7 @@ public void testGetSetMatrixLarge() { @Test public void testCopySubMatrix() { - FieldMatrix m = new BlockFieldMatrix<>(subTestData); + FieldMatrix m = new BlockFieldMatrix(subTestData); checkCopy(m, subRows23Cols00, 2 , 3 , 0, 0); checkCopy(m, subRows00Cols33, 0 , 0 , 3, 3); checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3); @@ -700,7 +700,7 @@ private void checkCopy(FieldMatrix m, Fraction[][] reference, new Fraction[reference.length][reference[0].length]; m.copySubMatrix(startRow, endRow, startColumn, endColumn, sub); if (reference != null) { - Assert.assertEquals(new BlockFieldMatrix<>(reference), new BlockFieldMatrix<>(sub)); + Assert.assertEquals(new BlockFieldMatrix(reference), new BlockFieldMatrix(sub)); } else { Assert.fail("Expecting OutOfRangeException or NumberIsTooSmallException or NoDataException"); } @@ -727,7 +727,7 @@ private void checkCopy(FieldMatrix m, Fraction[][] reference, new Fraction[reference.length][reference[0].length]; m.copySubMatrix(selectedRows, selectedColumns, sub); if (reference != null) { - Assert.assertEquals(new BlockFieldMatrix<>(reference), new BlockFieldMatrix<>(sub)); + Assert.assertEquals(new BlockFieldMatrix(reference), new BlockFieldMatrix(sub)); } else { Assert.fail("Expecting OutOfRangeException or NumberIsTooSmallException or NoDataException"); } @@ -748,9 +748,9 @@ private void checkCopy(FieldMatrix m, Fraction[][] reference, @Test public void testGetRowMatrix() { - FieldMatrix m = new BlockFieldMatrix<>(subTestData); - FieldMatrix mRow0 = new BlockFieldMatrix<>(subRow0); - FieldMatrix mRow3 = new BlockFieldMatrix<>(subRow3); + FieldMatrix m = new BlockFieldMatrix(subTestData); + FieldMatrix mRow0 = new BlockFieldMatrix(subRow0); + FieldMatrix mRow3 = new BlockFieldMatrix(subRow3); Assert.assertEquals("Row0", mRow0, m.getRowMatrix(0)); Assert.assertEquals("Row3", mRow3, m.getRowMatrix(3)); try { @@ -769,8 +769,8 @@ public void testGetRowMatrix() { @Test public void testSetRowMatrix() { - FieldMatrix m = new BlockFieldMatrix<>(subTestData); - FieldMatrix mRow3 = new BlockFieldMatrix<>(subRow3); + FieldMatrix m = new BlockFieldMatrix(subTestData); + FieldMatrix mRow3 = new BlockFieldMatrix(subRow3); Assert.assertNotSame(mRow3, m.getRowMatrix(0)); m.setRowMatrix(0, mRow3); Assert.assertEquals(mRow3, m.getRowMatrix(0)); @@ -792,9 +792,9 @@ public void testSetRowMatrix() { public void testGetSetRowMatrixLarge() { int n = 3 * BlockFieldMatrix.BLOCK_SIZE; FieldMatrix m = - new BlockFieldMatrix<>(FractionField.getInstance(), n, n); + new BlockFieldMatrix(FractionField.getInstance(), n, n); FieldMatrix sub = - new BlockFieldMatrix<>(FractionField.getInstance(), 1, n).scalarAdd(new Fraction(1)); + new BlockFieldMatrix(FractionField.getInstance(), 1, n).scalarAdd(new Fraction(1)); m.setRowMatrix(2, sub); for (int i = 0; i < n; ++i) { @@ -812,9 +812,9 @@ public void testGetSetRowMatrixLarge() { @Test public void testGetColumnMatrix() { - FieldMatrix m = new BlockFieldMatrix<>(subTestData); - FieldMatrix mColumn1 = new BlockFieldMatrix<>(subColumn1); - FieldMatrix mColumn3 = new BlockFieldMatrix<>(subColumn3); + FieldMatrix m = new BlockFieldMatrix(subTestData); + FieldMatrix mColumn1 = new BlockFieldMatrix(subColumn1); + FieldMatrix mColumn3 = new BlockFieldMatrix(subColumn3); Assert.assertEquals(mColumn1, m.getColumnMatrix(1)); Assert.assertEquals(mColumn3, m.getColumnMatrix(3)); try { @@ -833,8 +833,8 @@ public void testGetColumnMatrix() { @Test public void testSetColumnMatrix() { - FieldMatrix m = new BlockFieldMatrix<>(subTestData); - FieldMatrix mColumn3 = new BlockFieldMatrix<>(subColumn3); + FieldMatrix m = new BlockFieldMatrix(subTestData); + FieldMatrix mColumn3 = new BlockFieldMatrix(subColumn3); Assert.assertNotSame(mColumn3, m.getColumnMatrix(1)); m.setColumnMatrix(1, mColumn3); Assert.assertEquals(mColumn3, m.getColumnMatrix(1)); @@ -856,9 +856,9 @@ public void testSetColumnMatrix() { public void testGetSetColumnMatrixLarge() { int n = 3 * BlockFieldMatrix.BLOCK_SIZE; FieldMatrix m = - new BlockFieldMatrix<>(FractionField.getInstance(), n, n); + new BlockFieldMatrix(FractionField.getInstance(), n, n); FieldMatrix sub = - new BlockFieldMatrix<>(FractionField.getInstance(), n, 1).scalarAdd(new Fraction(1)); + new BlockFieldMatrix(FractionField.getInstance(), n, 1).scalarAdd(new Fraction(1)); m.setColumnMatrix(2, sub); for (int i = 0; i < n; ++i) { @@ -876,9 +876,9 @@ public void testGetSetColumnMatrixLarge() { @Test public void testGetRowVector() { - FieldMatrix m = new BlockFieldMatrix<>(subTestData); - FieldVector mRow0 = new ArrayFieldVector<>(subRow0[0]); - FieldVector mRow3 = new ArrayFieldVector<>(subRow3[0]); + FieldMatrix m = new BlockFieldMatrix(subTestData); + FieldVector mRow0 = new ArrayFieldVector(subRow0[0]); + FieldVector mRow3 = new ArrayFieldVector(subRow3[0]); Assert.assertEquals(mRow0, m.getRowVector(0)); Assert.assertEquals(mRow3, m.getRowVector(3)); try { @@ -897,8 +897,8 @@ public void testGetRowVector() { @Test public void testSetRowVector() { - FieldMatrix m = new BlockFieldMatrix<>(subTestData); - FieldVector mRow3 = new ArrayFieldVector<>(subRow3[0]); + FieldMatrix m = new BlockFieldMatrix(subTestData); + FieldVector mRow3 = new ArrayFieldVector(subRow3[0]); Assert.assertNotSame(mRow3, m.getRowMatrix(0)); m.setRowVector(0, mRow3); Assert.assertEquals(mRow3, m.getRowVector(0)); @@ -909,7 +909,7 @@ public void testSetRowVector() { // expected } try { - m.setRowVector(0, new ArrayFieldVector<>(FractionField.getInstance(), 5)); + m.setRowVector(0, new ArrayFieldVector(FractionField.getInstance(), 5)); Assert.fail("Expecting MatrixDimensionMismatchException"); } catch (MatrixDimensionMismatchException ex) { // expected @@ -919,8 +919,8 @@ public void testSetRowVector() { @Test public void testGetSetRowVectorLarge() { int n = 3 * BlockFieldMatrix.BLOCK_SIZE; - FieldMatrix m = new BlockFieldMatrix<>(FractionField.getInstance(), n, n); - FieldVector sub = new ArrayFieldVector<>(n, new Fraction(1)); + FieldMatrix m = new BlockFieldMatrix(FractionField.getInstance(), n, n); + FieldVector sub = new ArrayFieldVector(n, new Fraction(1)); m.setRowVector(2, sub); for (int i = 0; i < n; ++i) { @@ -938,7 +938,7 @@ public void testGetSetRowVectorLarge() { @Test public void testGetColumnVector() { - FieldMatrix m = new BlockFieldMatrix<>(subTestData); + FieldMatrix m = new BlockFieldMatrix(subTestData); FieldVector mColumn1 = columnToVector(subColumn1); FieldVector mColumn3 = columnToVector(subColumn3); Assert.assertEquals(mColumn1, m.getColumnVector(1)); @@ -959,7 +959,7 @@ public void testGetColumnVector() { @Test public void testSetColumnVector() { - FieldMatrix m = new BlockFieldMatrix<>(subTestData); + FieldMatrix m = new BlockFieldMatrix(subTestData); FieldVector mColumn3 = columnToVector(subColumn3); Assert.assertNotSame(mColumn3, m.getColumnVector(1)); m.setColumnVector(1, mColumn3); @@ -971,7 +971,7 @@ public void testSetColumnVector() { // expected } try { - m.setColumnVector(0, new ArrayFieldVector<>(FractionField.getInstance(), 5)); + m.setColumnVector(0, new ArrayFieldVector(FractionField.getInstance(), 5)); Assert.fail("Expecting MatrixDimensionMismatchException"); } catch (MatrixDimensionMismatchException ex) { // expected @@ -981,8 +981,8 @@ public void testSetColumnVector() { @Test public void testGetSetColumnVectorLarge() { int n = 3 * BlockFieldMatrix.BLOCK_SIZE; - FieldMatrix m = new BlockFieldMatrix<>(FractionField.getInstance(), n, n); - FieldVector sub = new ArrayFieldVector<>(n, new Fraction(1)); + FieldMatrix m = new BlockFieldMatrix(FractionField.getInstance(), n, n); + FieldVector sub = new ArrayFieldVector(n, new Fraction(1)); m.setColumnVector(2, sub); for (int i = 0; i < n; ++i) { @@ -1003,12 +1003,12 @@ private FieldVector columnToVector(Fraction[][] column) { for (int i = 0; i < data.length; ++i) { data[i] = column[i][0]; } - return new ArrayFieldVector<>(data, false); + return new ArrayFieldVector(data, false); } @Test public void testGetRow() { - FieldMatrix m = new BlockFieldMatrix<>(subTestData); + FieldMatrix m = new BlockFieldMatrix(subTestData); checkArrays(subRow0[0], m.getRow(0)); checkArrays(subRow3[0], m.getRow(3)); try { @@ -1027,7 +1027,7 @@ public void testGetRow() { @Test public void testSetRow() { - FieldMatrix m = new BlockFieldMatrix<>(subTestData); + FieldMatrix m = new BlockFieldMatrix(subTestData); Assert.assertTrue(subRow3[0][0] != m.getRow(0)[0]); m.setRow(0, subRow3[0]); checkArrays(subRow3[0], m.getRow(0)); @@ -1048,7 +1048,7 @@ public void testSetRow() { @Test public void testGetSetRowLarge() { int n = 3 * BlockFieldMatrix.BLOCK_SIZE; - FieldMatrix m = new BlockFieldMatrix<>(FractionField.getInstance(), n, n); + FieldMatrix m = new BlockFieldMatrix(FractionField.getInstance(), n, n); Fraction[] sub = new Fraction[n]; Arrays.fill(sub, new Fraction(1)); @@ -1068,7 +1068,7 @@ public void testGetSetRowLarge() { @Test public void testGetColumn() { - FieldMatrix m = new BlockFieldMatrix<>(subTestData); + FieldMatrix m = new BlockFieldMatrix(subTestData); Fraction[] mColumn1 = columnToArray(subColumn1); Fraction[] mColumn3 = columnToArray(subColumn3); checkArrays(mColumn1, m.getColumn(1)); @@ -1089,7 +1089,7 @@ public void testGetColumn() { @Test public void testSetColumn() { - FieldMatrix m = new BlockFieldMatrix<>(subTestData); + FieldMatrix m = new BlockFieldMatrix(subTestData); Fraction[] mColumn3 = columnToArray(subColumn3); Assert.assertTrue(mColumn3[0] != m.getColumn(1)[0]); m.setColumn(1, mColumn3); @@ -1111,7 +1111,7 @@ public void testSetColumn() { @Test public void testGetSetColumnLarge() { int n = 3 * BlockFieldMatrix.BLOCK_SIZE; - FieldMatrix m = new BlockFieldMatrix<>(FractionField.getInstance(), n, n); + FieldMatrix m = new BlockFieldMatrix(FractionField.getInstance(), n, n); Fraction[] sub = new Fraction[n]; Arrays.fill(sub, new Fraction(1)); @@ -1146,7 +1146,7 @@ private void checkArrays(Fraction[] expected, Fraction[] actual) { @Test public void testEqualsAndHashCode() { - BlockFieldMatrix m = new BlockFieldMatrix<>(testData); + BlockFieldMatrix m = new BlockFieldMatrix(testData); BlockFieldMatrix m1 = (BlockFieldMatrix) m.copy(); BlockFieldMatrix mt = (BlockFieldMatrix) m.transpose(); Assert.assertTrue(m.hashCode() != mt.hashCode()); @@ -1155,36 +1155,36 @@ public void testEqualsAndHashCode() { Assert.assertEquals(m, m1); Assert.assertFalse(m.equals(null)); Assert.assertFalse(m.equals(mt)); - Assert.assertFalse(m.equals(new BlockFieldMatrix<>(bigSingular))); + Assert.assertFalse(m.equals(new BlockFieldMatrix(bigSingular))); } @Test public void testToString() { - BlockFieldMatrix m = new BlockFieldMatrix<>(testData); + BlockFieldMatrix m = new BlockFieldMatrix(testData); Assert.assertEquals("BlockFieldMatrix{{1,2,3},{2,5,3},{1,0,8}}", m.toString()); } @Test public void testSetSubMatrix() { - BlockFieldMatrix m = new BlockFieldMatrix<>(testData); + BlockFieldMatrix m = new BlockFieldMatrix(testData); m.setSubMatrix(detData2,1,1); - FieldMatrix expected = new BlockFieldMatrix<> + FieldMatrix expected = new BlockFieldMatrix (new Fraction[][] {{new Fraction(1),new Fraction(2),new Fraction(3)},{new Fraction(2),new Fraction(1),new Fraction(3)},{new Fraction(1),new Fraction(2),new Fraction(4)}}); Assert.assertEquals(expected, m); m.setSubMatrix(detData2,0,0); - expected = new BlockFieldMatrix<> + expected = new BlockFieldMatrix (new Fraction[][] {{new Fraction(1),new Fraction(3),new Fraction(3)},{new Fraction(2),new Fraction(4),new Fraction(3)},{new Fraction(1),new Fraction(2),new Fraction(4)}}); Assert.assertEquals(expected, m); m.setSubMatrix(testDataPlus2,0,0); - expected = new BlockFieldMatrix<> + expected = new BlockFieldMatrix (new Fraction[][] {{new Fraction(3),new Fraction(4),new Fraction(5)},{new Fraction(4),new Fraction(7),new Fraction(5)},{new Fraction(3),new Fraction(2),new Fraction(10)}}); Assert.assertEquals(expected, m); // javadoc example BlockFieldMatrix matrix = - new BlockFieldMatrix<>(new Fraction[][] { + new BlockFieldMatrix(new Fraction[][] { {new Fraction(1), new Fraction(2), new Fraction(3), new Fraction(4)}, {new Fraction(5), new Fraction(6), new Fraction(7), new Fraction(8)}, {new Fraction(9), new Fraction(0), new Fraction(1) , new Fraction(2)} @@ -1194,7 +1194,7 @@ public void testSetSubMatrix() { {new Fraction(5), new Fraction(6)} }, 1, 1); expected = - new BlockFieldMatrix<>(new Fraction[][] { + new BlockFieldMatrix(new Fraction[][] { {new Fraction(1), new Fraction(2), new Fraction(3),new Fraction(4)}, {new Fraction(5), new Fraction(3), new Fraction(4), new Fraction(8)}, {new Fraction(9), new Fraction(5) ,new Fraction(6), new Fraction(2)} @@ -1252,13 +1252,13 @@ public void testWalk() { int rows = 150; int columns = 75; - FieldMatrix m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); + FieldMatrix m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInRowOrder(new SetVisitor()); GetVisitor getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); + m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInRowOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1272,13 +1272,13 @@ public void testWalk() { Assert.assertEquals(new Fraction(0), m.getEntry(rows - 1, j)); } - m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); + m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInColumnOrder(new SetVisitor()); getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); + m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInColumnOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1292,13 +1292,13 @@ public void testWalk() { Assert.assertEquals(new Fraction(0), m.getEntry(rows - 1, j)); } - m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); + m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor()); getVisitor = new GetVisitor(); m.walkInRowOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); + m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInRowOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1312,13 +1312,13 @@ public void testWalk() { Assert.assertEquals(new Fraction(0), m.getEntry(rows - 1, j)); } - m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); + m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor()); getVisitor = new GetVisitor(); m.walkInColumnOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); + m = new BlockFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInColumnOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1336,7 +1336,7 @@ public void testWalk() { @Test public void testSerial() { - BlockFieldMatrix m = new BlockFieldMatrix<>(testData); + BlockFieldMatrix m = new BlockFieldMatrix(testData); Assert.assertEquals(m,TestUtils.serializeAndRecover(m)); } @@ -1368,7 +1368,7 @@ public int getCount() { private BlockFieldMatrix createRandomMatrix(Random r, int rows, int columns) { BlockFieldMatrix m = - new BlockFieldMatrix<>(FractionField.getInstance(), rows, columns); + new BlockFieldMatrix(FractionField.getInstance(), rows, columns); for (int i = 0; i < rows; ++i) { for (int j = 0; j < columns; ++j) { int p = r.nextInt(20) - 10; diff --git a/src/test/java/org/apache/commons/math4/linear/FieldLUDecompositionTest.java b/src/test/java/org/apache/commons/math4/linear/FieldLUDecompositionTest.java index 0aa8c06811..528fdeb9e7 100644 --- a/src/test/java/org/apache/commons/math4/linear/FieldLUDecompositionTest.java +++ b/src/test/java/org/apache/commons/math4/linear/FieldLUDecompositionTest.java @@ -60,8 +60,8 @@ public class FieldLUDecompositionTest { @Test public void testDimensions() { FieldMatrix matrix = - new Array2DRowFieldMatrix<>(FractionField.getInstance(), testData); - FieldLUDecomposition LU = new FieldLUDecomposition<>(matrix); + new Array2DRowFieldMatrix(FractionField.getInstance(), testData); + FieldLUDecomposition LU = new FieldLUDecomposition(matrix); Assert.assertEquals(testData.length, LU.getL().getRowDimension()); Assert.assertEquals(testData.length, LU.getL().getColumnDimension()); Assert.assertEquals(testData.length, LU.getU().getRowDimension()); @@ -76,7 +76,7 @@ public void testDimensions() { public void testNonSquare() { try { // we don't use FractionField.getInstance() for testing purposes - new FieldLUDecomposition<>(new Array2DRowFieldMatrix<>(new Fraction[][] { + new FieldLUDecomposition(new Array2DRowFieldMatrix(new Fraction[][] { { Fraction.ZERO, Fraction.ZERO }, { Fraction.ZERO, Fraction.ZERO }, { Fraction.ZERO, Fraction.ZERO } @@ -90,39 +90,39 @@ public void testNonSquare() { /** test PA = LU */ @Test public void testPAEqualLU() { - FieldMatrix matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), testData); - FieldLUDecomposition lu = new FieldLUDecomposition<>(matrix); + FieldMatrix matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), testData); + FieldLUDecomposition lu = new FieldLUDecomposition(matrix); FieldMatrix l = lu.getL(); FieldMatrix u = lu.getU(); FieldMatrix p = lu.getP(); TestUtils.assertEquals(p.multiply(matrix), l.multiply(u)); - matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), testDataMinus); - lu = new FieldLUDecomposition<>(matrix); + matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), testDataMinus); + lu = new FieldLUDecomposition(matrix); l = lu.getL(); u = lu.getU(); p = lu.getP(); TestUtils.assertEquals(p.multiply(matrix), l.multiply(u)); - matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), 17, 17); + matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), 17, 17); for (int i = 0; i < matrix.getRowDimension(); ++i) { matrix.setEntry(i, i, Fraction.ONE); } - lu = new FieldLUDecomposition<>(matrix); + lu = new FieldLUDecomposition(matrix); l = lu.getL(); u = lu.getU(); p = lu.getP(); TestUtils.assertEquals(p.multiply(matrix), l.multiply(u)); - matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), singular); - lu = new FieldLUDecomposition<>(matrix); + matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), singular); + lu = new FieldLUDecomposition(matrix); Assert.assertFalse(lu.getSolver().isNonSingular()); Assert.assertNull(lu.getL()); Assert.assertNull(lu.getU()); Assert.assertNull(lu.getP()); - matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), bigSingular); - lu = new FieldLUDecomposition<>(matrix); + matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), bigSingular); + lu = new FieldLUDecomposition(matrix); Assert.assertFalse(lu.getSolver().isNonSingular()); Assert.assertNull(lu.getL()); Assert.assertNull(lu.getU()); @@ -133,8 +133,8 @@ public void testPAEqualLU() { /** test that L is lower triangular with unit diagonal */ @Test public void testLLowerTriangular() { - FieldMatrix matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), testData); - FieldMatrix l = new FieldLUDecomposition<>(matrix).getL(); + FieldMatrix matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), testData); + FieldMatrix l = new FieldLUDecomposition(matrix).getL(); for (int i = 0; i < l.getRowDimension(); i++) { Assert.assertEquals(Fraction.ONE, l.getEntry(i, i)); for (int j = i + 1; j < l.getColumnDimension(); j++) { @@ -146,8 +146,8 @@ public void testLLowerTriangular() { /** test that U is upper triangular */ @Test public void testUUpperTriangular() { - FieldMatrix matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), testData); - FieldMatrix u = new FieldLUDecomposition<>(matrix).getU(); + FieldMatrix matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), testData); + FieldMatrix u = new FieldLUDecomposition(matrix).getU(); for (int i = 0; i < u.getRowDimension(); i++) { for (int j = 0; j < i; j++) { Assert.assertEquals(Fraction.ZERO, u.getEntry(i, j)); @@ -158,12 +158,12 @@ public void testUUpperTriangular() { /** test that P is a permutation matrix */ @Test public void testPPermutation() { - FieldMatrix matrix = new Array2DRowFieldMatrix<>(FractionField.getInstance(), testData); - FieldMatrix p = new FieldLUDecomposition<>(matrix).getP(); + FieldMatrix matrix = new Array2DRowFieldMatrix(FractionField.getInstance(), testData); + FieldMatrix p = new FieldLUDecomposition(matrix).getP(); FieldMatrix ppT = p.multiply(p.transpose()); FieldMatrix id = - new Array2DRowFieldMatrix<>(FractionField.getInstance(), + new Array2DRowFieldMatrix(FractionField.getInstance(), p.getRowDimension(), p.getRowDimension()); for (int i = 0; i < id.getRowDimension(); ++i) { id.setEntry(i, i, Fraction.ONE); @@ -215,11 +215,11 @@ public void testPPermutation() { @Test public void testSingular() { FieldLUDecomposition lu = - new FieldLUDecomposition<>(new Array2DRowFieldMatrix<>(FractionField.getInstance(), testData)); + new FieldLUDecomposition(new Array2DRowFieldMatrix(FractionField.getInstance(), testData)); Assert.assertTrue(lu.getSolver().isNonSingular()); - lu = new FieldLUDecomposition<>(new Array2DRowFieldMatrix<>(FractionField.getInstance(), singular)); + lu = new FieldLUDecomposition(new Array2DRowFieldMatrix(FractionField.getInstance(), singular)); Assert.assertFalse(lu.getSolver().isNonSingular()); - lu = new FieldLUDecomposition<>(new Array2DRowFieldMatrix<>(FractionField.getInstance(), bigSingular)); + lu = new FieldLUDecomposition(new Array2DRowFieldMatrix(FractionField.getInstance(), bigSingular)); Assert.assertFalse(lu.getSolver().isNonSingular()); } @@ -227,18 +227,18 @@ public void testSingular() { @Test public void testMatricesValues1() { FieldLUDecomposition lu = - new FieldLUDecomposition<>(new Array2DRowFieldMatrix<>(FractionField.getInstance(), testData)); - FieldMatrix lRef = new Array2DRowFieldMatrix<>(FractionField.getInstance(), new Fraction[][] { + new FieldLUDecomposition(new Array2DRowFieldMatrix(FractionField.getInstance(), testData)); + FieldMatrix lRef = new Array2DRowFieldMatrix(FractionField.getInstance(), new Fraction[][] { { new Fraction(1), new Fraction(0), new Fraction(0) }, { new Fraction(2), new Fraction(1), new Fraction(0) }, { new Fraction(1), new Fraction(-2), new Fraction(1) } }); - FieldMatrix uRef = new Array2DRowFieldMatrix<>(FractionField.getInstance(), new Fraction[][] { + FieldMatrix uRef = new Array2DRowFieldMatrix(FractionField.getInstance(), new Fraction[][] { { new Fraction(1), new Fraction(2), new Fraction(3) }, { new Fraction(0), new Fraction(1), new Fraction(-3) }, { new Fraction(0), new Fraction(0), new Fraction(-1) } }); - FieldMatrix pRef = new Array2DRowFieldMatrix<>(FractionField.getInstance(), new Fraction[][] { + FieldMatrix pRef = new Array2DRowFieldMatrix(FractionField.getInstance(), new Fraction[][] { { new Fraction(1), new Fraction(0), new Fraction(0) }, { new Fraction(0), new Fraction(1), new Fraction(0) }, { new Fraction(0), new Fraction(0), new Fraction(1) } @@ -268,18 +268,18 @@ public void testMatricesValues1() { @Test public void testMatricesValues2() { FieldLUDecomposition lu = - new FieldLUDecomposition<>(new Array2DRowFieldMatrix<>(FractionField.getInstance(), luData)); - FieldMatrix lRef = new Array2DRowFieldMatrix<>(FractionField.getInstance(), new Fraction[][] { + new FieldLUDecomposition(new Array2DRowFieldMatrix(FractionField.getInstance(), luData)); + FieldMatrix lRef = new Array2DRowFieldMatrix(FractionField.getInstance(), new Fraction[][] { { new Fraction(1), new Fraction(0), new Fraction(0) }, { new Fraction(3), new Fraction(1), new Fraction(0) }, { new Fraction(1), new Fraction(0), new Fraction(1) } }); - FieldMatrix uRef = new Array2DRowFieldMatrix<>(FractionField.getInstance(), new Fraction[][] { + FieldMatrix uRef = new Array2DRowFieldMatrix(FractionField.getInstance(), new Fraction[][] { { new Fraction(2), new Fraction(3), new Fraction(3) }, { new Fraction(0), new Fraction(-3), new Fraction(-1) }, { new Fraction(0), new Fraction(0), new Fraction(4) } }); - FieldMatrix pRef = new Array2DRowFieldMatrix<>(FractionField.getInstance(), new Fraction[][] { + FieldMatrix pRef = new Array2DRowFieldMatrix(FractionField.getInstance(), new Fraction[][] { { new Fraction(1), new Fraction(0), new Fraction(0) }, { new Fraction(0), new Fraction(0), new Fraction(1) }, { new Fraction(0), new Fraction(1), new Fraction(0) } diff --git a/src/test/java/org/apache/commons/math4/linear/FieldLUSolverTest.java b/src/test/java/org/apache/commons/math4/linear/FieldLUSolverTest.java index 70ad9716bf..03662d8636 100644 --- a/src/test/java/org/apache/commons/math4/linear/FieldLUSolverTest.java +++ b/src/test/java/org/apache/commons/math4/linear/FieldLUSolverTest.java @@ -58,7 +58,7 @@ public static FieldMatrix createFractionMatrix(final int[][] data) { final int numRows = data.length; final int numCols = data[0].length; final Array2DRowFieldMatrix m; - m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), + m = new Array2DRowFieldMatrix(FractionField.getInstance(), numRows, numCols); for (int i = 0; i < numRows; i++) { for (int j = 0; j < numCols; j++) { @@ -72,13 +72,13 @@ public static FieldMatrix createFractionMatrix(final int[][] data) { @Test public void testSingular() { FieldDecompositionSolver solver; - solver = new FieldLUDecomposition<>(createFractionMatrix(testData)) + solver = new FieldLUDecomposition(createFractionMatrix(testData)) .getSolver(); Assert.assertTrue(solver.isNonSingular()); - solver = new FieldLUDecomposition<>(createFractionMatrix(singular)) + solver = new FieldLUDecomposition(createFractionMatrix(singular)) .getSolver(); Assert.assertFalse(solver.isNonSingular()); - solver = new FieldLUDecomposition<>(createFractionMatrix(bigSingular)) + solver = new FieldLUDecomposition(createFractionMatrix(bigSingular)) .getSolver(); Assert.assertFalse(solver.isNonSingular()); } @@ -87,7 +87,7 @@ public void testSingular() { @Test public void testSolveDimensionErrors() { FieldDecompositionSolver solver; - solver = new FieldLUDecomposition<>(createFractionMatrix(testData)) + solver = new FieldLUDecomposition(createFractionMatrix(testData)) .getSolver(); FieldMatrix b = createFractionMatrix(new int[2][2]); try { @@ -108,7 +108,7 @@ public void testSolveDimensionErrors() { @Test public void testSolveSingularityErrors() { FieldDecompositionSolver solver; - solver = new FieldLUDecomposition<>(createFractionMatrix(singular)) + solver = new FieldLUDecomposition(createFractionMatrix(singular)) .getSolver(); FieldMatrix b = createFractionMatrix(new int[2][2]); try { @@ -129,7 +129,7 @@ public void testSolveSingularityErrors() { @Test public void testSolve() { FieldDecompositionSolver solver; - solver = new FieldLUDecomposition<>(createFractionMatrix(testData)) + solver = new FieldLUDecomposition(createFractionMatrix(testData)) .getSolver(); FieldMatrix b = createFractionMatrix(new int[][] { { 1, 0 }, { 2, -5 }, { 3, 1 } @@ -159,7 +159,7 @@ public void testSolve() { // using SparseFieldVector for (int j = 0; j < b.getColumnDimension(); j++) { final SparseFieldVector bj; - bj = new SparseFieldVector<>(FractionField.getInstance(), + bj = new SparseFieldVector(FractionField.getInstance(), b.getColumn(j)); final FieldVector xj = solver.solve(bj); for (int i = 0; i < xj.getDimension(); i++) { @@ -179,6 +179,6 @@ public void testDeterminant() { } private double getDeterminant(final FieldMatrix m) { - return new FieldLUDecomposition<>(m).getDeterminant().doubleValue(); + return new FieldLUDecomposition(m).getDeterminant().doubleValue(); } } diff --git a/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java b/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java index bd4ccf55e9..4fb5bf4671 100644 --- a/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java +++ b/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java @@ -109,8 +109,8 @@ public final class FieldMatrixImplTest { /** test dimensions */ @Test public void testDimensions() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); - Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix<>(testData2); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); + Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix(testData2); Assert.assertEquals("testData row dimension",3,m.getRowDimension()); Assert.assertEquals("testData column dimension",3,m.getColumnDimension()); Assert.assertTrue("testData is square",m.isSquare()); @@ -122,19 +122,19 @@ public void testDimensions() { /** test copy functions */ @Test public void testCopyFunctions() { - Array2DRowFieldMatrix m1 = new Array2DRowFieldMatrix<>(testData); - Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix<>(m1.getData()); + Array2DRowFieldMatrix m1 = new Array2DRowFieldMatrix(testData); + Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix(m1.getData()); Assert.assertEquals(m2,m1); - Array2DRowFieldMatrix m3 = new Array2DRowFieldMatrix<>(testData); - Array2DRowFieldMatrix m4 = new Array2DRowFieldMatrix<>(m3.getData(), false); + Array2DRowFieldMatrix m3 = new Array2DRowFieldMatrix(testData); + Array2DRowFieldMatrix m4 = new Array2DRowFieldMatrix(m3.getData(), false); Assert.assertEquals(m4,m3); } /** test add */ @Test public void testAdd() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); - Array2DRowFieldMatrix mInv = new Array2DRowFieldMatrix<>(testDataInv); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); + Array2DRowFieldMatrix mInv = new Array2DRowFieldMatrix(testDataInv); FieldMatrix mPlusMInv = m.add(mInv); Fraction[][] sumEntries = mPlusMInv.getData(); for (int row = 0; row < m.getRowDimension(); row++) { @@ -147,8 +147,8 @@ public void testAdd() { /** test add failure */ @Test public void testAddFail() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); - Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix<>(testData2); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); + Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix(testData2); try { m.add(m2); Assert.fail("MathIllegalArgumentException expected"); @@ -160,11 +160,11 @@ public void testAddFail() { /** test m-n = m + -n */ @Test public void testPlusMinus() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); - Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix<>(testDataInv); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); + Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix(testDataInv); TestUtils.assertEquals(m.subtract(m2),m2.scalarMultiply(new Fraction(-1)).add(m)); try { - m.subtract(new Array2DRowFieldMatrix<>(testData2)); + m.subtract(new Array2DRowFieldMatrix(testData2)); Assert.fail("Expecting illegalArgumentException"); } catch (MathIllegalArgumentException ex) { // ignored @@ -174,17 +174,17 @@ public void testPlusMinus() { /** test multiply */ @Test public void testMultiply() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); - Array2DRowFieldMatrix mInv = new Array2DRowFieldMatrix<>(testDataInv); - Array2DRowFieldMatrix identity = new Array2DRowFieldMatrix<>(id); - Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix<>(testData2); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); + Array2DRowFieldMatrix mInv = new Array2DRowFieldMatrix(testDataInv); + Array2DRowFieldMatrix identity = new Array2DRowFieldMatrix(id); + Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix(testData2); TestUtils.assertEquals(m.multiply(mInv), identity); TestUtils.assertEquals(mInv.multiply(m), identity); TestUtils.assertEquals(m.multiply(identity), m); TestUtils.assertEquals(identity.multiply(mInv), mInv); TestUtils.assertEquals(m2.multiply(identity), m2); try { - m.multiply(new Array2DRowFieldMatrix<>(bigSingular)); + m.multiply(new Array2DRowFieldMatrix(bigSingular)); Assert.fail("Expecting illegalArgumentException"); } catch (MathIllegalArgumentException ex) { // ignored @@ -199,18 +199,18 @@ public void testMultiply() { @Test public void testMultiply2() { - FieldMatrix m3 = new Array2DRowFieldMatrix<>(d3); - FieldMatrix m4 = new Array2DRowFieldMatrix<>(d4); - FieldMatrix m5 = new Array2DRowFieldMatrix<>(d5); + FieldMatrix m3 = new Array2DRowFieldMatrix(d3); + FieldMatrix m4 = new Array2DRowFieldMatrix(d4); + FieldMatrix m5 = new Array2DRowFieldMatrix(d5); TestUtils.assertEquals(m3.multiply(m4), m5); } @Test public void testPower() { - FieldMatrix m = new Array2DRowFieldMatrix<>(testData); - FieldMatrix mInv = new Array2DRowFieldMatrix<>(testDataInv); - FieldMatrix mPlusInv = new Array2DRowFieldMatrix<>(testDataPlusInv); - FieldMatrix identity = new Array2DRowFieldMatrix<>(id); + FieldMatrix m = new Array2DRowFieldMatrix(testData); + FieldMatrix mInv = new Array2DRowFieldMatrix(testDataInv); + FieldMatrix mPlusInv = new Array2DRowFieldMatrix(testDataPlusInv); + FieldMatrix identity = new Array2DRowFieldMatrix(id); TestUtils.assertEquals(m.power(0), identity); TestUtils.assertEquals(mInv.power(0), identity); @@ -236,7 +236,7 @@ public void testPower() { } try { - FieldMatrix mNotSquare = new Array2DRowFieldMatrix<>(testData2T); + FieldMatrix mNotSquare = new Array2DRowFieldMatrix(testData2T); mNotSquare.power(2); Assert.fail("Expecting NonSquareMatrixException"); } catch (NonSquareMatrixException ex) { @@ -254,9 +254,9 @@ public void testPower() { /** test trace */ @Test public void testTrace() { - FieldMatrix m = new Array2DRowFieldMatrix<>(id); + FieldMatrix m = new Array2DRowFieldMatrix(id); Assert.assertEquals("identity trace",new Fraction(3),m.getTrace()); - m = new Array2DRowFieldMatrix<>(testData2); + m = new Array2DRowFieldMatrix(testData2); try { m.getTrace(); Assert.fail("Expecting NonSquareMatrixException"); @@ -268,17 +268,17 @@ public void testTrace() { /** test sclarAdd */ @Test public void testScalarAdd() { - FieldMatrix m = new Array2DRowFieldMatrix<>(testData); - TestUtils.assertEquals(new Array2DRowFieldMatrix<>(testDataPlus2), m.scalarAdd(new Fraction(2))); + FieldMatrix m = new Array2DRowFieldMatrix(testData); + TestUtils.assertEquals(new Array2DRowFieldMatrix(testDataPlus2), m.scalarAdd(new Fraction(2))); } /** test operate */ @Test public void testOperate() { - FieldMatrix m = new Array2DRowFieldMatrix<>(id); + FieldMatrix m = new Array2DRowFieldMatrix(id); TestUtils.assertEquals(testVector, m.operate(testVector)); - TestUtils.assertEquals(testVector, m.operate(new ArrayFieldVector<>(testVector)).toArray()); - m = new Array2DRowFieldMatrix<>(bigSingular); + TestUtils.assertEquals(testVector, m.operate(new ArrayFieldVector(testVector)).toArray()); + m = new Array2DRowFieldMatrix(bigSingular); try { m.operate(testVector); Assert.fail("Expecting illegalArgumentException"); @@ -290,7 +290,7 @@ public void testOperate() { /** test issue MATH-209 */ @Test public void testMath209() { - FieldMatrix a = new Array2DRowFieldMatrix<>(new Fraction[][] { + FieldMatrix a = new Array2DRowFieldMatrix(new Fraction[][] { { new Fraction(1), new Fraction(2) }, { new Fraction(3), new Fraction(4) }, { new Fraction(5), new Fraction(6) } }, false); Fraction[] b = a.operate(new Fraction[] { new Fraction(1), new Fraction(1) }); @@ -303,23 +303,23 @@ public void testMath209() { /** test transpose */ @Test public void testTranspose() { - FieldMatrix m = new Array2DRowFieldMatrix<>(testData); - FieldMatrix mIT = new FieldLUDecomposition<>(m).getSolver().getInverse().transpose(); - FieldMatrix mTI = new FieldLUDecomposition<>(m.transpose()).getSolver().getInverse(); + FieldMatrix m = new Array2DRowFieldMatrix(testData); + FieldMatrix mIT = new FieldLUDecomposition(m).getSolver().getInverse().transpose(); + FieldMatrix mTI = new FieldLUDecomposition(m.transpose()).getSolver().getInverse(); TestUtils.assertEquals(mIT, mTI); - m = new Array2DRowFieldMatrix<>(testData2); - FieldMatrix mt = new Array2DRowFieldMatrix<>(testData2T); + m = new Array2DRowFieldMatrix(testData2); + FieldMatrix mt = new Array2DRowFieldMatrix(testData2T); TestUtils.assertEquals(mt, m.transpose()); } /** test preMultiply by vector */ @Test public void testPremultiplyVector() { - FieldMatrix m = new Array2DRowFieldMatrix<>(testData); + FieldMatrix m = new Array2DRowFieldMatrix(testData); TestUtils.assertEquals(m.preMultiply(testVector), preMultTest); - TestUtils.assertEquals(m.preMultiply(new ArrayFieldVector<>(testVector).toArray()), + TestUtils.assertEquals(m.preMultiply(new ArrayFieldVector(testVector).toArray()), preMultTest); - m = new Array2DRowFieldMatrix<>(bigSingular); + m = new Array2DRowFieldMatrix(bigSingular); try { m.preMultiply(testVector); Assert.fail("expecting MathIllegalArgumentException"); @@ -330,20 +330,20 @@ public void testPremultiplyVector() { @Test public void testPremultiply() { - FieldMatrix m3 = new Array2DRowFieldMatrix<>(d3); - FieldMatrix m4 = new Array2DRowFieldMatrix<>(d4); - FieldMatrix m5 = new Array2DRowFieldMatrix<>(d5); + FieldMatrix m3 = new Array2DRowFieldMatrix(d3); + FieldMatrix m4 = new Array2DRowFieldMatrix(d4); + FieldMatrix m5 = new Array2DRowFieldMatrix(d5); TestUtils.assertEquals(m4.preMultiply(m3), m5); - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); - Array2DRowFieldMatrix mInv = new Array2DRowFieldMatrix<>(testDataInv); - Array2DRowFieldMatrix identity = new Array2DRowFieldMatrix<>(id); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); + Array2DRowFieldMatrix mInv = new Array2DRowFieldMatrix(testDataInv); + Array2DRowFieldMatrix identity = new Array2DRowFieldMatrix(id); TestUtils.assertEquals(m.preMultiply(mInv), identity); TestUtils.assertEquals(mInv.preMultiply(m), identity); TestUtils.assertEquals(m.preMultiply(identity), m); TestUtils.assertEquals(identity.preMultiply(mInv), mInv); try { - m.preMultiply(new Array2DRowFieldMatrix<>(bigSingular)); + m.preMultiply(new Array2DRowFieldMatrix(bigSingular)); Assert.fail("Expecting illegalArgumentException"); } catch (MathIllegalArgumentException ex) { // ignored @@ -352,7 +352,7 @@ public void testPremultiply() { @Test public void testGetVectors() { - FieldMatrix m = new Array2DRowFieldMatrix<>(testData); + FieldMatrix m = new Array2DRowFieldMatrix(testData); TestUtils.assertEquals(m.getRow(0), testDataRow1); TestUtils.assertEquals(m.getColumn(2), testDataCol3); try { @@ -371,7 +371,7 @@ public void testGetVectors() { @Test public void testGetEntry() { - FieldMatrix m = new Array2DRowFieldMatrix<>(testData); + FieldMatrix m = new Array2DRowFieldMatrix(testData); Assert.assertEquals("get entry", m.getEntry(0,1), new Fraction(2)); try { m.getEntry(10, 4); @@ -389,20 +389,20 @@ public void testExamples() { {new Fraction(1),new Fraction(2),new Fraction(3)}, {new Fraction(2),new Fraction(5),new Fraction(3)} }; - FieldMatrix m = new Array2DRowFieldMatrix<>(matrixData); + FieldMatrix m = new Array2DRowFieldMatrix(matrixData); // One more with three rows, two columns Fraction[][] matrixData2 = { {new Fraction(1),new Fraction(2)}, {new Fraction(2),new Fraction(5)}, {new Fraction(1), new Fraction(7)} }; - FieldMatrix n = new Array2DRowFieldMatrix<>(matrixData2); + FieldMatrix n = new Array2DRowFieldMatrix(matrixData2); // Now multiply m by n FieldMatrix p = m.multiply(n); Assert.assertEquals(2, p.getRowDimension()); Assert.assertEquals(2, p.getColumnDimension()); // Invert p - FieldMatrix pInverse = new FieldLUDecomposition<>(p).getSolver().getInverse(); + FieldMatrix pInverse = new FieldLUDecomposition(p).getSolver().getInverse(); Assert.assertEquals(2, pInverse.getRowDimension()); Assert.assertEquals(2, pInverse.getColumnDimension()); @@ -412,14 +412,14 @@ public void testExamples() { {new Fraction(-1), new Fraction(7), new Fraction(6)}, {new Fraction(4), new Fraction(-3), new Fraction(-5)} }; - FieldMatrix coefficients = new Array2DRowFieldMatrix<>(coefficientsData); + FieldMatrix coefficients = new Array2DRowFieldMatrix(coefficientsData); Fraction[] constants = { new Fraction(1), new Fraction(-2), new Fraction(1) }; Fraction[] solution; - solution = new FieldLUDecomposition<>(coefficients) + solution = new FieldLUDecomposition(coefficients) .getSolver() - .solve(new ArrayFieldVector<>(constants, false)).toArray(); + .solve(new ArrayFieldVector(constants, false)).toArray(); Assert.assertEquals(new Fraction(2).multiply(solution[0]). add(new Fraction(3).multiply(solution[1])). subtract(new Fraction(2).multiply(solution[2])), constants[0]); @@ -435,7 +435,7 @@ public void testExamples() { // test submatrix accessors @Test public void testGetSubMatrix() { - FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix(subTestData); checkGetSubMatrix(m, subRows23Cols00, 2 , 3 , 0, 0); checkGetSubMatrix(m, subRows00Cols33, 0 , 0 , 3, 3); checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3); @@ -458,7 +458,7 @@ private void checkGetSubMatrix(FieldMatrix m, Fraction[][] reference, try { FieldMatrix sub = m.getSubMatrix(startRow, endRow, startColumn, endColumn); if (reference != null) { - Assert.assertEquals(new Array2DRowFieldMatrix<>(reference), sub); + Assert.assertEquals(new Array2DRowFieldMatrix(reference), sub); } else { Assert.fail("Expecting OutOfRangeException or NotStrictlyPositiveException" + " or NumberIsTooSmallException or NoDataException"); @@ -487,7 +487,7 @@ private void checkGetSubMatrix(FieldMatrix m, Fraction[][] reference, try { FieldMatrix sub = m.getSubMatrix(selectedRows, selectedColumns); if (reference != null) { - Assert.assertEquals(new Array2DRowFieldMatrix<>(reference), sub); + Assert.assertEquals(new Array2DRowFieldMatrix(reference), sub); } else { Assert.fail("Expecting OutOfRangeException or NotStrictlyPositiveException" + " or NumberIsTooSmallException or NoDataException"); @@ -513,7 +513,7 @@ private void checkGetSubMatrix(FieldMatrix m, Fraction[][] reference, @Test public void testCopySubMatrix() { - FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix(subTestData); checkCopy(m, subRows23Cols00, 2 , 3 , 0, 0); checkCopy(m, subRows00Cols33, 0 , 0 , 3, 3); checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3); @@ -540,7 +540,7 @@ private void checkCopy(FieldMatrix m, Fraction[][] reference, new Fraction[reference.length][reference[0].length]; m.copySubMatrix(startRow, endRow, startColumn, endColumn, sub); if (reference != null) { - Assert.assertEquals(new Array2DRowFieldMatrix<>(reference), new Array2DRowFieldMatrix<>(sub)); + Assert.assertEquals(new Array2DRowFieldMatrix(reference), new Array2DRowFieldMatrix(sub)); } else { Assert.fail("Expecting OutOfRangeException or NumberIsTooSmallException or NoDataException"); } @@ -567,7 +567,7 @@ private void checkCopy(FieldMatrix m, Fraction[][] reference, new Fraction[reference.length][reference[0].length]; m.copySubMatrix(selectedRows, selectedColumns, sub); if (reference != null) { - Assert.assertEquals(new Array2DRowFieldMatrix<>(reference), new Array2DRowFieldMatrix<>(sub)); + Assert.assertEquals(new Array2DRowFieldMatrix(reference), new Array2DRowFieldMatrix(sub)); } else { Assert.fail("Expecting OutOfRangeException or NumberIsTooSmallException or NoDataException"); } @@ -588,9 +588,9 @@ private void checkCopy(FieldMatrix m, Fraction[][] reference, @Test public void testGetRowMatrix() { - FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); - FieldMatrix mRow0 = new Array2DRowFieldMatrix<>(subRow0); - FieldMatrix mRow3 = new Array2DRowFieldMatrix<>(subRow3); + FieldMatrix m = new Array2DRowFieldMatrix(subTestData); + FieldMatrix mRow0 = new Array2DRowFieldMatrix(subRow0); + FieldMatrix mRow3 = new Array2DRowFieldMatrix(subRow3); Assert.assertEquals("Row0", mRow0, m.getRowMatrix(0)); Assert.assertEquals("Row3", mRow3, @@ -611,8 +611,8 @@ public void testGetRowMatrix() { @Test public void testSetRowMatrix() { - FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); - FieldMatrix mRow3 = new Array2DRowFieldMatrix<>(subRow3); + FieldMatrix m = new Array2DRowFieldMatrix(subTestData); + FieldMatrix mRow3 = new Array2DRowFieldMatrix(subRow3); Assert.assertNotSame(mRow3, m.getRowMatrix(0)); m.setRowMatrix(0, mRow3); Assert.assertEquals(mRow3, m.getRowMatrix(0)); @@ -632,9 +632,9 @@ public void testSetRowMatrix() { @Test public void testGetColumnMatrix() { - FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); - FieldMatrix mColumn1 = new Array2DRowFieldMatrix<>(subColumn1); - FieldMatrix mColumn3 = new Array2DRowFieldMatrix<>(subColumn3); + FieldMatrix m = new Array2DRowFieldMatrix(subTestData); + FieldMatrix mColumn1 = new Array2DRowFieldMatrix(subColumn1); + FieldMatrix mColumn3 = new Array2DRowFieldMatrix(subColumn3); Assert.assertEquals("Column1", mColumn1, m.getColumnMatrix(1)); Assert.assertEquals("Column3", mColumn3, @@ -655,8 +655,8 @@ public void testGetColumnMatrix() { @Test public void testSetColumnMatrix() { - FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); - FieldMatrix mColumn3 = new Array2DRowFieldMatrix<>(subColumn3); + FieldMatrix m = new Array2DRowFieldMatrix(subTestData); + FieldMatrix mColumn3 = new Array2DRowFieldMatrix(subColumn3); Assert.assertNotSame(mColumn3, m.getColumnMatrix(1)); m.setColumnMatrix(1, mColumn3); Assert.assertEquals(mColumn3, m.getColumnMatrix(1)); @@ -676,9 +676,9 @@ public void testSetColumnMatrix() { @Test public void testGetRowVector() { - FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); - FieldVector mRow0 = new ArrayFieldVector<>(subRow0[0]); - FieldVector mRow3 = new ArrayFieldVector<>(subRow3[0]); + FieldMatrix m = new Array2DRowFieldMatrix(subTestData); + FieldVector mRow0 = new ArrayFieldVector(subRow0[0]); + FieldVector mRow3 = new ArrayFieldVector(subRow3[0]); Assert.assertEquals("Row0", mRow0, m.getRowVector(0)); Assert.assertEquals("Row3", mRow3, m.getRowVector(3)); try { @@ -697,8 +697,8 @@ public void testGetRowVector() { @Test public void testSetRowVector() { - FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); - FieldVector mRow3 = new ArrayFieldVector<>(subRow3[0]); + FieldMatrix m = new Array2DRowFieldMatrix(subTestData); + FieldVector mRow3 = new ArrayFieldVector(subRow3[0]); Assert.assertNotSame(mRow3, m.getRowMatrix(0)); m.setRowVector(0, mRow3); Assert.assertEquals(mRow3, m.getRowVector(0)); @@ -709,7 +709,7 @@ public void testSetRowVector() { // expected } try { - m.setRowVector(0, new ArrayFieldVector<>(FractionField.getInstance(), 5)); + m.setRowVector(0, new ArrayFieldVector(FractionField.getInstance(), 5)); Assert.fail("Expecting MatrixDimensionMismatchException"); } catch (MatrixDimensionMismatchException ex) { // expected @@ -718,7 +718,7 @@ public void testSetRowVector() { @Test public void testGetColumnVector() { - FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix(subTestData); FieldVector mColumn1 = columnToVector(subColumn1); FieldVector mColumn3 = columnToVector(subColumn3); Assert.assertEquals("Column1", mColumn1, m.getColumnVector(1)); @@ -739,7 +739,7 @@ public void testGetColumnVector() { @Test public void testSetColumnVector() { - FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix(subTestData); FieldVector mColumn3 = columnToVector(subColumn3); Assert.assertNotSame(mColumn3, m.getColumnVector(1)); m.setColumnVector(1, mColumn3); @@ -751,7 +751,7 @@ public void testSetColumnVector() { // expected } try { - m.setColumnVector(0, new ArrayFieldVector<>(FractionField.getInstance(), 5)); + m.setColumnVector(0, new ArrayFieldVector(FractionField.getInstance(), 5)); Assert.fail("Expecting MatrixDimensionMismatchException"); } catch (MatrixDimensionMismatchException ex) { // expected @@ -763,12 +763,12 @@ private FieldVector columnToVector(Fraction[][] column) { for (int i = 0; i < data.length; ++i) { data[i] = column[i][0]; } - return new ArrayFieldVector<>(data, false); + return new ArrayFieldVector(data, false); } @Test public void testGetRow() { - FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix(subTestData); checkArrays(subRow0[0], m.getRow(0)); checkArrays(subRow3[0], m.getRow(3)); try { @@ -787,7 +787,7 @@ public void testGetRow() { @Test public void testSetRow() { - FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix(subTestData); Assert.assertTrue(subRow3[0][0] != m.getRow(0)[0]); m.setRow(0, subRow3[0]); checkArrays(subRow3[0], m.getRow(0)); @@ -807,7 +807,7 @@ public void testSetRow() { @Test public void testGetColumn() { - FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix(subTestData); Fraction[] mColumn1 = columnToArray(subColumn1); Fraction[] mColumn3 = columnToArray(subColumn3); checkArrays(mColumn1, m.getColumn(1)); @@ -828,7 +828,7 @@ public void testGetColumn() { @Test public void testSetColumn() { - FieldMatrix m = new Array2DRowFieldMatrix<>(subTestData); + FieldMatrix m = new Array2DRowFieldMatrix(subTestData); Fraction[] mColumn3 = columnToArray(subColumn3); Assert.assertTrue(mColumn3[0] != m.getColumn(1)[0]); m.setColumn(1, mColumn3); @@ -864,7 +864,7 @@ private void checkArrays(Fraction[] expected, Fraction[] actual) { @Test public void testEqualsAndHashCode() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); Array2DRowFieldMatrix m1 = (Array2DRowFieldMatrix) m.copy(); Array2DRowFieldMatrix mt = (Array2DRowFieldMatrix) m.transpose(); Assert.assertTrue(m.hashCode() != mt.hashCode()); @@ -873,22 +873,22 @@ public void testEqualsAndHashCode() { Assert.assertEquals(m, m1); Assert.assertFalse(m.equals(null)); Assert.assertFalse(m.equals(mt)); - Assert.assertFalse(m.equals(new Array2DRowFieldMatrix<>(bigSingular))); + Assert.assertFalse(m.equals(new Array2DRowFieldMatrix(bigSingular))); } @Test public void testToString() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); Assert.assertEquals("Array2DRowFieldMatrix{{1,2,3},{2,5,3},{1,0,8}}", m.toString()); - m = new Array2DRowFieldMatrix<>(FractionField.getInstance()); + m = new Array2DRowFieldMatrix(FractionField.getInstance()); Assert.assertEquals("Array2DRowFieldMatrix{}", m.toString()); } @Test public void testSetSubMatrix() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); m.setSubMatrix(detData2,1,1); - FieldMatrix expected = new Array2DRowFieldMatrix<> + FieldMatrix expected = new Array2DRowFieldMatrix (new Fraction[][] { {new Fraction(1),new Fraction(2),new Fraction(3)}, {new Fraction(2),new Fraction(1),new Fraction(3)}, @@ -897,7 +897,7 @@ public void testSetSubMatrix() { Assert.assertEquals(expected, m); m.setSubMatrix(detData2,0,0); - expected = new Array2DRowFieldMatrix<> + expected = new Array2DRowFieldMatrix (new Fraction[][] { {new Fraction(1),new Fraction(3),new Fraction(3)}, {new Fraction(2),new Fraction(4),new Fraction(3)}, @@ -906,7 +906,7 @@ public void testSetSubMatrix() { Assert.assertEquals(expected, m); m.setSubMatrix(testDataPlus2,0,0); - expected = new Array2DRowFieldMatrix<> + expected = new Array2DRowFieldMatrix (new Fraction[][] { {new Fraction(3),new Fraction(4),new Fraction(5)}, {new Fraction(4),new Fraction(7),new Fraction(5)}, @@ -942,7 +942,7 @@ public void testSetSubMatrix() { } catch (NullArgumentException e) { // expected } - Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix<>(FractionField.getInstance()); + Array2DRowFieldMatrix m2 = new Array2DRowFieldMatrix(FractionField.getInstance()); try { m2.setSubMatrix(testData,0,1); Assert.fail("expecting MathIllegalStateException"); @@ -980,13 +980,13 @@ public void testWalk() { int columns = 75; FieldMatrix m = - new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); + new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInRowOrder(new SetVisitor()); GetVisitor getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); + m = new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInRowOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1000,13 +1000,13 @@ public void testWalk() { Assert.assertEquals(new Fraction(0), m.getEntry(rows - 1, j)); } - m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); + m = new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInColumnOrder(new SetVisitor()); getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); + m = new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInColumnOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInOptimizedOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1020,13 +1020,13 @@ public void testWalk() { Assert.assertEquals(new Fraction(0), m.getEntry(rows - 1, j)); } - m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); + m = new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor()); getVisitor = new GetVisitor(); m.walkInRowOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); + m = new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInRowOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1040,13 +1040,13 @@ public void testWalk() { Assert.assertEquals(new Fraction(0), m.getEntry(rows - 1, j)); } - m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); + m = new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor()); getVisitor = new GetVisitor(); m.walkInColumnOrder(getVisitor); Assert.assertEquals(rows * columns, getVisitor.getCount()); - m = new Array2DRowFieldMatrix<>(FractionField.getInstance(), rows, columns); + m = new Array2DRowFieldMatrix(FractionField.getInstance(), rows, columns); m.walkInOptimizedOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2); getVisitor = new GetVisitor(); m.walkInColumnOrder(getVisitor, 1, rows - 2, 1, columns - 2); @@ -1063,7 +1063,7 @@ public void testWalk() { @Test public void testSerial() { - Array2DRowFieldMatrix m = new Array2DRowFieldMatrix<>(testData); + Array2DRowFieldMatrix m = new Array2DRowFieldMatrix(testData); Assert.assertEquals(m,TestUtils.serializeAndRecover(m)); } @@ -1148,6 +1148,6 @@ protected FieldMatrix permuteRows(FieldMatrix matrix, int[] out[i][j] = matrix.getEntry(permutation[i], j); } } - return new Array2DRowFieldMatrix<>(out); + return new Array2DRowFieldMatrix(out); } } diff --git a/src/test/java/org/apache/commons/math4/linear/MatrixUtilsTest.java b/src/test/java/org/apache/commons/math4/linear/MatrixUtilsTest.java index c8bd3f9106..b547cdc038 100644 --- a/src/test/java/org/apache/commons/math4/linear/MatrixUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/linear/MatrixUtilsTest.java @@ -104,9 +104,9 @@ public void testCreateRealMatrix() { @Test public void testcreateFieldMatrix() { - Assert.assertEquals(new Array2DRowFieldMatrix<>(asFraction(testData)), + Assert.assertEquals(new Array2DRowFieldMatrix(asFraction(testData)), MatrixUtils.createFieldMatrix(asFraction(testData))); - Assert.assertEquals(new Array2DRowFieldMatrix<>(FractionField.getInstance(), fractionColMatrix), + Assert.assertEquals(new Array2DRowFieldMatrix(FractionField.getInstance(), fractionColMatrix), MatrixUtils.createFieldMatrix(fractionColMatrix)); try { MatrixUtils.createFieldMatrix(asFraction(new double[][] {{1}, {1,2}})); // ragged @@ -149,9 +149,9 @@ public void testCreateRowRealMatrix() { @Test public void testCreateRowFieldMatrix() { Assert.assertEquals(MatrixUtils.createRowFieldMatrix(asFraction(row)), - new Array2DRowFieldMatrix<>(asFraction(rowMatrix))); + new Array2DRowFieldMatrix(asFraction(rowMatrix))); Assert.assertEquals(MatrixUtils.createRowFieldMatrix(fractionRow), - new Array2DRowFieldMatrix<>(fractionRowMatrix)); + new Array2DRowFieldMatrix(fractionRowMatrix)); try { MatrixUtils.createRowFieldMatrix(new Fraction[] {}); // empty Assert.fail("Expecting MathIllegalArgumentException"); @@ -187,9 +187,9 @@ public void testCreateColumnRealMatrix() { @Test public void testCreateColumnFieldMatrix() { Assert.assertEquals(MatrixUtils.createColumnFieldMatrix(asFraction(col)), - new Array2DRowFieldMatrix<>(asFraction(colMatrix))); + new Array2DRowFieldMatrix(asFraction(colMatrix))); Assert.assertEquals(MatrixUtils.createColumnFieldMatrix(fractionCol), - new Array2DRowFieldMatrix<>(fractionColMatrix)); + new Array2DRowFieldMatrix(fractionColMatrix)); try { MatrixUtils.createColumnFieldMatrix(new Fraction[] {}); // empty @@ -268,7 +268,7 @@ public void testBigFractionConverter() { { new BigFraction(2), new BigFraction(5), new BigFraction(3) }, { new BigFraction(1), new BigFraction(0), new BigFraction(8) } }; - FieldMatrix m = new Array2DRowFieldMatrix<>(bfData, false); + FieldMatrix m = new Array2DRowFieldMatrix(bfData, false); RealMatrix converted = MatrixUtils.bigFractionMatrixToRealMatrix(m); RealMatrix reference = new Array2DRowRealMatrix(testData, false); Assert.assertEquals(0.0, converted.subtract(reference).getNorm(), 0.0); @@ -281,7 +281,7 @@ public void testFractionConverter() { { new Fraction(2), new Fraction(5), new Fraction(3) }, { new Fraction(1), new Fraction(0), new Fraction(8) } }; - FieldMatrix m = new Array2DRowFieldMatrix<>(fData, false); + FieldMatrix m = new Array2DRowFieldMatrix(fData, false); RealMatrix converted = MatrixUtils.fractionMatrixToRealMatrix(m); RealMatrix reference = new Array2DRowRealMatrix(testData, false); Assert.assertEquals(0.0, converted.subtract(reference).getNorm(), 0.0); diff --git a/src/test/java/org/apache/commons/math4/linear/SparseFieldMatrixTest.java b/src/test/java/org/apache/commons/math4/linear/SparseFieldMatrixTest.java index 0266b305d1..176b227aa2 100644 --- a/src/test/java/org/apache/commons/math4/linear/SparseFieldMatrixTest.java +++ b/src/test/java/org/apache/commons/math4/linear/SparseFieldMatrixTest.java @@ -209,7 +209,7 @@ public void testMultiply() { SparseFieldMatrix m2 = createSparseMatrix(testData2); assertClose("inverse multiply", m.multiply(mInv), identity, entryTolerance); - assertClose("inverse multiply", m.multiply(new Array2DRowFieldMatrix<>(FractionField.getInstance(), testDataInv)), identity, + assertClose("inverse multiply", m.multiply(new Array2DRowFieldMatrix(FractionField.getInstance(), testDataInv)), identity, entryTolerance); assertClose("inverse multiply", mInv.multiply(m), identity, entryTolerance); @@ -270,7 +270,7 @@ public void testOperate() { assertClose("identity operate", testVector, m.operate(testVector), entryTolerance); assertClose("identity operate", testVector, m.operate( - new ArrayFieldVector<>(testVector)).toArray(), entryTolerance); + new ArrayFieldVector(testVector)).toArray(), entryTolerance); m = createSparseMatrix(bigSingular); try { m.operate(testVector); @@ -296,8 +296,8 @@ public void testMath209() { @Test public void testTranspose() { FieldMatrix m = createSparseMatrix(testData); - FieldMatrix mIT = new FieldLUDecomposition<>(m).getSolver().getInverse().transpose(); - FieldMatrix mTI = new FieldLUDecomposition<>(m.transpose()).getSolver().getInverse(); + FieldMatrix mIT = new FieldLUDecomposition(m).getSolver().getInverse().transpose(); + FieldMatrix mTI = new FieldLUDecomposition(m.transpose()).getSolver().getInverse(); assertClose("inverse-transpose", mIT, mTI, normTolerance); m = createSparseMatrix(testData2); FieldMatrix mt = createSparseMatrix(testData2T); @@ -311,7 +311,7 @@ public void testPremultiplyVector() { assertClose("premultiply", m.preMultiply(testVector), preMultTest, normTolerance); assertClose("premultiply", m.preMultiply( - new ArrayFieldVector<>(testVector).toArray()), preMultTest, normTolerance); + new ArrayFieldVector(testVector).toArray()), preMultTest, normTolerance); m = createSparseMatrix(bigSingular); try { m.preMultiply(testVector); @@ -392,7 +392,7 @@ public void testExamples() { Assert.assertEquals(2, p.getRowDimension()); Assert.assertEquals(2, p.getColumnDimension()); // Invert p - FieldMatrix pInverse = new FieldLUDecomposition<>(p).getSolver().getInverse(); + FieldMatrix pInverse = new FieldLUDecomposition(p).getSolver().getInverse(); Assert.assertEquals(2, pInverse.getRowDimension()); Assert.assertEquals(2, pInverse.getColumnDimension()); @@ -402,9 +402,9 @@ public void testExamples() { FieldMatrix coefficients = createSparseMatrix(coefficientsData); Fraction[] constants = { new Fraction(1), new Fraction(-2), new Fraction(1) }; Fraction[] solution; - solution = new FieldLUDecomposition<>(coefficients) + solution = new FieldLUDecomposition(coefficients) .getSolver() - .solve(new ArrayFieldVector<>(constants, false)).toArray(); + .solve(new ArrayFieldVector(constants, false)).toArray(); Assert.assertEquals((new Fraction(2).multiply((solution[0])).add(new Fraction(3).multiply(solution[1])).subtract(new Fraction(2).multiply(solution[2]))).doubleValue(), constants[0].doubleValue(), 1E-12); Assert.assertEquals(((new Fraction(-1).multiply(solution[0])).add(new Fraction(7).multiply(solution[1])).add(new Fraction(6).multiply(solution[2]))).doubleValue(), @@ -525,8 +525,8 @@ public void testGetColumnMatrix() { @Test public void testGetRowVector() { FieldMatrix m = createSparseMatrix(subTestData); - FieldVector mRow0 = new ArrayFieldVector<>(subRow0[0]); - FieldVector mRow3 = new ArrayFieldVector<>(subRow3[0]); + FieldVector mRow0 = new ArrayFieldVector(subRow0[0]); + FieldVector mRow3 = new ArrayFieldVector(subRow3[0]); Assert.assertEquals("Row0", mRow0, m.getRowVector(0)); Assert.assertEquals("Row3", mRow3, m.getRowVector(3)); try { @@ -569,7 +569,7 @@ private FieldVector columnToVector(Fraction[][] column) { for (int i = 0; i < data.length; ++i) { data[i] = column[i][0]; } - return new ArrayFieldVector<>(data, false); + return new ArrayFieldVector(data, false); } @Test @@ -653,7 +653,7 @@ public void testSetSubMatrix() { // expected } try { - new SparseFieldMatrix<>(field, 0, 0); + new SparseFieldMatrix(field, 0, 0); Assert.fail("expecting MathIllegalArgumentException"); } catch (MathIllegalArgumentException e) { // expected @@ -702,7 +702,7 @@ protected void assertClose(String msg, Fraction[] m, Fraction[] n, } private SparseFieldMatrix createSparseMatrix(Fraction[][] data) { - SparseFieldMatrix matrix = new SparseFieldMatrix<>(field, data.length, data[0].length); + SparseFieldMatrix matrix = new SparseFieldMatrix(field, data.length, data[0].length); for (int row = 0; row < data.length; row++) { for (int col = 0; col < data[row].length; col++) { matrix.setEntry(row, col, data[row][col]); diff --git a/src/test/java/org/apache/commons/math4/linear/SparseFieldVectorTest.java b/src/test/java/org/apache/commons/math4/linear/SparseFieldVectorTest.java index 5df1142e21..3a607f4637 100644 --- a/src/test/java/org/apache/commons/math4/linear/SparseFieldVectorTest.java +++ b/src/test/java/org/apache/commons/math4/linear/SparseFieldVectorTest.java @@ -58,7 +58,7 @@ public class SparseFieldVectorTest { @Test public void testMapFunctions() throws FractionConversionException { - SparseFieldVector v1 = new SparseFieldVector<>(field,vec1); + SparseFieldVector v1 = new SparseFieldVector(field,vec1); //octave = v1 .+ 2.0 FieldVector v_mapAdd = v1.mapAdd(new Fraction(2)); @@ -120,17 +120,17 @@ public void testMapFunctions() throws FractionConversionException { @Test public void testBasicFunctions() throws FractionConversionException { - SparseFieldVector v1 = new SparseFieldVector<>(field,vec1); - SparseFieldVector v2 = new SparseFieldVector<>(field,vec2); + SparseFieldVector v1 = new SparseFieldVector(field,vec1); + SparseFieldVector v2 = new SparseFieldVector(field,vec2); - FieldVector v2_t = new ArrayFieldVectorTest.FieldVectorTestImpl<>(vec2); + FieldVector v2_t = new ArrayFieldVectorTest.FieldVectorTestImpl(vec2); //octave = v1 + v2 FieldVector v_add = v1.add(v2); Fraction[] result_add = {new Fraction(5), new Fraction(7), new Fraction(9)}; Assert.assertArrayEquals("compare vect" ,v_add.toArray(),result_add); - FieldVector vt2 = new ArrayFieldVectorTest.FieldVectorTestImpl<>(vec2); + FieldVector vt2 = new ArrayFieldVectorTest.FieldVectorTestImpl(vec2); FieldVector v_add_i = v1.add(vt2); Fraction[] result_add_i = {new Fraction(5), new Fraction(7), new Fraction(9)}; Assert.assertArrayEquals("compare vect" ,v_add_i.toArray(),result_add_i); @@ -181,12 +181,12 @@ public void testBasicFunctions() throws FractionConversionException { @Test public void testOuterProduct() { final SparseFieldVector u - = new SparseFieldVector<>(FractionField.getInstance(), + = new SparseFieldVector(FractionField.getInstance(), new Fraction[] {new Fraction(1), new Fraction(2), new Fraction(-3)}); final SparseFieldVector v - = new SparseFieldVector<>(FractionField.getInstance(), + = new SparseFieldVector(FractionField.getInstance(), new Fraction[] {new Fraction(4), new Fraction(-2)}); @@ -203,7 +203,7 @@ public void testOuterProduct() { @Test public void testMisc() { - SparseFieldVector v1 = new SparseFieldVector<>(field,vec1); + SparseFieldVector v1 = new SparseFieldVector(field,vec1); String out1 = v1.toString(); Assert.assertTrue("some output ", out1.length()!=0); @@ -220,11 +220,11 @@ public void testMisc() { @Test public void testPredicates() { - SparseFieldVector v = new SparseFieldVector<>(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2) }); + SparseFieldVector v = new SparseFieldVector(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2) }); v.setEntry(0, field.getZero()); - Assert.assertEquals(v, new SparseFieldVector<>(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2) })); - Assert.assertNotSame(v, new SparseFieldVector<>(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2), new Fraction(3) })); + Assert.assertEquals(v, new SparseFieldVector(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2) })); + Assert.assertNotSame(v, new SparseFieldVector(field, new Fraction[] { new Fraction(0), new Fraction(1), new Fraction(2), new Fraction(3) })); } @@ -260,7 +260,7 @@ public void testWalkInDefaultOrderPreservingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector<>(field, data); + final SparseFieldVector v = new SparseFieldVector(field, data); final FieldVectorPreservingVisitor visitor; visitor = new FieldVectorPreservingVisitor() { @@ -347,7 +347,7 @@ public void testWalkInDefaultOrderPreservingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector<>(field, data); + final SparseFieldVector v = new SparseFieldVector(field, data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorPreservingVisitor visitor; @@ -385,7 +385,7 @@ public void testWalkInOptimizedOrderPreservingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector<>(field, data); + final SparseFieldVector v = new SparseFieldVector(field, data); final FieldVectorPreservingVisitor visitor; visitor = new FieldVectorPreservingVisitor() { private final boolean[] visited = new boolean[data.length]; @@ -474,7 +474,7 @@ public void testWalkInOptimizedOrderPreservingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector<>(field, data); + final SparseFieldVector v = new SparseFieldVector(field, data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorPreservingVisitor visitor; @@ -514,7 +514,7 @@ public void testWalkInDefaultOrderChangingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector<>(field, data); + final SparseFieldVector v = new SparseFieldVector(field, data); final FieldVectorChangingVisitor visitor; visitor = new FieldVectorChangingVisitor() { @@ -605,7 +605,7 @@ public void testWalkInDefaultOrderChangingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector<>(field, data); + final SparseFieldVector v = new SparseFieldVector(field, data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorChangingVisitor visitor; @@ -647,7 +647,7 @@ public void testWalkInOptimizedOrderChangingVisitor1() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector<>(field, data); + final SparseFieldVector v = new SparseFieldVector(field, data); final FieldVectorChangingVisitor visitor; visitor = new FieldVectorChangingVisitor() { private final boolean[] visited = new boolean[data.length]; @@ -740,7 +740,7 @@ public void testWalkInOptimizedOrderChangingVisitor3() { Fraction.ZERO, Fraction.TWO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, new Fraction(3) }; - final SparseFieldVector v = new SparseFieldVector<>(field, data); + final SparseFieldVector v = new SparseFieldVector(field, data); final int expectedStart = 2; final int expectedEnd = 7; final FieldVectorChangingVisitor visitor; @@ -781,6 +781,6 @@ private SparseFieldVector create(int n) { for (int i = 0; i < n; ++i) { t[i] = Fraction.ZERO; } - return new SparseFieldVector<>(field, t); + return new SparseFieldVector(field, t); } } diff --git a/src/test/java/org/apache/commons/math4/linear/UnmodifiableRealVectorAbstractTest.java b/src/test/java/org/apache/commons/math4/linear/UnmodifiableRealVectorAbstractTest.java index 121789e38b..9930801435 100644 --- a/src/test/java/org/apache/commons/math4/linear/UnmodifiableRealVectorAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/linear/UnmodifiableRealVectorAbstractTest.java @@ -53,7 +53,7 @@ public abstract class UnmodifiableRealVectorAbstractTest { * The list of methods which are excluded from the general test * {@link #testAllButExcluded()}. */ - protected static final Set EXCLUDE = new HashSet<>(); + protected static final Set EXCLUDE = new HashSet(); /** The random number generator (always initialized with the same seed. */ protected static final Random RANDOM; diff --git a/src/test/java/org/apache/commons/math4/ml/clustering/DBSCANClustererTest.java b/src/test/java/org/apache/commons/math4/ml/clustering/DBSCANClustererTest.java index e3413a709a..0820fbc586 100644 --- a/src/test/java/org/apache/commons/math4/ml/clustering/DBSCANClustererTest.java +++ b/src/test/java/org/apache/commons/math4/ml/clustering/DBSCANClustererTest.java @@ -99,7 +99,7 @@ public void testCluster() { }; final DBSCANClusterer transformer = - new DBSCANClusterer<>(2.0, 5); + new DBSCANClusterer(2.0, 5); final List> clusters = transformer.cluster(Arrays.asList(points)); final List clusterOne = @@ -152,7 +152,7 @@ public void testSingleLink() { }; - final DBSCANClusterer clusterer = new DBSCANClusterer<>(3, 3); + final DBSCANClusterer clusterer = new DBSCANClusterer(3, 3); List> clusters = clusterer.cluster(Arrays.asList(points)); Assert.assertEquals(1, clusters.size()); @@ -164,13 +164,13 @@ public void testSingleLink() { @Test public void testGetEps() { - final DBSCANClusterer transformer = new DBSCANClusterer<>(2.0, 5); + final DBSCANClusterer transformer = new DBSCANClusterer(2.0, 5); Assert.assertEquals(2.0, transformer.getEps(), 0.0); } @Test public void testGetMinPts() { - final DBSCANClusterer transformer = new DBSCANClusterer<>(2.0, 5); + final DBSCANClusterer transformer = new DBSCANClusterer(2.0, 5); Assert.assertEquals(5, transformer.getMinPts()); } @@ -186,7 +186,7 @@ public void testNegativeMinPts() { @Test(expected = NullArgumentException.class) public void testNullDataset() { - DBSCANClusterer clusterer = new DBSCANClusterer<>(2.0, 5); + DBSCANClusterer clusterer = new DBSCANClusterer(2.0, 5); clusterer.cluster(null); } diff --git a/src/test/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClustererTest.java b/src/test/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClustererTest.java index dd5ca3623d..a46c01ea77 100644 --- a/src/test/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClustererTest.java +++ b/src/test/java/org/apache/commons/math4/ml/clustering/FuzzyKMeansClustererTest.java @@ -43,7 +43,7 @@ public class FuzzyKMeansClustererTest { @Test public void testCluster() { - final List points = new ArrayList<>(); + final List points = new ArrayList(); // create 10 data points: [1], ... [10] for (int i = 1; i <= 10; i++) { @@ -52,7 +52,7 @@ public void testCluster() { } final FuzzyKMeansClusterer transformer = - new FuzzyKMeansClusterer<>(3, 2.0); + new FuzzyKMeansClusterer(3, 2.0); final List> clusters = transformer.cluster(points); // we expect 3 clusters: @@ -90,7 +90,7 @@ public void testTooSmallFuzzynessFactor() { @Test(expected = NullArgumentException.class) public void testNullDataset() { - final FuzzyKMeansClusterer clusterer = new FuzzyKMeansClusterer<>(3, 2.0); + final FuzzyKMeansClusterer clusterer = new FuzzyKMeansClusterer(3, 2.0); clusterer.cluster(null); } @@ -99,7 +99,7 @@ public void testGetters() { final DistanceMeasure measure = new CanberraDistance(); final RandomGenerator random = new JDKRandomGenerator(); final FuzzyKMeansClusterer clusterer = - new FuzzyKMeansClusterer<>(3, 2.0, 100, measure, 1e-6, random); + new FuzzyKMeansClusterer(3, 2.0, 100, measure, 1e-6, random); Assert.assertEquals(3, clusterer.getK()); Assert.assertEquals(2.0, clusterer.getFuzziness(), 1e-6); @@ -111,11 +111,11 @@ public void testGetters() { @Test public void testSingleCluster() { - final List points = new ArrayList<>(); + final List points = new ArrayList(); points.add(new DoublePoint(new double[] { 1, 1 })); final FuzzyKMeansClusterer transformer = - new FuzzyKMeansClusterer<>(1, 2.0); + new FuzzyKMeansClusterer(1, 2.0); final List> clusters = transformer.cluster(points); Assert.assertEquals(1, clusters.size()); @@ -123,14 +123,14 @@ public void testSingleCluster() { @Test public void testClusterCenterEqualsPoints() { - final List points = new ArrayList<>(); + final List points = new ArrayList(); points.add(new DoublePoint(new double[] { 1, 1 })); points.add(new DoublePoint(new double[] { 1.00001, 1.00001 })); points.add(new DoublePoint(new double[] { 2, 2 })); points.add(new DoublePoint(new double[] { 3, 3 })); final FuzzyKMeansClusterer transformer = - new FuzzyKMeansClusterer<>(3, 2.0); + new FuzzyKMeansClusterer(3, 2.0); final List> clusters = transformer.cluster(points); Assert.assertEquals(3, clusters.size()); diff --git a/src/test/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClustererTest.java b/src/test/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClustererTest.java index 56f262d55e..39ef2c53f4 100644 --- a/src/test/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClustererTest.java +++ b/src/test/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClustererTest.java @@ -52,7 +52,7 @@ public void setUp() { @Test public void testPerformClusterAnalysisDegenerate() { KMeansPlusPlusClusterer transformer = - new KMeansPlusPlusClusterer<>(1, 1); + new KMeansPlusPlusClusterer(1, 1); DoublePoint[] points = new DoublePoint[] { new DoublePoint(new int[] { 1959, 325100 }), @@ -102,7 +102,7 @@ public void testCertainSpace() { for (int n = 2; n < 27; ++n) { KMeansPlusPlusClusterer transformer = - new KMeansPlusPlusClusterer<>(n, 100, new EuclideanDistance(), random, strategy); + new KMeansPlusPlusClusterer(n, 100, new EuclideanDistance(), random, strategy); List> clusters = transformer.cluster(Arrays.asList(breakingPoints)); @@ -143,7 +143,7 @@ public void testSmallDistances() { DoublePoint repeatedPoint = new DoublePoint(repeatedArray); DoublePoint uniquePoint = new DoublePoint(uniqueArray); - Collection points = new ArrayList<>(); + Collection points = new ArrayList(); final int NUM_REPEATED_POINTS = 10 * 1000; for (int i = 0; i < NUM_REPEATED_POINTS; ++i) { points.add(repeatedPoint); @@ -158,7 +158,7 @@ public void testSmallDistances() { random.setSeed(RANDOM_SEED); KMeansPlusPlusClusterer clusterer = - new KMeansPlusPlusClusterer<>(NUM_CLUSTERS, NUM_ITERATIONS, + new KMeansPlusPlusClusterer(NUM_CLUSTERS, NUM_ITERATIONS, new CloseDistance(), random); List> clusters = clusterer.cluster(points); @@ -178,7 +178,7 @@ public void testSmallDistances() { @Test(expected=NumberIsTooSmallException.class) public void testPerformClusterAnalysisToManyClusters() { KMeansPlusPlusClusterer transformer = - new KMeansPlusPlusClusterer<>(3, 1, new EuclideanDistance(), random); + new KMeansPlusPlusClusterer(3, 1, new EuclideanDistance(), random); DoublePoint[] points = new DoublePoint[] { new DoublePoint(new int[] { diff --git a/src/test/java/org/apache/commons/math4/ml/clustering/MultiKMeansPlusPlusClustererTest.java b/src/test/java/org/apache/commons/math4/ml/clustering/MultiKMeansPlusPlusClustererTest.java index 12816d7085..d7071129c3 100644 --- a/src/test/java/org/apache/commons/math4/ml/clustering/MultiKMeansPlusPlusClustererTest.java +++ b/src/test/java/org/apache/commons/math4/ml/clustering/MultiKMeansPlusPlusClustererTest.java @@ -34,7 +34,7 @@ public class MultiKMeansPlusPlusClustererTest { @Test public void dimension2() { MultiKMeansPlusPlusClusterer transformer = - new MultiKMeansPlusPlusClusterer<>( + new MultiKMeansPlusPlusClusterer( new KMeansPlusPlusClusterer(3, 10), 5); DoublePoint[] points = new DoublePoint[] { diff --git a/src/test/java/org/apache/commons/math4/ml/clustering/evaluation/SumOfClusterVariancesTest.java b/src/test/java/org/apache/commons/math4/ml/clustering/evaluation/SumOfClusterVariancesTest.java index 37c59a605f..0b20f8b05b 100644 --- a/src/test/java/org/apache/commons/math4/ml/clustering/evaluation/SumOfClusterVariancesTest.java +++ b/src/test/java/org/apache/commons/math4/ml/clustering/evaluation/SumOfClusterVariancesTest.java @@ -38,7 +38,7 @@ public class SumOfClusterVariancesTest { @Before public void setUp() { - evaluator = new SumOfClusterVariances<>(new EuclideanDistance()); + evaluator = new SumOfClusterVariances(new EuclideanDistance()); } @Test @@ -55,9 +55,9 @@ public void testScore() { new DoublePoint(new double[] { 10 }) }; - final List> clusters = new ArrayList<>(); + final List> clusters = new ArrayList>(); - final Cluster cluster1 = new Cluster<>(); + final Cluster cluster1 = new Cluster(); for (DoublePoint p : points1) { cluster1.addPoint(p); } @@ -65,7 +65,7 @@ public void testScore() { assertEquals(1.0/3.0, evaluator.score(clusters), 1e-6); - final Cluster cluster2 = new Cluster<>(); + final Cluster cluster2 = new Cluster(); for (DoublePoint p : points2) { cluster2.addPoint(p); } diff --git a/src/test/java/org/apache/commons/math4/ml/neuralnet/MapUtilsTest.java b/src/test/java/org/apache/commons/math4/ml/neuralnet/MapUtilsTest.java index 4404aacbc6..f716fc8d11 100644 --- a/src/test/java/org/apache/commons/math4/ml/neuralnet/MapUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/ml/neuralnet/MapUtilsTest.java @@ -49,8 +49,8 @@ public void testFindClosestNeuron() { final Network net = new NeuronString(3, false, initArray).getNetwork(); final DistanceMeasure dist = new EuclideanDistance(); - final Set allBest = new HashSet<>(); - final Set best = new HashSet<>(); + final Set allBest = new HashSet(); + final Set best = new HashSet(); double[][] features; // The following tests ensures that @@ -97,7 +97,7 @@ public void testFindClosestNeuron() { @Test public void testSort() { - final Set list = new HashSet<>(); + final Set list = new HashSet(); for (int i = 0; i < 4; i++) { list.add(new Neuron(i, new double[] { i - 0.5 })); diff --git a/src/test/java/org/apache/commons/math4/ml/neuralnet/oned/NeuronStringTest.java b/src/test/java/org/apache/commons/math4/ml/neuralnet/oned/NeuronStringTest.java index 5871956bbd..e7654fdc01 100644 --- a/src/test/java/org/apache/commons/math4/ml/neuralnet/oned/NeuronStringTest.java +++ b/src/test/java/org/apache/commons/math4/ml/neuralnet/oned/NeuronStringTest.java @@ -139,7 +139,7 @@ public void testCircleNetwork() { public void testGetNeighboursWithExclude() { final FeatureInitializer[] initArray = { init }; final Network net = new NeuronString(5, true, initArray).getNetwork(); - final Collection exclude = new ArrayList<>(); + final Collection exclude = new ArrayList(); exclude.add(net.getNeuron(1)); final Collection neighbours = net.getNeighbours(net.getNeuron(0), exclude); diff --git a/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenTrainingTaskTest.java b/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenTrainingTaskTest.java index 373a5bd902..dd669d58d2 100644 --- a/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenTrainingTaskTest.java +++ b/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/KohonenTrainingTaskTest.java @@ -112,7 +112,7 @@ public void testTravellerSalesmanSquareTourParallelSolver() throws ExecutionExce final ExecutorService service = Executors.newCachedThreadPool(); final int numProcs = Runtime.getRuntime().availableProcessors(); final Runnable[] tasks = solver.createParallelTasks(numProcs, 5000); - final List> execOutput = new ArrayList<>(); + final List> execOutput = new ArrayList>(); // Run tasks. for (Runnable r : tasks) { execOutput.add(service.submit(r)); @@ -165,7 +165,7 @@ private String travelCoordinatesTable(TravellingSalesmanSolver solver) { * @return the total distance. */ private Collection uniqueCities(City[] cityList) { - final Set unique = new HashSet<>(); + final Set unique = new HashSet(); for (City c : cityList) { unique.add(c); } diff --git a/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/TravellingSalesmanSolver.java b/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/TravellingSalesmanSolver.java index 37a9b2df24..fea0f162ba 100644 --- a/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/TravellingSalesmanSolver.java +++ b/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/TravellingSalesmanSolver.java @@ -58,7 +58,7 @@ public class TravellingSalesmanSolver { /** RNG. */ private final RandomGenerator random; /** Set of cities. */ - private final Set cities = new HashSet<>(); + private final Set cities = new HashSet(); /** SOFM. */ private final Network net; /** Distance function. */ @@ -176,7 +176,7 @@ private static double computeUpdateRatio(Network net) { * @return the iterator. */ private Iterator createRandomIterator(final long numSamples) { - final List cityList = new ArrayList<>(); + final List cityList = new ArrayList(); cityList.addAll(cities); return new Iterator() { @@ -204,7 +204,7 @@ public void remove() { */ private List getNeuronList() { // Sequence of coordinates. - final List list = new ArrayList<>(); + final List list = new ArrayList(); // First neuron. Neuron current = net.getNeuron(FIRST_NEURON_ID); @@ -230,7 +230,7 @@ private List getNeuronList() { */ public List getCoordinatesList() { // Sequence of coordinates. - final List coordinatesList = new ArrayList<>(); + final List coordinatesList = new ArrayList(); for (Neuron n : getNeuronList()) { coordinatesList.add(n.getFeatures()); diff --git a/src/test/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2DTest.java b/src/test/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2DTest.java index 833717514d..d233b24fb8 100644 --- a/src/test/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2DTest.java +++ b/src/test/java/org/apache/commons/math4/ml/neuralnet/twod/NeuronSquareMesh2DTest.java @@ -574,7 +574,7 @@ public void testConcentricNeighbourhood() { initArray).getNetwork(); Collection neighbours; - Collection exclude = new HashSet<>(); + Collection exclude = new HashSet(); // Level-1 neighbourhood. neighbours = net.getNeighbours(net.getNeuron(12)); @@ -623,7 +623,7 @@ public void testConcentricNeighbourhood2() { initArray).getNetwork(); Collection neighbours; - Collection exclude = new HashSet<>(); + Collection exclude = new HashSet(); // Level-1 neighbourhood. neighbours = net.getNeighbours(net.getNeuron(8)); @@ -854,13 +854,13 @@ public void testIterator() { 3, true, SquareNeighbourhood.VON_NEUMANN, initArray); - final Set fromMap = new HashSet<>(); + final Set fromMap = new HashSet(); for (Neuron n : map) { fromMap.add(n); } final Network net = map.getNetwork(); - final Set fromNet = new HashSet<>(); + final Set fromNet = new HashSet(); for (Neuron n : net) { fromNet.add(n); } diff --git a/src/test/java/org/apache/commons/math4/ode/ContinuousOutputFieldModelTest.java b/src/test/java/org/apache/commons/math4/ode/ContinuousOutputFieldModelTest.java index b50d0b9e45..870ee1e2f2 100644 --- a/src/test/java/org/apache/commons/math4/ode/ContinuousOutputFieldModelTest.java +++ b/src/test/java/org/apache/commons/math4/ode/ContinuousOutputFieldModelTest.java @@ -42,12 +42,12 @@ public void testBoundaries() { } private > void doTestBoundaries(final Field field) { - TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); + TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); - FirstOrderFieldIntegrator integ = new DormandPrince54FieldIntegrator<>(field, minStep, maxStep, 1.0e-8, 1.0e-8); + FirstOrderFieldIntegrator integ = new DormandPrince54FieldIntegrator(field, minStep, maxStep, 1.0e-8, 1.0e-8); integ.addStepHandler(new ContinuousOutputFieldModel()); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); ContinuousOutputFieldModel cm = (ContinuousOutputFieldModel) integ.getStepHandlers().iterator().next(); cm.getInterpolatedState(pb.getInitialState().getTime().multiply(2).subtract(pb.getFinalTime())); cm.getInterpolatedState(pb.getFinalTime().multiply(2).subtract(pb.getInitialState().getTime())); @@ -61,13 +61,13 @@ public void testRandomAccess() { private > void doTestRandomAccess(final Field field) { - TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); + TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); - FirstOrderFieldIntegrator integ = new DormandPrince54FieldIntegrator<>(field, minStep, maxStep, 1.0e-8, 1.0e-8); - ContinuousOutputFieldModel cm = new ContinuousOutputFieldModel<>(); + FirstOrderFieldIntegrator integ = new DormandPrince54FieldIntegrator(field, minStep, maxStep, 1.0e-8, 1.0e-8); + ContinuousOutputFieldModel cm = new ContinuousOutputFieldModel(); integ.addStepHandler(cm); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Random random = new Random(347588535632l); T maxError = field.getZero(); @@ -117,32 +117,32 @@ public void init(T t0, T[] y0, T finalTime) { }; // integrate backward from π to 0; - ContinuousOutputFieldModel cm1 = new ContinuousOutputFieldModel<>(); + ContinuousOutputFieldModel cm1 = new ContinuousOutputFieldModel(); FirstOrderFieldIntegrator integ1 = - new DormandPrince853FieldIntegrator<>(field, 0, 1.0, 1.0e-8, 1.0e-8); + new DormandPrince853FieldIntegrator(field, 0, 1.0, 1.0e-8, 1.0e-8); integ1.addStepHandler(cm1); T t0 = field.getZero().add(FastMath.PI); T[] y0 = MathArrays.buildArray(field, 2); y0[0] = field.getOne().negate(); y0[1] = field.getZero(); - integ1.integrate(new FieldExpandableODE<>(problem), - new FieldODEState<>(t0, y0), + integ1.integrate(new FieldExpandableODE(problem), + new FieldODEState(t0, y0), field.getZero()); // integrate backward from 2π to π - ContinuousOutputFieldModel cm2 = new ContinuousOutputFieldModel<>(); + ContinuousOutputFieldModel cm2 = new ContinuousOutputFieldModel(); FirstOrderFieldIntegrator integ2 = - new DormandPrince853FieldIntegrator<>(field, 0, 0.1, 1.0e-12, 1.0e-12); + new DormandPrince853FieldIntegrator(field, 0, 0.1, 1.0e-12, 1.0e-12); integ2.addStepHandler(cm2); t0 = field.getZero().add(2.0 * FastMath.PI); y0[0] = field.getOne(); y0[1] = field.getZero(); - integ2.integrate(new FieldExpandableODE<>(problem), - new FieldODEState<>(t0, y0), + integ2.integrate(new FieldExpandableODE(problem), + new FieldODEState(t0, y0), field.getZero().add(FastMath.PI)); // merge the two half circles - ContinuousOutputFieldModel cm = new ContinuousOutputFieldModel<>(); + ContinuousOutputFieldModel cm = new ContinuousOutputFieldModel(); cm.append(cm2); cm.append(new ContinuousOutputFieldModel()); cm.append(cm1); @@ -164,7 +164,7 @@ public void testErrorConditions() { } private > void doTestErrorConditions(final Field field) { - ContinuousOutputFieldModel cm = new ContinuousOutputFieldModel<>(); + ContinuousOutputFieldModel cm = new ContinuousOutputFieldModel(); cm.handleStep(buildInterpolator(field, 0, 1, new double[] { 0.0, 1.0, -2.0 }), true); // dimension mismatch @@ -184,7 +184,7 @@ private > void doTestErrorConditions(final Field> boolean checkAppendError(Field field, ContinuousOutputFieldModel cm, double t0, double t1, double[] y) { try { - ContinuousOutputFieldModel otherCm = new ContinuousOutputFieldModel<>(); + ContinuousOutputFieldModel otherCm = new ContinuousOutputFieldModel(); otherCm.handleStep(buildInterpolator(field, t0, t1, y), true); cm.append(otherCm); } catch(DimensionMismatchException dme) { @@ -201,9 +201,9 @@ private > FieldStepInterpolator buildInterpolat for (int i = 0; i < y.length; ++i) { fieldY[i] = field.getZero().add(y[i]); } - final FieldODEStateAndDerivative s0 = new FieldODEStateAndDerivative<>(field.getZero().add(t0), fieldY, fieldY); - final FieldODEStateAndDerivative s1 = new FieldODEStateAndDerivative<>(field.getZero().add(t1), fieldY, fieldY); - final FieldEquationsMapper mapper = new FieldExpandableODE<>(new FirstOrderFieldDifferentialEquations() { + final FieldODEStateAndDerivative s0 = new FieldODEStateAndDerivative(field.getZero().add(t0), fieldY, fieldY); + final FieldODEStateAndDerivative s1 = new FieldODEStateAndDerivative(field.getZero().add(t1), fieldY, fieldY); + final FieldEquationsMapper mapper = new FieldExpandableODE(new FirstOrderFieldDifferentialEquations() { public int getDimension() { return s0.getStateDimension(); } @@ -213,7 +213,7 @@ public T[] computeDerivatives(T t, T[] y) { return y; } }).getMapper(); - return new DummyFieldStepInterpolator<>(t1 >= t0, s0, s1, s0, s1, mapper); + return new DummyFieldStepInterpolator(t1 >= t0, s0, s1, s0, s1, mapper); } public void checkValue(double value, double reference) { diff --git a/src/test/java/org/apache/commons/math4/ode/FieldExpandableODETest.java b/src/test/java/org/apache/commons/math4/ode/FieldExpandableODETest.java index 20fc11f356..79070d03b6 100644 --- a/src/test/java/org/apache/commons/math4/ode/FieldExpandableODETest.java +++ b/src/test/java/org/apache/commons/math4/ode/FieldExpandableODETest.java @@ -39,8 +39,8 @@ public void testOnlyMainEquation() { } private > void doTestOnlyMainEquation(final Field field) { - FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE<>(main); + FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE(main); Assert.assertEquals(main.getDimension(), equation.getMapper().getTotalDimension()); Assert.assertEquals(1, equation.getMapper().getNumberOfEquations()); T t0 = field.getZero().add(10); @@ -70,11 +70,11 @@ public void testMainAndSecondary() { private > void doTestMainAndSecondary(final Field field) { - FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE<>(main); - FieldSecondaryEquations secondary1 = new Linear<>(field, 3, main.getDimension()); + FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE(main); + FieldSecondaryEquations secondary1 = new Linear(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); - FieldSecondaryEquations secondary2 = new Linear<>(field, 5, main.getDimension() + secondary1.getDimension()); + FieldSecondaryEquations secondary2 = new Linear(field, 5, main.getDimension() + secondary1.getDimension()); int i2 = equation.addSecondaryEquations(secondary2); Assert.assertEquals(main.getDimension() + secondary1.getDimension() + secondary2.getDimension(), equation.getMapper().getTotalDimension()); @@ -127,11 +127,11 @@ public void testMap() { private > void doTestMap(final Field field) { - FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE<>(main); - FieldSecondaryEquations secondary1 = new Linear<>(field, 3, main.getDimension()); + FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE(main); + FieldSecondaryEquations secondary1 = new Linear(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); - FieldSecondaryEquations secondary2 = new Linear<>(field, 5, main.getDimension() + secondary1.getDimension()); + FieldSecondaryEquations secondary2 = new Linear(field, 5, main.getDimension() + secondary1.getDimension()); int i2 = equation.addSecondaryEquations(secondary2); Assert.assertEquals(main.getDimension() + secondary1.getDimension() + secondary2.getDimension(), equation.getMapper().getTotalDimension()); @@ -215,9 +215,9 @@ public void testExtractDimensionMismatch() { private > void doTestExtractDimensionMismatch(final Field field) throws DimensionMismatchException { - FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE<>(main); - FieldSecondaryEquations secondary1 = new Linear<>(field, 3, main.getDimension()); + FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE(main); + FieldSecondaryEquations secondary1 = new Linear(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); T[] tooShort = MathArrays.buildArray(field, main.getDimension()); equation.getMapper().extractEquationData(i1, tooShort); @@ -231,9 +231,9 @@ public void testInsertTooShortComplete() { private > void doTestInsertTooShortComplete(final Field field) throws DimensionMismatchException { - FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE<>(main); - FieldSecondaryEquations secondary1 = new Linear<>(field, 3, main.getDimension()); + FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE(main); + FieldSecondaryEquations secondary1 = new Linear(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); T[] equationData = MathArrays.buildArray(field, secondary1.getDimension()); T[] tooShort = MathArrays.buildArray(field, main.getDimension()); @@ -248,9 +248,9 @@ public void testInsertWrongEquationData() { private > void doTestInsertWrongEquationData(final Field field) throws DimensionMismatchException { - FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE<>(main); - FieldSecondaryEquations secondary1 = new Linear<>(field, 3, main.getDimension()); + FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE(main); + FieldSecondaryEquations secondary1 = new Linear(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); T[] wrongEquationData = MathArrays.buildArray(field, secondary1.getDimension() + 1); T[] complete = MathArrays.buildArray(field, equation.getMapper().getTotalDimension()); @@ -265,8 +265,8 @@ public void testNegativeIndex() { private > void doTestNegativeIndex(final Field field) throws MathIllegalArgumentException { - FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE<>(main); + FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE(main); T[] complete = MathArrays.buildArray(field, equation.getMapper().getTotalDimension()); equation.getMapper().extractEquationData(-1, complete); } @@ -279,8 +279,8 @@ public void testTooLargeIndex() { private > void doTestTooLargeIndex(final Field field) throws MathIllegalArgumentException { - FirstOrderFieldDifferentialEquations main = new Linear<>(field, 3, 0); - FieldExpandableODE equation = new FieldExpandableODE<>(main); + FirstOrderFieldDifferentialEquations main = new Linear(field, 3, 0); + FieldExpandableODE equation = new FieldExpandableODE(main); T[] complete = MathArrays.buildArray(field, equation.getMapper().getTotalDimension()); equation.getMapper().extractEquationData(+1, complete); } diff --git a/src/test/java/org/apache/commons/math4/ode/TestFieldProblem4.java b/src/test/java/org/apache/commons/math4/ode/TestFieldProblem4.java index 01db18f6a6..cc797776e4 100644 --- a/src/test/java/org/apache/commons/math4/ode/TestFieldProblem4.java +++ b/src/test/java/org/apache/commons/math4/ode/TestFieldProblem4.java @@ -67,8 +67,8 @@ public FieldEventHandler[] getEventsHandlers() { @SuppressWarnings("unchecked") FieldEventHandler[] handlers = (FieldEventHandler[]) Array.newInstance(FieldEventHandler.class, 2); - handlers[0] = new Bounce<>(); - handlers[1] = new Stop<>(); + handlers[0] = new Bounce(); + handlers[1] = new Stop(); return handlers; } @@ -130,7 +130,7 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { T[] y = state.getState(); y[0] = y[0].negate(); y[1] = y[1].negate(); - return new FieldODEState<>(state.getTime(), y); + return new FieldODEState(state.getTime(), y); } } diff --git a/src/test/java/org/apache/commons/math4/ode/TestFieldProblemAbstract.java b/src/test/java/org/apache/commons/math4/ode/TestFieldProblemAbstract.java index cf404d677c..9d1b78b11c 100644 --- a/src/test/java/org/apache/commons/math4/ode/TestFieldProblemAbstract.java +++ b/src/test/java/org/apache/commons/math4/ode/TestFieldProblemAbstract.java @@ -114,7 +114,7 @@ public int getDimension() { * @return initial state */ public FieldODEState getInitialState() { - return new FieldODEState<>(t0, y0); + return new FieldODEState(t0, y0); } /** diff --git a/src/test/java/org/apache/commons/math4/ode/events/OverlappingEventsTest.java b/src/test/java/org/apache/commons/math4/ode/events/OverlappingEventsTest.java index 38f1cf33e1..e489e4e22b 100644 --- a/src/test/java/org/apache/commons/math4/ode/events/OverlappingEventsTest.java +++ b/src/test/java/org/apache/commons/math4/ode/events/OverlappingEventsTest.java @@ -90,8 +90,8 @@ public void test(int eventType) double t = 0.0; double tEnd = 10.0; double[] y = {0.0, 0.0}; - List events1 = new ArrayList<>(); - List events2 = new ArrayList<>(); + List events1 = new ArrayList(); + List events2 = new ArrayList(); while (t < tEnd) { t = integrator.integrate(this, t, y, tEnd, y); //System.out.println("t=" + t + ",\t\ty=[" + y[0] + "," + y[1] + "]"); diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java index aceede07eb..61372f51e8 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java @@ -152,8 +152,8 @@ public T[] computeDerivatives(T t, T[] y) { EmbeddedRungeKuttaFieldIntegrator integrator = createIntegrator(field, 0.0, 1.0, 1.0e-10, 1.0e-10); try { - integrator.integrate(new FieldExpandableODE<>(equations), - new FieldODEState<>(field.getOne().negate(), + integrator.integrate(new FieldExpandableODE(equations), + new FieldODEState(field.getOne().negate(), MathArrays.buildArray(field, 1)), field.getZero()); Assert.fail("an exception should have been thrown"); @@ -162,8 +162,8 @@ public T[] computeDerivatives(T t, T[] y) { } try { - integrator.integrate(new FieldExpandableODE<>(equations), - new FieldODEState<>(field.getZero(), + integrator.integrate(new FieldExpandableODE(equations), + new FieldODEState(field.getZero(), MathArrays.buildArray(field, 1)), field.getOne()); Assert.fail("an exception should have been thrown"); @@ -182,7 +182,7 @@ protected static class LocalException extends RuntimeException { protected > void doTestMinStep(final Field field) throws NumberIsTooSmallException { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); + TestFieldProblem1 pb = new TestFieldProblem1(field); double minStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.1).getReal(); double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double[] vecAbsoluteTolerance = { 1.0e-15, 1.0e-16 }; @@ -190,9 +190,9 @@ protected > void doTestMinStep(final Field fiel FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); } @@ -206,7 +206,7 @@ protected > void doTestIncreasingTolerance(final F int previousCalls = Integer.MAX_VALUE; for (int i = -12; i < -2; ++i) { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); + TestFieldProblem1 pb = new TestFieldProblem1(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = FastMath.pow(10.0, i); @@ -214,9 +214,9 @@ protected > void doTestIncreasingTolerance(final F FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertTrue(handler.getMaximalValueError().getReal() < (factor * scalAbsoluteTolerance)); Assert.assertEquals(0, handler.getMaximalTimeError().getReal(), epsilon); @@ -237,7 +237,7 @@ protected > void doTestEvents(final Field field final double epsilonMaxValue, final String name) { - TestFieldProblem4 pb = new TestFieldProblem4<>(field); + TestFieldProblem4 pb = new TestFieldProblem4(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -245,7 +245,7 @@ protected > void doTestEvents(final Field field FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); FieldEventHandler[] functions = pb.getEventsHandlers(); double convergence = 1.0e-8 * maxStep; @@ -253,7 +253,7 @@ protected > void doTestEvents(final Field field integ.addEventHandler(functions[l], Double.POSITIVE_INFINITY, convergence, 1000); } Assert.assertEquals(functions.length, integ.getEventHandlers().size()); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); Assert.assertEquals(0, handler.getMaximalTimeError().getReal(), convergence); @@ -269,7 +269,7 @@ protected > void doTestEvents(final Field field protected > void doTestEventsErrors(final Field field) throws LocalException { - final TestFieldProblem1 pb = new TestFieldProblem1<>(field); + final TestFieldProblem1 pb = new TestFieldProblem1(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -277,7 +277,7 @@ protected > void doTestEventsErrors(final Field FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); integ.addEventHandler(new FieldEventHandler() { @@ -299,7 +299,7 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { } }, Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); } @@ -308,7 +308,7 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { protected > void doTestEventsNoConvergence(final Field field){ - final TestFieldProblem1 pb = new TestFieldProblem1<>(field); + final TestFieldProblem1 pb = new TestFieldProblem1(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -316,7 +316,7 @@ protected > void doTestEventsNoConvergence(final F FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); integ.addEventHandler(new FieldEventHandler() { @@ -336,7 +336,7 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { }, Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 3); try { - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); } catch (MaxCountExceededException mcee) { // Expected. @@ -348,13 +348,13 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { public abstract void testSanityChecks(); protected > void doTestSanityChecks(Field field) { - TestFieldProblem3 pb = new TestFieldProblem3<>(field); + TestFieldProblem3 pb = new TestFieldProblem3(field); try { EmbeddedRungeKuttaFieldIntegrator integrator = createIntegrator(field, 0, pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(), new double[4], new double[4]); - integrator.integrate(new FieldExpandableODE<>(pb), - new FieldODEState<>(pb.getInitialState().getTime(), + integrator.integrate(new FieldExpandableODE(pb), + new FieldODEState(pb.getInitialState().getTime(), MathArrays.buildArray(field, 6)), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); @@ -365,7 +365,7 @@ protected > void doTestSanityChecks(Field field createIntegrator(field, 0, pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(), new double[2], new double[4]); - integrator.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integrator.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); } catch(DimensionMismatchException ie) { } @@ -374,7 +374,7 @@ protected > void doTestSanityChecks(Field field createIntegrator(field, 0, pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(), new double[4], new double[4]); - integrator.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getInitialState().getTime()); + integrator.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getInitialState().getTime()); Assert.fail("an exception should have been thrown"); } catch(NumberIsTooSmallException ie) { } @@ -391,7 +391,7 @@ protected > void doTestBackward(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem5 pb = new TestFieldProblem5<>(field); + TestFieldProblem5 pb = new TestFieldProblem5(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).abs().getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -400,9 +400,9 @@ protected > void doTestBackward(Field field, EmbeddedRungeKuttaFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getLastError().getReal(), epsilonLast); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); @@ -416,7 +416,7 @@ protected > void doTestBackward(Field field, protected > void doTestKepler(Field field, double epsilon) { - final TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); + final TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double[] vecAbsoluteTolerance = { 1.0e-8, 1.0e-8, 1.0e-10, 1.0e-10 }; @@ -424,8 +424,8 @@ protected > void doTestKepler(Field field, doub FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); - integ.addStepHandler(new KeplerHandler<>(pb, epsilon)); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.addStepHandler(new KeplerHandler(pb, epsilon)); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); } private static class KeplerHandler> implements FieldStepHandler { @@ -486,8 +486,8 @@ protected > void doTestPartialDerivatives(final do t.subtract(t0).multiply(0.001).getReal(), t.subtract(t0).getReal(), 1.0e-12, 1.0e-12); FieldODEStateAndDerivative result = - integrator.integrate(new FieldExpandableODE<>(sinCos), - new FieldODEState<>(t0, y0), + integrator.integrate(new FieldExpandableODE(sinCos), + new FieldODEState(t0, y0), t); // check values diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java index 80b682856f..d79a19f150 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java @@ -151,8 +151,8 @@ public T[] computeDerivatives(T t, T[] y) { y0[i] = field.getOne().add(i); } - FieldODEStateAndDerivative result = integrator.integrate(new FieldExpandableODE<>(ode), - new FieldODEState<>(t0, y0), + FieldODEStateAndDerivative result = integrator.integrate(new FieldExpandableODE(ode), + new FieldODEState(t0, y0), tEvent); Assert.assertEquals(tEvent.getReal(), result.getTime().getReal(), epsilonT); T[] y = result.getState(); @@ -180,8 +180,8 @@ public Action eventOccurred(FieldODEStateAndDerivative state, boolean increas return Action.CONTINUE; } }, Double.POSITIVE_INFINITY, 1.0e-20, 100); - result = integrator.integrate(new FieldExpandableODE<>(ode), - new FieldODEState<>(t0, y0), + result = integrator.integrate(new FieldExpandableODE(ode), + new FieldODEState(t0, y0), tEvent.add(120)); Assert.assertEquals(tEvent.add(120).getReal(), result.getTime().getReal(), epsilonT); y = result.getState(); @@ -201,17 +201,17 @@ protected > void doTestSanityChecks(Field field MaxCountExceededException, NoBracketingException { RungeKuttaFieldIntegrator integrator = createIntegrator(field, field.getZero().add(0.01)); try { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); - integrator.integrate(new FieldExpandableODE<>(pb), - new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, pb.getDimension() + 10)), + TestFieldProblem1 pb = new TestFieldProblem1(field); + integrator.integrate(new FieldExpandableODE(pb), + new FieldODEState(field.getZero(), MathArrays.buildArray(field, pb.getDimension() + 10)), field.getOne()); Assert.fail("an exception should have been thrown"); } catch(DimensionMismatchException ie) { } try { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); - integrator.integrate(new FieldExpandableODE<>(pb), - new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, pb.getDimension())), + TestFieldProblem1 pb = new TestFieldProblem1(field); + integrator.integrate(new FieldExpandableODE(pb), + new FieldODEState(field.getZero(), MathArrays.buildArray(field, pb.getDimension())), field.getZero()); Assert.fail("an exception should have been thrown"); } catch(NumberIsTooSmallException ie) { @@ -231,12 +231,12 @@ protected > void doTestDecreasingSteps(Field fi @SuppressWarnings("unchecked") TestFieldProblemAbstract[] allProblems = (TestFieldProblemAbstract[]) Array.newInstance(TestFieldProblemAbstract.class, 6); - allProblems[0] = new TestFieldProblem1<>(field); - allProblems[1] = new TestFieldProblem2<>(field); - allProblems[2] = new TestFieldProblem3<>(field); - allProblems[3] = new TestFieldProblem4<>(field); - allProblems[4] = new TestFieldProblem5<>(field); - allProblems[5] = new TestFieldProblem6<>(field); + allProblems[0] = new TestFieldProblem1(field); + allProblems[1] = new TestFieldProblem2(field); + allProblems[2] = new TestFieldProblem3(field); + allProblems[3] = new TestFieldProblem4(field); + allProblems[4] = new TestFieldProblem5(field); + allProblems[5] = new TestFieldProblem6(field); for (TestFieldProblemAbstract pb : allProblems) { T previousValueError = null; @@ -246,7 +246,7 @@ protected > void doTestDecreasingSteps(Field fi T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(FastMath.pow(2.0, -i)); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); FieldEventHandler[] functions = pb.getEventsHandlers(); for (int l = 0; l < functions.length; ++l) { @@ -254,7 +254,7 @@ protected > void doTestDecreasingSteps(Field fi Double.POSITIVE_INFINITY, 1.0e-6 * step.getReal(), 1000); } Assert.assertEquals(functions.length, integ.getEventHandlers().size()); - FieldODEStateAndDerivative stop = integ.integrate(new FieldExpandableODE<>(pb), + FieldODEStateAndDerivative stop = integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); if (functions.length == 0) { @@ -292,13 +292,13 @@ protected > void doTestSmallStep(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); + TestFieldProblem1 pb = new TestFieldProblem1(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.001); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getLastError().getReal(), epsilonLast); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); @@ -318,13 +318,13 @@ protected > void doTestBigStep(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); + TestFieldProblem1 pb = new TestFieldProblem1(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.2); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertTrue(handler.getLastError().getReal() > belowLast); Assert.assertTrue(handler.getMaximalValueError().getReal() > belowMaxValue); @@ -344,13 +344,13 @@ protected > void doTestBackward(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem5 pb = new TestFieldProblem5<>(field); + TestFieldProblem5 pb = new TestFieldProblem5(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.001).abs(); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getLastError().getReal(), epsilonLast); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); @@ -366,12 +366,12 @@ protected > void doTestKepler(Field field, doub throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - final TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); + final TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.0003); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - integ.addStepHandler(new KeplerHandler<>(pb, expectedMaxError, epsilon)); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.addStepHandler(new KeplerHandler(pb, expectedMaxError, epsilon)); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); } private static class KeplerHandler> implements FieldStepHandler { @@ -424,7 +424,7 @@ public void handleStep(FieldStepInterpolator interpolator, boolean isLast) { public void init(FieldODEStateAndDerivative s0, T t) { } }); - integ.integrate(new FieldExpandableODE<>(new FirstOrderFieldDifferentialEquations() { + integ.integrate(new FieldExpandableODE(new FirstOrderFieldDifferentialEquations() { public void init(T t0, T[] y0, T t) { } public T[] computeDerivatives(T t, T[] y) { @@ -435,7 +435,7 @@ public T[] computeDerivatives(T t, T[] y) { public int getDimension() { return 1; } - }), new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, 1)), field.getZero().add(5.0)); + }), new FieldODEState(field.getZero(), MathArrays.buildArray(field, 1)), field.getZero().add(5.0)); } @Test @@ -443,7 +443,7 @@ public int getDimension() { protected > void doTestSingleStep(final Field field, final double epsilon) { - final TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); + final TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); T h = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.0003); RungeKuttaFieldIntegrator integ = createIntegrator(field, field.getZero().add(Double.NaN)); @@ -489,7 +489,7 @@ public T[] computeDerivatives(T t, T[] y) { }; - integ.integrate(new FieldExpandableODE<>(equations), new FieldODEState<>(t0, y0), t); + integ.integrate(new FieldExpandableODE(equations), new FieldODEState(t0, y0), t); } @@ -497,14 +497,14 @@ public T[] computeDerivatives(T t, T[] y) { public abstract void testUnstableDerivative(); protected > void doTestUnstableDerivative(Field field, double epsilon) { - final StepFieldProblem stepProblem = new StepFieldProblem<>(field, + final StepFieldProblem stepProblem = new StepFieldProblem(field, field.getZero().add(0.0), field.getZero().add(1.0), field.getZero().add(2.0)); RungeKuttaFieldIntegrator integ = createIntegrator(field, field.getZero().add(0.3)); integ.addEventHandler(stepProblem, 1.0, 1.0e-12, 1000); - FieldODEStateAndDerivative result = integ.integrate(new FieldExpandableODE<>(stepProblem), - new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, 1)), + FieldODEStateAndDerivative result = integ.integrate(new FieldExpandableODE(stepProblem), + new FieldODEState(field.getZero(), MathArrays.buildArray(field, 1)), field.getZero().add(10.0)); Assert.assertEquals(8.0, result.getState()[0].getReal(), epsilon); } @@ -513,7 +513,7 @@ protected > void doTestUnstableDerivative(Field public abstract void testDerivativesConsistency(); protected > void doTestDerivativesConsistency(final Field field, double epsilon) { - TestFieldProblem3 pb = new TestFieldProblem3<>(field); + TestFieldProblem3 pb = new TestFieldProblem3(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.001); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); StepInterpolatorTestUtils.checkDerivativesConsistency(integ, pb, 1.0e-10); @@ -546,8 +546,8 @@ protected > void doTestPartialDerivatives(final do RungeKuttaFieldIntegrator integrator = createIntegrator(omega.getField(), t.subtract(t0).multiply(0.001)); FieldODEStateAndDerivative result = - integrator.integrate(new FieldExpandableODE<>(sinCos), - new FieldODEState<>(t0, y0), + integrator.integrate(new FieldExpandableODE(sinCos), + new FieldODEState(t0, y0), t); // check values diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegratorTest.java index 15d05a8aac..ed69ccd69b 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsBashforthFieldIntegratorTest.java @@ -31,14 +31,14 @@ public class AdamsBashforthFieldIntegratorTest extends AdamsFieldIntegratorAbstr protected > AdamsFieldIntegrator createIntegrator(Field field, final int nSteps, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance) { - return new AdamsBashforthFieldIntegrator<>(field, nSteps, minStep, maxStep, + return new AdamsBashforthFieldIntegrator(field, nSteps, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); } protected > AdamsFieldIntegrator createIntegrator(Field field, final int nSteps, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) { - return new AdamsBashforthFieldIntegrator<>(field, nSteps, minStep, maxStep, + return new AdamsBashforthFieldIntegrator(field, nSteps, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); } diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldIntegratorAbstractTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldIntegratorAbstractTest.java index 1f786bcd83..340dd4888f 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldIntegratorAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsFieldIntegratorAbstractTest.java @@ -54,7 +54,7 @@ public abstract class AdamsFieldIntegratorAbstractTest { public abstract void testMinStep(); protected > void doDimensionCheck(final Field field) { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); + TestFieldProblem1 pb = new TestFieldProblem1(field); double minStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.1).getReal(); double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); @@ -64,9 +64,9 @@ protected > void doDimensionCheck(final Field f FirstOrderFieldIntegrator integ = createIntegrator(field, 4, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); } @@ -78,7 +78,7 @@ protected > void doTestIncreasingTolerance(final F int previousCalls = Integer.MAX_VALUE; for (int i = -12; i < -2; ++i) { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); + TestFieldProblem1 pb = new TestFieldProblem1(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = FastMath.pow(10.0, i); @@ -87,9 +87,9 @@ protected > void doTestIncreasingTolerance(final F FirstOrderFieldIntegrator integ = createIntegrator(field, 4, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertTrue(handler.getMaximalValueError().getReal() > ratioMin * scalAbsoluteTolerance); Assert.assertTrue(handler.getMaximalValueError().getReal() < ratioMax * scalAbsoluteTolerance); @@ -108,14 +108,14 @@ protected > void doTestIncreasingTolerance(final F protected > void doExceedMaxEvaluations(final Field field, final int max) { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); + TestFieldProblem1 pb = new TestFieldProblem1(field); double range = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); FirstOrderFieldIntegrator integ = createIntegrator(field, 2, 0, range, 1.0e-12, 1.0e-12); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); integ.setMaxEvaluations(max); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); } @@ -128,13 +128,13 @@ protected > void doBackward(final Field field, final double epsilonMaxTime, final String name) { - TestFieldProblem5 pb = new TestFieldProblem5<>(field); + TestFieldProblem5 pb = new TestFieldProblem5(field); double range = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); AdamsFieldIntegrator integ = createIntegrator(field, 4, 0, range, 1.0e-12, 1.0e-12); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0.0, handler.getLastError().getReal(), epsilonLast); Assert.assertEquals(0.0, handler.getMaximalValueError().getReal(), epsilonMaxValue); @@ -149,15 +149,15 @@ protected > void doPolynomial(final Field field final int nLimit, final double epsilonBad, final double epsilonGood) { - TestFieldProblem6 pb = new TestFieldProblem6<>(field); + TestFieldProblem6 pb = new TestFieldProblem6(field); double range = pb.getFinalTime().subtract(pb.getInitialState().getTime()).abs().getReal(); for (int nSteps = 2; nSteps < 8; ++nSteps) { AdamsFieldIntegrator integ = createIntegrator(field, nSteps, 1.0e-6 * range, 0.1 * range, 1.0e-4, 1.0e-4); - integ.setStarterIntegrator(new PerfectStarter<>(pb, nSteps)); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + integ.setStarterIntegrator(new PerfectStarter(pb, nSteps)); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); if (nSteps < nLimit) { Assert.assertTrue(handler.getMaximalValueError().getReal() > epsilonBad); } else { @@ -171,7 +171,7 @@ protected > void doPolynomial(final Field field public abstract void testStartFailure(); protected > void doTestStartFailure(final Field field) { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); + TestFieldProblem1 pb = new TestFieldProblem1(field); double minStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.0001).getReal(); double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = 1.0e-6; @@ -180,10 +180,10 @@ protected > void doTestStartFailure(final Field MultistepFieldIntegrator integ = createIntegrator(field, 6, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - integ.setStarterIntegrator(new DormandPrince853FieldIntegrator<>(field, maxStep * 0.5, maxStep, 0.1, 0.1)); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + integ.setStarterIntegrator(new DormandPrince853FieldIntegrator(field, maxStep * 0.5, maxStep, 0.1, 0.1)); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); } @@ -194,7 +194,7 @@ private static class PerfectStarter> extends Abstr public PerfectStarter(final TestFieldProblemAbstract problem, final int nbSteps) { super(problem.getField(), "perfect-starter"); - this.interpolator = new PerfectInterpolator<>(problem); + this.interpolator = new PerfectInterpolator(problem); this.nbSteps = nbSteps; } @@ -252,7 +252,7 @@ public FieldODEStateAndDerivative getCurrentState() { public FieldODEStateAndDerivative getInterpolatedState(T time) { T[] y = problem.computeTheoreticalState(time); T[] yDot = problem.computeDerivatives(time, y); - return new FieldODEStateAndDerivative<>(time, y, yDot); + return new FieldODEStateAndDerivative(time, y, yDot); } } diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegratorTest.java index 84a0f7d24d..51eb7efda4 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/AdamsMoultonFieldIntegratorTest.java @@ -31,14 +31,14 @@ public class AdamsMoultonFieldIntegratorTest extends AdamsFieldIntegratorAbstrac protected > AdamsFieldIntegrator createIntegrator(Field field, final int nSteps, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance) { - return new AdamsMoultonFieldIntegrator<>(field, nSteps, minStep, maxStep, + return new AdamsMoultonFieldIntegrator(field, nSteps, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); } protected > AdamsFieldIntegrator createIntegrator(Field field, final int nSteps, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) { - return new AdamsMoultonFieldIntegrator<>(field, nSteps, minStep, maxStep, + return new AdamsMoultonFieldIntegrator(field, nSteps, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); } diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungKuttaFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungKuttaFieldStepInterpolatorTest.java index f484baacb9..bbe30c2ccf 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungKuttaFieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungKuttaFieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class ClassicalRungKuttaFieldStepInterpolatorTest extends RungeKuttaField FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new ClassicalRungeKuttaFieldStepInterpolator<>(field, forward, yDotK, + return new ClassicalRungeKuttaFieldStepInterpolator(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class ClassicalRungKuttaFieldStepInterpolatorTest extends RungeKuttaField protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new ClassicalRungeKuttaFieldIntegrator<>(field, field.getOne()); + return new ClassicalRungeKuttaFieldIntegrator(field, field.getOne()); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegratorTest.java index ebc996256d..3cd0e3558e 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegratorTest.java @@ -26,7 +26,7 @@ public class ClassicalRungeKuttaFieldIntegratorTest extends RungeKuttaFieldInteg protected > RungeKuttaFieldIntegrator createIntegrator(Field field, T step) { - return new ClassicalRungeKuttaFieldIntegrator<>(field, step); + return new ClassicalRungeKuttaFieldIntegrator(field, step); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegratorTest.java index 28267e0457..da908035b2 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegratorTest.java @@ -27,13 +27,13 @@ public class DormandPrince54FieldIntegratorTest extends EmbeddedRungeKuttaFieldI protected > EmbeddedRungeKuttaFieldIntegrator createIntegrator(Field field, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance) { - return new DormandPrince54FieldIntegrator<>(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); + return new DormandPrince54FieldIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); } protected > EmbeddedRungeKuttaFieldIntegrator createIntegrator(Field field, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) { - return new DormandPrince54FieldIntegrator<>(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); + return new DormandPrince54FieldIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolatorTest.java index b10501fb87..9b6d607078 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class DormandPrince54FieldStepInterpolatorTest extends RungeKuttaFieldSte FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new DormandPrince54FieldStepInterpolator<>(field, forward, yDotK, + return new DormandPrince54FieldStepInterpolator(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class DormandPrince54FieldStepInterpolatorTest extends RungeKuttaFieldSte protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new DormandPrince54FieldIntegrator<>(field, 0, 1, 1, 1); + return new DormandPrince54FieldIntegrator(field, 0, 1, 1, 1); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegratorTest.java index 258ccc7d74..bc73968059 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegratorTest.java @@ -27,13 +27,13 @@ public class DormandPrince853FieldIntegratorTest extends EmbeddedRungeKuttaField protected > EmbeddedRungeKuttaFieldIntegrator createIntegrator(Field field, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance) { - return new DormandPrince853FieldIntegrator<>(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); + return new DormandPrince853FieldIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); } protected > EmbeddedRungeKuttaFieldIntegrator createIntegrator(Field field, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) { - return new DormandPrince853FieldIntegrator<>(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); + return new DormandPrince853FieldIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolatorTest.java index 69dbec4a9b..5591b4d8df 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class DormandPrince853FieldStepInterpolatorTest extends RungeKuttaFieldSt FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new DormandPrince853FieldStepInterpolator<>(field, forward, yDotK, + return new DormandPrince853FieldStepInterpolator(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class DormandPrince853FieldStepInterpolatorTest extends RungeKuttaFieldSt protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new DormandPrince853FieldIntegrator<>(field, 0, 1, 1, 1); + return new DormandPrince853FieldIntegrator(field, 0, 1, 1, 1); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java index edb9501284..045e77de7e 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java @@ -152,8 +152,8 @@ public T[] computeDerivatives(T t, T[] y) { EmbeddedRungeKuttaFieldIntegrator integrator = createIntegrator(field, 0.0, 1.0, 1.0e-10, 1.0e-10); try { - integrator.integrate(new FieldExpandableODE<>(equations), - new FieldODEState<>(field.getOne().negate(), + integrator.integrate(new FieldExpandableODE(equations), + new FieldODEState(field.getOne().negate(), MathArrays.buildArray(field, 1)), field.getZero()); Assert.fail("an exception should have been thrown"); @@ -162,8 +162,8 @@ public T[] computeDerivatives(T t, T[] y) { } try { - integrator.integrate(new FieldExpandableODE<>(equations), - new FieldODEState<>(field.getZero(), + integrator.integrate(new FieldExpandableODE(equations), + new FieldODEState(field.getZero(), MathArrays.buildArray(field, 1)), field.getOne()); Assert.fail("an exception should have been thrown"); @@ -182,7 +182,7 @@ protected static class LocalException extends RuntimeException { protected > void doTestMinStep(final Field field) throws NumberIsTooSmallException { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); + TestFieldProblem1 pb = new TestFieldProblem1(field); double minStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.1).getReal(); double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double[] vecAbsoluteTolerance = { 1.0e-15, 1.0e-16 }; @@ -190,9 +190,9 @@ protected > void doTestMinStep(final Field fiel FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); } @@ -206,7 +206,7 @@ protected > void doTestIncreasingTolerance(final F int previousCalls = Integer.MAX_VALUE; for (int i = -12; i < -2; ++i) { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); + TestFieldProblem1 pb = new TestFieldProblem1(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = FastMath.pow(10.0, i); @@ -214,9 +214,9 @@ protected > void doTestIncreasingTolerance(final F FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertTrue(handler.getMaximalValueError().getReal() < (factor * scalAbsoluteTolerance)); Assert.assertEquals(0, handler.getMaximalTimeError().getReal(), epsilon); @@ -237,7 +237,7 @@ protected > void doTestEvents(final Field field final double epsilonMaxValue, final String name) { - TestFieldProblem4 pb = new TestFieldProblem4<>(field); + TestFieldProblem4 pb = new TestFieldProblem4(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -245,7 +245,7 @@ protected > void doTestEvents(final Field field FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); FieldEventHandler[] functions = pb.getEventsHandlers(); double convergence = 1.0e-8 * maxStep; @@ -253,7 +253,7 @@ protected > void doTestEvents(final Field field integ.addEventHandler(functions[l], Double.POSITIVE_INFINITY, convergence, 1000); } Assert.assertEquals(functions.length, integ.getEventHandlers().size()); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); Assert.assertEquals(0, handler.getMaximalTimeError().getReal(), convergence); @@ -269,7 +269,7 @@ protected > void doTestEvents(final Field field protected > void doTestEventsErrors(final Field field) throws LocalException { - final TestFieldProblem1 pb = new TestFieldProblem1<>(field); + final TestFieldProblem1 pb = new TestFieldProblem1(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -277,7 +277,7 @@ protected > void doTestEventsErrors(final Field FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); integ.addEventHandler(new FieldEventHandler() { @@ -299,7 +299,7 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { } }, Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); } @@ -308,7 +308,7 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { protected > void doTestEventsNoConvergence(final Field field){ - final TestFieldProblem1 pb = new TestFieldProblem1<>(field); + final TestFieldProblem1 pb = new TestFieldProblem1(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -316,7 +316,7 @@ protected > void doTestEventsNoConvergence(final F FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); integ.addEventHandler(new FieldEventHandler() { @@ -336,7 +336,7 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { }, Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 3); try { - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); } catch (MaxCountExceededException mcee) { // Expected. @@ -348,13 +348,13 @@ public FieldODEState resetState(FieldODEStateAndDerivative state) { public abstract void testSanityChecks(); protected > void doTestSanityChecks(Field field) { - TestFieldProblem3 pb = new TestFieldProblem3<>(field); + TestFieldProblem3 pb = new TestFieldProblem3(field); try { EmbeddedRungeKuttaFieldIntegrator integrator = createIntegrator(field, 0, pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(), new double[4], new double[4]); - integrator.integrate(new FieldExpandableODE<>(pb), - new FieldODEState<>(pb.getInitialState().getTime(), + integrator.integrate(new FieldExpandableODE(pb), + new FieldODEState(pb.getInitialState().getTime(), MathArrays.buildArray(field, 6)), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); @@ -365,7 +365,7 @@ protected > void doTestSanityChecks(Field field createIntegrator(field, 0, pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(), new double[2], new double[4]); - integrator.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integrator.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.fail("an exception should have been thrown"); } catch(DimensionMismatchException ie) { } @@ -374,7 +374,7 @@ protected > void doTestSanityChecks(Field field createIntegrator(field, 0, pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(), new double[4], new double[4]); - integrator.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getInitialState().getTime()); + integrator.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getInitialState().getTime()); Assert.fail("an exception should have been thrown"); } catch(NumberIsTooSmallException ie) { } @@ -391,7 +391,7 @@ protected > void doTestBackward(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem5 pb = new TestFieldProblem5<>(field); + TestFieldProblem5 pb = new TestFieldProblem5(field); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).abs().getReal(); double scalAbsoluteTolerance = 1.0e-8; @@ -400,9 +400,9 @@ protected > void doTestBackward(Field field, EmbeddedRungeKuttaFieldIntegrator integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getLastError().getReal(), epsilonLast); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); @@ -416,7 +416,7 @@ protected > void doTestBackward(Field field, protected > void doTestKepler(Field field, double epsilon) { - final TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); + final TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); double[] vecAbsoluteTolerance = { 1.0e-8, 1.0e-8, 1.0e-10, 1.0e-10 }; @@ -424,8 +424,8 @@ protected > void doTestKepler(Field field, doub FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); - integ.addStepHandler(new KeplerHandler<>(pb, epsilon)); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.addStepHandler(new KeplerHandler(pb, epsilon)); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); } private static class KeplerHandler> implements FieldStepHandler { @@ -486,8 +486,8 @@ protected void doTestPartialDerivatives(final double epsilonY, t.subtract(t0).multiply(0.001).getReal(), t.subtract(t0).getReal(), 1.0e-12, 1.0e-12); FieldODEStateAndDerivative result = - integrator.integrate(new FieldExpandableODE<>(sinCos), - new FieldODEState<>(t0, y0), + integrator.integrate(new FieldExpandableODE(sinCos), + new FieldODEState(t0, y0), t); // check values diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegratorTest.java index d492cab4c9..9a48986819 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegratorTest.java @@ -26,7 +26,7 @@ public class EulerFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstractT protected > RungeKuttaFieldIntegrator createIntegrator(Field field, T step) { - return new EulerFieldIntegrator<>(field, step); + return new EulerFieldIntegrator(field, step); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolatorTest.java index 9f7f1ffe6d..c5d1c3b727 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/EulerFieldStepInterpolatorTest.java @@ -33,7 +33,7 @@ public class EulerFieldStepInterpolatorTest extends RungeKuttaFieldStepInterpola FieldODEStateAndDerivative globalCurrentState, FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new EulerFieldStepInterpolator<>(field, forward, yDotK, + return new EulerFieldStepInterpolator(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -41,7 +41,7 @@ public class EulerFieldStepInterpolatorTest extends RungeKuttaFieldStepInterpola protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new EulerFieldIntegrator<>(field, field.getOne()); + return new EulerFieldIntegrator(field, field.getOne()); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegratorTest.java index 7100cbf952..877321beb5 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegratorTest.java @@ -26,7 +26,7 @@ public class GillFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstractTe protected > RungeKuttaFieldIntegrator createIntegrator(Field field, T step) { - return new GillFieldIntegrator<>(field, step); + return new GillFieldIntegrator(field, step); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolatorTest.java index 3c7d21c7eb..87a9b10cac 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/GillFieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class GillFieldStepInterpolatorTest extends RungeKuttaFieldStepInterpolat FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new GillFieldStepInterpolator<>(field, forward, yDotK, + return new GillFieldStepInterpolator(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class GillFieldStepInterpolatorTest extends RungeKuttaFieldStepInterpolat protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new GillFieldIntegrator<>(field, field.getOne()); + return new GillFieldIntegrator(field, field.getOne()); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegratorTest.java index 6263e7c037..0630fcc176 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegratorTest.java @@ -27,13 +27,13 @@ public class HighamHall54FieldIntegratorTest extends EmbeddedRungeKuttaFieldInte protected > EmbeddedRungeKuttaFieldIntegrator createIntegrator(Field field, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance) { - return new HighamHall54FieldIntegrator<>(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); + return new HighamHall54FieldIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); } protected > EmbeddedRungeKuttaFieldIntegrator createIntegrator(Field field, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) { - return new HighamHall54FieldIntegrator<>(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); + return new HighamHall54FieldIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolatorTest.java index 7559e98754..12c9473f16 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class HighamHall54FieldStepInterpolatorTest extends RungeKuttaFieldStepIn FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new HighamHall54FieldStepInterpolator<>(field, forward, yDotK, + return new HighamHall54FieldStepInterpolator(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class HighamHall54FieldStepInterpolatorTest extends RungeKuttaFieldStepIn protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new HighamHall54FieldIntegrator<>(field, 0, 1, 1, 1); + return new HighamHall54FieldIntegrator(field, 0, 1, 1, 1); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegratorTest.java index 31db1769c5..9f459cfe6e 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegratorTest.java @@ -30,7 +30,7 @@ public class LutherFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstract protected > RungeKuttaFieldIntegrator createIntegrator(Field field, T step) { - return new LutherFieldIntegrator<>(field, step); + return new LutherFieldIntegrator(field, step); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolatorTest.java index 1a0d5e2f0d..e35e1ecadf 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/LutherFieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class LutherFieldStepInterpolatorTest extends RungeKuttaFieldStepInterpol FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new LutherFieldStepInterpolator<>(field, forward, yDotK, + return new LutherFieldStepInterpolator(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class LutherFieldStepInterpolatorTest extends RungeKuttaFieldStepInterpol protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new LutherFieldIntegrator<>(field, field.getOne()); + return new LutherFieldIntegrator(field, field.getOne()); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegratorTest.java index 0f64075d14..d983146c52 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegratorTest.java @@ -26,7 +26,7 @@ public class MidpointFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstra protected > RungeKuttaFieldIntegrator createIntegrator(Field field, T step) { - return new MidpointFieldIntegrator<>(field, step); + return new MidpointFieldIntegrator(field, step); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolatorTest.java index ef0aa9cca3..b1008e58bf 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class MidpointFieldStepInterpolatorTest extends RungeKuttaFieldStepInterp FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new MidpointFieldStepInterpolator<>(field, forward, yDotK, + return new MidpointFieldStepInterpolator(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class MidpointFieldStepInterpolatorTest extends RungeKuttaFieldStepInterp protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new MidpointFieldIntegrator<>(field, field.getOne()); + return new MidpointFieldIntegrator(field, field.getOne()); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java index a6d480cef0..788f732add 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java @@ -151,8 +151,8 @@ public T[] computeDerivatives(T t, T[] y) { y0[i] = field.getOne().add(i); } - FieldODEStateAndDerivative result = integrator.integrate(new FieldExpandableODE<>(ode), - new FieldODEState<>(t0, y0), + FieldODEStateAndDerivative result = integrator.integrate(new FieldExpandableODE(ode), + new FieldODEState(t0, y0), tEvent); Assert.assertEquals(tEvent.getReal(), result.getTime().getReal(), epsilonT); T[] y = result.getState(); @@ -180,8 +180,8 @@ public Action eventOccurred(FieldODEStateAndDerivative state, boolean increas return Action.CONTINUE; } }, Double.POSITIVE_INFINITY, 1.0e-20, 100); - result = integrator.integrate(new FieldExpandableODE<>(ode), - new FieldODEState<>(t0, y0), + result = integrator.integrate(new FieldExpandableODE(ode), + new FieldODEState(t0, y0), tEvent.add(120)); Assert.assertEquals(tEvent.add(120).getReal(), result.getTime().getReal(), epsilonT); y = result.getState(); @@ -201,17 +201,17 @@ protected > void doTestSanityChecks(Field field MaxCountExceededException, NoBracketingException { RungeKuttaFieldIntegrator integrator = createIntegrator(field, field.getZero().add(0.01)); try { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); - integrator.integrate(new FieldExpandableODE<>(pb), - new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, pb.getDimension() + 10)), + TestFieldProblem1 pb = new TestFieldProblem1(field); + integrator.integrate(new FieldExpandableODE(pb), + new FieldODEState(field.getZero(), MathArrays.buildArray(field, pb.getDimension() + 10)), field.getOne()); Assert.fail("an exception should have been thrown"); } catch(DimensionMismatchException ie) { } try { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); - integrator.integrate(new FieldExpandableODE<>(pb), - new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, pb.getDimension())), + TestFieldProblem1 pb = new TestFieldProblem1(field); + integrator.integrate(new FieldExpandableODE(pb), + new FieldODEState(field.getZero(), MathArrays.buildArray(field, pb.getDimension())), field.getZero()); Assert.fail("an exception should have been thrown"); } catch(NumberIsTooSmallException ie) { @@ -231,12 +231,12 @@ protected > void doTestDecreasingSteps(Field fi @SuppressWarnings("unchecked") TestFieldProblemAbstract[] allProblems = (TestFieldProblemAbstract[]) Array.newInstance(TestFieldProblemAbstract.class, 6); - allProblems[0] = new TestFieldProblem1<>(field); - allProblems[1] = new TestFieldProblem2<>(field); - allProblems[2] = new TestFieldProblem3<>(field); - allProblems[3] = new TestFieldProblem4<>(field); - allProblems[4] = new TestFieldProblem5<>(field); - allProblems[5] = new TestFieldProblem6<>(field); + allProblems[0] = new TestFieldProblem1(field); + allProblems[1] = new TestFieldProblem2(field); + allProblems[2] = new TestFieldProblem3(field); + allProblems[3] = new TestFieldProblem4(field); + allProblems[4] = new TestFieldProblem5(field); + allProblems[5] = new TestFieldProblem6(field); for (TestFieldProblemAbstract pb : allProblems) { T previousValueError = null; @@ -246,7 +246,7 @@ protected > void doTestDecreasingSteps(Field fi T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(FastMath.pow(2.0, -i)); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); FieldEventHandler[] functions = pb.getEventsHandlers(); for (int l = 0; l < functions.length; ++l) { @@ -254,7 +254,7 @@ protected > void doTestDecreasingSteps(Field fi Double.POSITIVE_INFINITY, 1.0e-6 * step.getReal(), 1000); } Assert.assertEquals(functions.length, integ.getEventHandlers().size()); - FieldODEStateAndDerivative stop = integ.integrate(new FieldExpandableODE<>(pb), + FieldODEStateAndDerivative stop = integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); if (functions.length == 0) { @@ -292,13 +292,13 @@ protected > void doTestSmallStep(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); + TestFieldProblem1 pb = new TestFieldProblem1(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.001); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getLastError().getReal(), epsilonLast); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); @@ -318,13 +318,13 @@ protected > void doTestBigStep(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem1 pb = new TestFieldProblem1<>(field); + TestFieldProblem1 pb = new TestFieldProblem1(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.2); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertTrue(handler.getLastError().getReal() > belowLast); Assert.assertTrue(handler.getMaximalValueError().getReal() > belowMaxValue); @@ -344,13 +344,13 @@ protected > void doTestBackward(Field field, throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - TestFieldProblem5 pb = new TestFieldProblem5<>(field); + TestFieldProblem5 pb = new TestFieldProblem5(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.001).abs(); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ); + TestFieldProblemHandler handler = new TestFieldProblemHandler(pb, integ); integ.addStepHandler(handler); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); Assert.assertEquals(0, handler.getLastError().getReal(), epsilonLast); Assert.assertEquals(0, handler.getMaximalValueError().getReal(), epsilonMaxValue); @@ -366,12 +366,12 @@ protected > void doTestKepler(Field field, doub throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException { - final TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); + final TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.0003); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); - integ.addStepHandler(new KeplerHandler<>(pb, expectedMaxError, epsilon)); - integ.integrate(new FieldExpandableODE<>(pb), pb.getInitialState(), pb.getFinalTime()); + integ.addStepHandler(new KeplerHandler(pb, expectedMaxError, epsilon)); + integ.integrate(new FieldExpandableODE(pb), pb.getInitialState(), pb.getFinalTime()); } private static class KeplerHandler> implements FieldStepHandler { @@ -424,7 +424,7 @@ public void handleStep(FieldStepInterpolator interpolator, boolean isLast) { public void init(FieldODEStateAndDerivative s0, T t) { } }); - integ.integrate(new FieldExpandableODE<>(new FirstOrderFieldDifferentialEquations() { + integ.integrate(new FieldExpandableODE(new FirstOrderFieldDifferentialEquations() { public void init(T t0, T[] y0, T t) { } public T[] computeDerivatives(T t, T[] y) { @@ -435,7 +435,7 @@ public T[] computeDerivatives(T t, T[] y) { public int getDimension() { return 1; } - }), new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, 1)), field.getZero().add(5.0)); + }), new FieldODEState(field.getZero(), MathArrays.buildArray(field, 1)), field.getZero().add(5.0)); } @Test @@ -443,7 +443,7 @@ public int getDimension() { protected > void doTestSingleStep(final Field field, final double epsilon) { - final TestFieldProblem3 pb = new TestFieldProblem3<>(field, field.getZero().add(0.9)); + final TestFieldProblem3 pb = new TestFieldProblem3(field, field.getZero().add(0.9)); T h = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.0003); RungeKuttaFieldIntegrator integ = createIntegrator(field, field.getZero().add(Double.NaN)); @@ -489,7 +489,7 @@ public T[] computeDerivatives(T t, T[] y) { }; - integ.integrate(new FieldExpandableODE<>(equations), new FieldODEState<>(t0, y0), t); + integ.integrate(new FieldExpandableODE(equations), new FieldODEState(t0, y0), t); } @@ -497,14 +497,14 @@ public T[] computeDerivatives(T t, T[] y) { public abstract void testUnstableDerivative(); protected > void doTestUnstableDerivative(Field field, double epsilon) { - final StepFieldProblem stepProblem = new StepFieldProblem<>(field, + final StepFieldProblem stepProblem = new StepFieldProblem(field, field.getZero().add(0.0), field.getZero().add(1.0), field.getZero().add(2.0)); RungeKuttaFieldIntegrator integ = createIntegrator(field, field.getZero().add(0.3)); integ.addEventHandler(stepProblem, 1.0, 1.0e-12, 1000); - FieldODEStateAndDerivative result = integ.integrate(new FieldExpandableODE<>(stepProblem), - new FieldODEState<>(field.getZero(), MathArrays.buildArray(field, 1)), + FieldODEStateAndDerivative result = integ.integrate(new FieldExpandableODE(stepProblem), + new FieldODEState(field.getZero(), MathArrays.buildArray(field, 1)), field.getZero().add(10.0)); Assert.assertEquals(8.0, result.getState()[0].getReal(), epsilon); } @@ -513,7 +513,7 @@ protected > void doTestUnstableDerivative(Field public abstract void testDerivativesConsistency(); protected > void doTestDerivativesConsistency(final Field field, double epsilon) { - TestFieldProblem3 pb = new TestFieldProblem3<>(field); + TestFieldProblem3 pb = new TestFieldProblem3(field); T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.001); RungeKuttaFieldIntegrator integ = createIntegrator(field, step); StepInterpolatorTestUtils.checkDerivativesConsistency(integ, pb, 1.0e-10); @@ -546,8 +546,8 @@ protected void doTestPartialDerivatives(final double epsilonY, RungeKuttaFieldIntegrator integrator = createIntegrator(omega.getField(), t.subtract(t0).multiply(0.001)); FieldODEStateAndDerivative result = - integrator.integrate(new FieldExpandableODE<>(sinCos), - new FieldODEState<>(t0, y0), + integrator.integrate(new FieldExpandableODE(sinCos), + new FieldODEState(t0, y0), t); // check values diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldStepInterpolatorAbstractTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldStepInterpolatorAbstractTest.java index ca77ac3978..0205a8dab2 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldStepInterpolatorAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldStepInterpolatorAbstractTest.java @@ -52,7 +52,7 @@ public abstract class RungeKuttaFieldStepInterpolatorAbstractTest { protected > void doInterpolationAtBounds(final Field field, double epsilon) { RungeKuttaFieldStepInterpolator interpolator = setUpInterpolator(field, - new SinCos<>(field), + new SinCos(field), 0.0, new double[] { 0.0, 1.0 }, 0.125); Assert.assertEquals(0.0, interpolator.getPreviousState().getTime().getReal(), 1.0e-15); @@ -77,7 +77,7 @@ protected > void doInterpolationInside(final Field double epsilonSin, double epsilonCos) { RungeKuttaFieldStepInterpolator interpolator = setUpInterpolator(field, - new SinCos<>(field), + new SinCos(field), 0.0, new double[] { 0.0, 1.0 }, 0.0125); int n = 100; @@ -103,7 +103,7 @@ protected > void doNonFieldInterpolatorConsistency double epsilonSin, double epsilonCos, double epsilonSinDot, double epsilonCosDot) { - FirstOrderFieldDifferentialEquations eqn = new SinCos<>(field); + FirstOrderFieldDifferentialEquations eqn = new SinCos(field); RungeKuttaFieldStepInterpolator fieldInterpolator = setUpInterpolator(field, eqn, 0.0, new double[] { 0.0, 1.0 }, 0.125); RungeKuttaStepInterpolator regularInterpolator = convertInterpolator(fieldInterpolator, eqn); @@ -160,7 +160,7 @@ RungeKuttaFieldStepInterpolator setUpInterpolator(final Field field, fieldY[i] = field.getZero().add(y0[i]); } fieldYDotK[0] = eqn.computeDerivatives(t, fieldY); - FieldODEStateAndDerivative s0 = new FieldODEStateAndDerivative<>(t, fieldY, fieldYDotK[0]); + FieldODEStateAndDerivative s0 = new FieldODEStateAndDerivative(t, fieldY, fieldYDotK[0]); // perform one integration step, in order to get consistent derivatives T h = field.getZero().add(t1 - t0); @@ -182,11 +182,11 @@ RungeKuttaFieldStepInterpolator setUpInterpolator(final Field field, fieldY[i] = fieldY[i].add(h.multiply(b[s].multiply(fieldYDotK[s][i]))); } } - FieldODEStateAndDerivative s1 = new FieldODEStateAndDerivative<>(t, fieldY, + FieldODEStateAndDerivative s1 = new FieldODEStateAndDerivative(t, fieldY, eqn.computeDerivatives(t, fieldY)); return createInterpolator(field, t1 > t0, fieldYDotK, s0, s1, s0, s1, - new FieldExpandableODE<>(eqn).getMapper()); + new FieldExpandableODE(eqn).getMapper()); } diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegratorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegratorTest.java index 1739a28136..fd481ba6e4 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegratorTest.java @@ -26,7 +26,7 @@ public class ThreeEighthesFieldIntegratorTest extends RungeKuttaFieldIntegratorA protected > RungeKuttaFieldIntegrator createIntegrator(Field field, T step) { - return new ThreeEighthesFieldIntegrator<>(field, step); + return new ThreeEighthesFieldIntegrator(field, step); } @Override diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolatorTest.java index 601a32fb1a..86ed2f9f85 100644 --- a/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldStepInterpolatorTest.java @@ -34,7 +34,7 @@ public class ThreeEighthesFieldStepInterpolatorTest extends RungeKuttaFieldStepI FieldODEStateAndDerivative softPreviousState, FieldODEStateAndDerivative softCurrentState, FieldEquationsMapper mapper) { - return new ThreeEighthesFieldStepInterpolator<>(field, forward, yDotK, + return new ThreeEighthesFieldStepInterpolator(field, forward, yDotK, globalPreviousState, globalCurrentState, softPreviousState, softCurrentState, mapper); @@ -42,7 +42,7 @@ public class ThreeEighthesFieldStepInterpolatorTest extends RungeKuttaFieldStepI protected > FieldButcherArrayProvider createButcherArrayProvider(final Field field) { - return new ThreeEighthesFieldIntegrator<>(field, field.getOne()); + return new ThreeEighthesFieldIntegrator(field, field.getOne()); } @Test diff --git a/src/test/java/org/apache/commons/math4/ode/sampling/DummyFieldStepInterpolator.java b/src/test/java/org/apache/commons/math4/ode/sampling/DummyFieldStepInterpolator.java index cda8f2c192..f5467459df 100644 --- a/src/test/java/org/apache/commons/math4/ode/sampling/DummyFieldStepInterpolator.java +++ b/src/test/java/org/apache/commons/math4/ode/sampling/DummyFieldStepInterpolator.java @@ -40,7 +40,7 @@ protected AbstractFieldStepInterpolator create(final boolean newForward, final FieldODEStateAndDerivative newSoftPreviousState, final FieldODEStateAndDerivative newSoftCurrentState, final FieldEquationsMapper newMapper) { - return new DummyFieldStepInterpolator<>(newForward, + return new DummyFieldStepInterpolator(newForward, newGlobalPreviousState, newGlobalCurrentState, newSoftPreviousState, newSoftCurrentState, newMapper); diff --git a/src/test/java/org/apache/commons/math4/ode/sampling/StepInterpolatorTestUtils.java b/src/test/java/org/apache/commons/math4/ode/sampling/StepInterpolatorTestUtils.java index d3d5fcaff9..5c592d3df7 100644 --- a/src/test/java/org/apache/commons/math4/ode/sampling/StepInterpolatorTestUtils.java +++ b/src/test/java/org/apache/commons/math4/ode/sampling/StepInterpolatorTestUtils.java @@ -137,7 +137,7 @@ public void init(FieldODEStateAndDerivative state0, T t) { }); - integrator.integrate(new FieldExpandableODE<>(problem), problem.getInitialState(), problem.getFinalTime()); + integrator.integrate(new FieldExpandableODE(problem), problem.getInitialState(), problem.getFinalTime()); } } diff --git a/src/test/java/org/apache/commons/math4/ode/sampling/StepNormalizerOutputTestBase.java b/src/test/java/org/apache/commons/math4/ode/sampling/StepNormalizerOutputTestBase.java index 6f6bfbec08..1955321978 100644 --- a/src/test/java/org/apache/commons/math4/ode/sampling/StepNormalizerOutputTestBase.java +++ b/src/test/java/org/apache/commons/math4/ode/sampling/StepNormalizerOutputTestBase.java @@ -255,7 +255,7 @@ private void doTest(StepNormalizerMode mode, StepNormalizerBounds bounds, double[] y = {0.0}; double start = reverse ? getEnd() : getStart(); double end = reverse ? getStart() : getEnd(); - output = new ArrayList<>(); + output = new ArrayList(); integ.integrate(this, start, y, end, y); double[] actual = new double[output.size()]; for(int i = 0; i < actual.length; i++) { diff --git a/src/test/java/org/apache/commons/math4/optim/SimplePointCheckerTest.java b/src/test/java/org/apache/commons/math4/optim/SimplePointCheckerTest.java index 262bb6082d..e496e9e2ae 100644 --- a/src/test/java/org/apache/commons/math4/optim/SimplePointCheckerTest.java +++ b/src/test/java/org/apache/commons/math4/optim/SimplePointCheckerTest.java @@ -32,7 +32,7 @@ public void testIterationCheckPrecondition() { public void testIterationCheck() { final int max = 10; final SimplePointChecker checker - = new SimplePointChecker<>(1e-1, 1e-2, max); + = new SimplePointChecker(1e-1, 1e-2, max); Assert.assertTrue(checker.converged(max, null, null)); Assert.assertTrue(checker.converged(max + 1, null, null)); } @@ -40,7 +40,7 @@ public void testIterationCheck() { @Test public void testIterationCheckDisabled() { final SimplePointChecker checker - = new SimplePointChecker<>(1e-8, 1e-8); + = new SimplePointChecker(1e-8, 1e-8); final PointValuePair a = new PointValuePair(new double[] { 1d }, 1d); final PointValuePair b = new PointValuePair(new double[] { 10d }, 10d); diff --git a/src/test/java/org/apache/commons/math4/optim/linear/SimplexSolverTest.java b/src/test/java/org/apache/commons/math4/optim/linear/SimplexSolverTest.java index 503f782d30..987ab6c697 100644 --- a/src/test/java/org/apache/commons/math4/optim/linear/SimplexSolverTest.java +++ b/src/test/java/org/apache/commons/math4/optim/linear/SimplexSolverTest.java @@ -54,7 +54,7 @@ public void testMath842Cycle() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 10, -57, -9, -24}, 0); - ArrayList constraints = new ArrayList<>(); + ArrayList constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] {0.5, -5.5, -2.5, 9}, Relationship.LEQ, 0)); constraints.add(new LinearConstraint(new double[] {0.5, -1.5, -0.5, 1}, Relationship.LEQ, 0)); @@ -75,7 +75,7 @@ public void testMath828() { LinearObjectiveFunction f = new LinearObjectiveFunction( new double[] { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, 0.0); - ArrayList constraints = new ArrayList<>(); + ArrayList constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] {0.0, 39.0, 23.0, 96.0, 15.0, 48.0, 9.0, 21.0, 48.0, 36.0, 76.0, 19.0, 88.0, 17.0, 16.0, 36.0,}, Relationship.GEQ, 15.0)); constraints.add(new LinearConstraint(new double[] {0.0, 59.0, 93.0, 12.0, 29.0, 78.0, 73.0, 87.0, 32.0, 70.0, 68.0, 24.0, 11.0, 26.0, 65.0, 25.0,}, Relationship.GEQ, 29.0)); @@ -97,7 +97,7 @@ public void testMath828Cycle() { LinearObjectiveFunction f = new LinearObjectiveFunction( new double[] { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, 0.0); - ArrayList constraints = new ArrayList<>(); + ArrayList constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] {0.0, 16.0, 14.0, 69.0, 1.0, 85.0, 52.0, 43.0, 64.0, 97.0, 14.0, 74.0, 89.0, 28.0, 94.0, 58.0, 13.0, 22.0, 21.0, 17.0, 30.0, 25.0, 1.0, 59.0, 91.0, 78.0, 12.0, 74.0, 56.0, 3.0, 88.0,}, Relationship.GEQ, 91.0)); constraints.add(new LinearConstraint(new double[] {0.0, 60.0, 40.0, 81.0, 71.0, 72.0, 46.0, 45.0, 38.0, 48.0, 40.0, 17.0, 33.0, 85.0, 64.0, 32.0, 84.0, 3.0, 54.0, 44.0, 71.0, 67.0, 90.0, 95.0, 54.0, 99.0, 99.0, 29.0, 52.0, 98.0, 9.0,}, Relationship.GEQ, 54.0)); @@ -120,7 +120,7 @@ GoalType.MINIMIZE, new NonNegativeConstraint(true), public void testMath781() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 2, 6, 7 }, 0); - ArrayList constraints = new ArrayList<>(); + ArrayList constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1, 2, 1 }, Relationship.LEQ, 2)); constraints.add(new LinearConstraint(new double[] { -1, 1, 1 }, Relationship.LEQ, -1)); constraints.add(new LinearConstraint(new double[] { 2, -3, 1 }, Relationship.LEQ, -1)); @@ -139,7 +139,7 @@ public void testMath781() { @Test public void testMath713NegativeVariable() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {1.0, 1.0}, 0.0d); - ArrayList constraints = new ArrayList<>(); + ArrayList constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] {1, 0}, Relationship.EQ, 1)); double epsilon = 1e-6; @@ -154,7 +154,7 @@ public void testMath713NegativeVariable() { @Test public void testMath434NegativeVariable() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {0.0, 0.0, 1.0}, 0.0d); - ArrayList constraints = new ArrayList<>(); + ArrayList constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] {1, 1, 0}, Relationship.EQ, 5)); constraints.add(new LinearConstraint(new double[] {0, 0, 1}, Relationship.GEQ, -10)); @@ -174,7 +174,7 @@ public void testMath434UnfeasibleSolution() { double epsilon = 1e-6; LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {1.0, 0.0}, 0.0); - ArrayList constraints = new ArrayList<>(); + ArrayList constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] {epsilon/2, 0.5}, Relationship.EQ, 0)); constraints.add(new LinearConstraint(new double[] {1e-3, 0.1}, Relationship.EQ, 10)); @@ -189,7 +189,7 @@ public void testMath434PivotRowSelection() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {1.0}, 0.0); double epsilon = 1e-6; - ArrayList constraints = new ArrayList<>(); + ArrayList constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] {200}, Relationship.GEQ, 1)); constraints.add(new LinearConstraint(new double[] {100}, Relationship.GEQ, 0.499900001)); @@ -205,7 +205,7 @@ public void testMath434PivotRowSelection() { public void testMath434PivotRowSelection2() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {0.0d, 1.0d, 1.0d, 0.0d, 0.0d, 0.0d, 0.0d}, 0.0d); - ArrayList constraints = new ArrayList<>(); + ArrayList constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] {1.0d, -0.1d, 0.0d, 0.0d, 0.0d, 0.0d, 0.0d}, Relationship.EQ, -0.1d)); constraints.add(new LinearConstraint(new double[] {1.0d, 0.0d, 0.0d, 0.0d, 0.0d, 0.0d, 0.0d}, Relationship.GEQ, -1e-18d)); constraints.add(new LinearConstraint(new double[] {0.0d, 1.0d, 0.0d, 0.0d, 0.0d, 0.0d, 0.0d}, Relationship.GEQ, 0.0d)); @@ -230,7 +230,7 @@ public void testMath434PivotRowSelection2() { @Test public void testMath272() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 2, 2, 1 }, 0); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1, 1, 0 }, Relationship.GEQ, 1)); constraints.add(new LinearConstraint(new double[] { 1, 0, 1 }, Relationship.GEQ, 1)); constraints.add(new LinearConstraint(new double[] { 0, 1, 0 }, Relationship.GEQ, 1)); @@ -248,7 +248,7 @@ public void testMath272() { @Test public void testMath286() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 0.8, 0.2, 0.7, 0.3, 0.6, 0.4 }, 0 ); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1, 0, 1, 0, 1, 0 }, Relationship.EQ, 23.0)); constraints.add(new LinearConstraint(new double[] { 0, 1, 0, 1, 0, 1 }, Relationship.EQ, 23.0)); constraints.add(new LinearConstraint(new double[] { 1, 0, 0, 0, 0, 0 }, Relationship.GEQ, 10.0)); @@ -270,7 +270,7 @@ public void testMath286() { @Test public void testDegeneracy() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 0.8, 0.7 }, 0 ); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1, 1 }, Relationship.LEQ, 18.0)); constraints.add(new LinearConstraint(new double[] { 1, 0 }, Relationship.GEQ, 10.0)); constraints.add(new LinearConstraint(new double[] { 0, 1 }, Relationship.GEQ, 8.0)); @@ -284,7 +284,7 @@ public void testDegeneracy() { @Test public void testMath288() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 7, 3, 0, 0 }, 0 ); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 3, 0, -5, 0 }, Relationship.LEQ, 0.0)); constraints.add(new LinearConstraint(new double[] { 2, 0, 0, -5 }, Relationship.LEQ, 0.0)); constraints.add(new LinearConstraint(new double[] { 0, 3, 0, -5 }, Relationship.LEQ, 0.0)); @@ -300,7 +300,7 @@ public void testMath288() { @Test public void testMath290GEQ() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 1, 5 }, 0 ); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 2, 0 }, Relationship.GEQ, -1.0)); SimplexSolver solver = new SimplexSolver(); PointValuePair solution = solver.optimize(DEFAULT_MAX_ITER, f, new LinearConstraintSet(constraints), @@ -313,7 +313,7 @@ public void testMath290GEQ() { @Test(expected=NoFeasibleSolutionException.class) public void testMath290LEQ() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 1, 5 }, 0 ); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 2, 0 }, Relationship.LEQ, -1.0)); SimplexSolver solver = new SimplexSolver(); solver.optimize(DEFAULT_MAX_ITER, f, new LinearConstraintSet(constraints), @@ -323,7 +323,7 @@ public void testMath290LEQ() { @Test public void testMath293() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 0.8, 0.2, 0.7, 0.3, 0.4, 0.6}, 0 ); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1, 0, 1, 0, 1, 0 }, Relationship.EQ, 30.0)); constraints.add(new LinearConstraint(new double[] { 0, 1, 0, 1, 0, 1 }, Relationship.EQ, 30.0)); constraints.add(new LinearConstraint(new double[] { 0.8, 0.2, 0.0, 0.0, 0.0, 0.0 }, Relationship.GEQ, 10.0)); @@ -347,7 +347,7 @@ public void testMath293() { double valC = 0.4 * solution1.getPoint()[4] + 0.6 * solution1.getPoint()[5]; f = new LinearObjectiveFunction(new double[] { 0.8, 0.2, 0.7, 0.3, 0.4, 0.6}, 0 ); - constraints = new ArrayList<>(); + constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1, 0, 1, 0, 1, 0 }, Relationship.EQ, 30.0)); constraints.add(new LinearConstraint(new double[] { 0, 1, 0, 1, 0, 1 }, Relationship.EQ, 30.0)); constraints.add(new LinearConstraint(new double[] { 0.8, 0.2, 0.0, 0.0, 0.0, 0.0 }, Relationship.GEQ, valA)); @@ -374,7 +374,7 @@ public void testMath930() { } private List createMath930Constraints() { - List constraints = new ArrayList<>(); + List constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] {1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 0}, Relationship.GEQ, 0.0)); constraints.add(new LinearConstraint(new double[] {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1}, Relationship.GEQ, 0.0)); constraints.add(new LinearConstraint(new double[] {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1}, Relationship.LEQ, 0.0)); @@ -479,7 +479,7 @@ private List createMath930Constraints() { public void testSimplexSolver() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 15, 10 }, 7); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1, 0 }, Relationship.LEQ, 2)); constraints.add(new LinearConstraint(new double[] { 0, 1 }, Relationship.LEQ, 3)); constraints.add(new LinearConstraint(new double[] { 1, 1 }, Relationship.EQ, 4)); @@ -495,7 +495,7 @@ public void testSimplexSolver() { @Test public void testSingleVariableAndConstraint() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 3 }, 0); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1 }, Relationship.LEQ, 10)); SimplexSolver solver = new SimplexSolver(); @@ -512,7 +512,7 @@ public void testSingleVariableAndConstraint() { @Test public void testModelWithNoArtificialVars() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 15, 10 }, 0); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1, 0 }, Relationship.LEQ, 2)); constraints.add(new LinearConstraint(new double[] { 0, 1 }, Relationship.LEQ, 3)); constraints.add(new LinearConstraint(new double[] { 1, 1 }, Relationship.LEQ, 4)); @@ -528,7 +528,7 @@ public void testModelWithNoArtificialVars() { @Test public void testMinimization() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { -2, 1 }, -5); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1, 2 }, Relationship.LEQ, 6)); constraints.add(new LinearConstraint(new double[] { 3, 2 }, Relationship.LEQ, 12)); constraints.add(new LinearConstraint(new double[] { 0, 1 }, Relationship.GEQ, 0)); @@ -544,7 +544,7 @@ public void testMinimization() { @Test public void testSolutionWithNegativeDecisionVariable() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { -2, 1 }, 0); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1, 1 }, Relationship.GEQ, 6)); constraints.add(new LinearConstraint(new double[] { 1, 2 }, Relationship.LEQ, 14)); @@ -559,7 +559,7 @@ public void testSolutionWithNegativeDecisionVariable() { @Test(expected = NoFeasibleSolutionException.class) public void testInfeasibleSolution() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 15 }, 0); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1 }, Relationship.LEQ, 1)); constraints.add(new LinearConstraint(new double[] { 1 }, Relationship.GEQ, 3)); @@ -571,7 +571,7 @@ public void testInfeasibleSolution() { @Test(expected = UnboundedSolutionException.class) public void testUnboundedSolution() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 15, 10 }, 0); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1, 0 }, Relationship.EQ, 2)); SimplexSolver solver = new SimplexSolver(); @@ -582,7 +582,7 @@ public void testUnboundedSolution() { @Test public void testRestrictVariablesToNonNegative() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 409, 523, 70, 204, 339 }, 0); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 43, 56, 345, 56, 5 }, Relationship.LEQ, 4567456)); constraints.add(new LinearConstraint(new double[] { 12, 45, 7, 56, 23 }, Relationship.LEQ, 56454)); constraints.add(new LinearConstraint(new double[] { 8, 768, 0, 34, 7456 }, Relationship.LEQ, 1923421)); @@ -604,7 +604,7 @@ public void testRestrictVariablesToNonNegative() { public void testEpsilon() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 10, 5, 1 }, 0); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 9, 8, 0 }, Relationship.EQ, 17)); constraints.add(new LinearConstraint(new double[] { 0, 7, 8 }, Relationship.LEQ, 7)); constraints.add(new LinearConstraint(new double[] { 10, 0, 2 }, Relationship.LEQ, 10)); @@ -621,7 +621,7 @@ public void testEpsilon() { @Test public void testTrivialModel() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 1, 1 }, 0); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 1, 1 }, Relationship.EQ, 0)); SimplexSolver solver = new SimplexSolver(); @@ -657,7 +657,7 @@ public void testLargeModel() { 1, 1, 1, 1, 1, 1}; LinearObjectiveFunction f = new LinearObjectiveFunction(objective, 0); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(equationFromString(objective.length, "x0 + x1 + x2 + x3 - x12 = 0")); constraints.add(equationFromString(objective.length, "x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 - x13 = 0")); constraints.add(equationFromString(objective.length, "x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 >= 49")); @@ -765,7 +765,7 @@ public void testSolutionCallback() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 7, 3, 0, 0 }, 0 ); - List constraints = new ArrayList<>(); + List constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] { 3, 0, -5, 0 }, Relationship.LEQ, 0.0)); constraints.add(new LinearConstraint(new double[] { 2, 0, 0, -5 }, Relationship.LEQ, 0.0)); constraints.add(new LinearConstraint(new double[] { 0, 3, 0, -5 }, Relationship.LEQ, 0.0)); @@ -805,7 +805,7 @@ public void testDimensionMatch() { // x1,x2,x3 >= 0 LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 2, 15, 18 }, 0); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); // this constraint is wrong, the dimension is less than expected one constraints.add(new LinearConstraint(new double[] { -1, 2 - 6 }, Relationship.LEQ, -10)); constraints.add(new LinearConstraint(new double[] { 0, 1, 2 }, Relationship.LEQ, 6)); diff --git a/src/test/java/org/apache/commons/math4/optim/linear/SimplexTableauTest.java b/src/test/java/org/apache/commons/math4/optim/linear/SimplexTableauTest.java index be774c4ccc..e0c99da4cf 100644 --- a/src/test/java/org/apache/commons/math4/optim/linear/SimplexTableauTest.java +++ b/src/test/java/org/apache/commons/math4/optim/linear/SimplexTableauTest.java @@ -65,7 +65,7 @@ public void testDropPhase1Objective() { @Test public void testTableauWithNoArtificialVars() { LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {15, 10}, 0); - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] {1, 0}, Relationship.LEQ, 2)); constraints.add(new LinearConstraint(new double[] {0, 1}, Relationship.LEQ, 3)); constraints.add(new LinearConstraint(new double[] {1, 1}, Relationship.LEQ, 4)); @@ -94,7 +94,7 @@ private LinearObjectiveFunction createFunction() { } private Collection createConstraints() { - Collection constraints = new ArrayList<>(); + Collection constraints = new ArrayList(); constraints.add(new LinearConstraint(new double[] {1, 0}, Relationship.LEQ, 2)); constraints.add(new LinearConstraint(new double[] {0, 1}, Relationship.LEQ, 3)); constraints.add(new LinearConstraint(new double[] {1, 1}, Relationship.EQ, 4)); diff --git a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/CircleScalar.java b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/CircleScalar.java index 0c802543a0..4c2acaa323 100644 --- a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/CircleScalar.java +++ b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/CircleScalar.java @@ -32,7 +32,7 @@ public class CircleScalar { private ArrayList points; public CircleScalar() { - points = new ArrayList<>(); + points = new ArrayList(); } public void addPoint(double px, double py) { diff --git a/src/test/java/org/apache/commons/math4/primes/PrimesTest.java b/src/test/java/org/apache/commons/math4/primes/PrimesTest.java index 831a86ee61..26bcd37f9a 100644 --- a/src/test/java/org/apache/commons/math4/primes/PrimesTest.java +++ b/src/test/java/org/apache/commons/math4/primes/PrimesTest.java @@ -140,7 +140,7 @@ static int product(List numbers) { } return out; } - static final HashSet PRIMES_SET = new HashSet<>(); + static final HashSet PRIMES_SET = new HashSet(); static { for (int p : PRIMES) { PRIMES_SET.add(p); diff --git a/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java b/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java index d4d5bc2157..4854979c01 100644 --- a/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java +++ b/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java @@ -62,7 +62,7 @@ public void setUp() { super.setUp(); empiricalDistribution = new EmpiricalDistribution(100); url = getClass().getResource("testData.txt"); - final ArrayList list = new ArrayList<>(); + final ArrayList list = new ArrayList(); try { empiricalDistribution2 = new EmpiricalDistribution(100); BufferedReader in = diff --git a/src/test/java/org/apache/commons/math4/random/RandomDataGeneratorTest.java b/src/test/java/org/apache/commons/math4/random/RandomDataGeneratorTest.java index d7d7bb59d9..2982efb35e 100644 --- a/src/test/java/org/apache/commons/math4/random/RandomDataGeneratorTest.java +++ b/src/test/java/org/apache/commons/math4/random/RandomDataGeneratorTest.java @@ -483,7 +483,7 @@ public void checkNextPoissonConsistency(double mean) { * [binBounds[binCount - 2], upper = binBounds[binCount - 1]), [upper, +inf) * */ - List binBounds = new ArrayList<>(); + List binBounds = new ArrayList(); binBounds.add(lower); int bound = lower + binWidth; while (bound < upper - binWidth) { @@ -872,14 +872,14 @@ public void testNextSample() { long[] observed = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; double[] expected = { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 }; - HashSet cPop = new HashSet<>(); // {0,1,2,3,4} + HashSet cPop = new HashSet(); // {0,1,2,3,4} for (int i = 0; i < 5; i++) { cPop.add(Integer.toString(i)); } Object[] sets = new Object[10]; // 2-sets from 5 for (int i = 0; i < 10; i++) { - HashSet hs = new HashSet<>(); + HashSet hs = new HashSet(); hs.add(c[i][0]); hs.add(c[i][1]); sets[i] = hs; @@ -898,7 +898,7 @@ public void testNextSample() { testStatistic.chiSquare(expected, observed) < 27.88); // Make sure sample of size = size of collection returns same collection - HashSet hs = new HashSet<>(); + HashSet hs = new HashSet(); hs.add("one"); Object[] one = randomData.nextSample(hs, 1); String oneString = (String) one[0]; @@ -916,7 +916,7 @@ public void testNextSample() { // Make sure we fail for empty collection try { - hs = new HashSet<>(); + hs = new HashSet(); one = randomData.nextSample(hs, 0); Assert.fail("n = k = 0, expecting MathIllegalArgumentException"); } catch (MathIllegalArgumentException ex) { @@ -928,7 +928,7 @@ public void testNextSample() { private int findSample(Object[] u, Object[] samp) { for (int i = 0; i < u.length; i++) { HashSet set = (HashSet) u[i]; - HashSet sampSet = new HashSet<>(); + HashSet sampSet = new HashSet(); for (int j = 0; j < samp.length; j++) { sampSet.add(samp[j]); } diff --git a/src/test/java/org/apache/commons/math4/random/SynchronizedRandomGeneratorTest.java b/src/test/java/org/apache/commons/math4/random/SynchronizedRandomGeneratorTest.java index f4ec2cdf72..b66a1272b6 100644 --- a/src/test/java/org/apache/commons/math4/random/SynchronizedRandomGeneratorTest.java +++ b/src/test/java/org/apache/commons/math4/random/SynchronizedRandomGeneratorTest.java @@ -95,7 +95,7 @@ private double[] doTestMath899(final boolean sync, final RandomGenerator rng = new MersenneTwister(); final RandomGenerator wrapper = sync ? new SynchronizedRandomGenerator(rng) : rng; - final List> tasks = new ArrayList<>(); + final List> tasks = new ArrayList>(); for (int i = 0; i < numGenerators; i++) { tasks.add(new Callable() { @Override diff --git a/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java b/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java index 7263a1e540..444c57ae94 100644 --- a/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java +++ b/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java @@ -367,7 +367,7 @@ public void testMergeCollection() { Frequency h = new Frequency(); h.addValue(THREE_LONG); - List coll = new ArrayList<>(); + List coll = new ArrayList(); coll.add(g); coll.add(h); f.merge(coll); diff --git a/src/test/java/org/apache/commons/math4/stat/data/CertifiedDataAbstractTest.java b/src/test/java/org/apache/commons/math4/stat/data/CertifiedDataAbstractTest.java index 74262b9234..32cfbdd02c 100644 --- a/src/test/java/org/apache/commons/math4/stat/data/CertifiedDataAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/stat/data/CertifiedDataAbstractTest.java @@ -48,7 +48,7 @@ public abstract class CertifiedDataAbstractTest { public void setUp() throws IOException { descriptives = new DescriptiveStatistics(); summaries = new SummaryStatistics(); - certifiedValues = new HashMap<>(); + certifiedValues = new HashMap(); loadData(); } diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatisticsTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatisticsTest.java index 94c980d2be..5324ecf4f5 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatisticsTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatisticsTest.java @@ -147,7 +147,7 @@ public void testAggregate() { for (int i = 0; i < nSamples; i++) { subSampleStats[i] = new SummaryStatistics(); } - Collection aggregate = new ArrayList<>(); + Collection aggregate = new ArrayList(); for (int i = 0; i < nSamples; i++) { for (int j = 0; j < subSamples[i].length; j++) { subSampleStats[i].addValue(subSamples[i][j]); @@ -183,7 +183,7 @@ public void testAggregateStatisticalSummary() { for (int i = 0; i < nSamples; i++) { subSampleStats[i] = new SummaryStatistics(); } - Collection aggregate = new ArrayList<>(); + Collection aggregate = new ArrayList(); for (int i = 0; i < nSamples; i++) { for (int j = 0; j < subSamples[i].length; j++) { subSampleStats[i].addValue(subSamples[i][j]); @@ -213,7 +213,7 @@ public void testAggregateDegenerate() { for (int i = 0; i < 5; i++) { subSampleStats[i] = new SummaryStatistics(); } - Collection aggregate = new ArrayList<>(); + Collection aggregate = new ArrayList(); for (int i = 0; i < 5; i++) { for (int j = 0; j < subSamples[i].length; j++) { subSampleStats[i].addValue(subSamples[i][j]); @@ -242,7 +242,7 @@ public void testAggregateSpecialValues() { for (int i = 0; i < 4; i++) { subSampleStats[i] = new SummaryStatistics(); } - Collection aggregate = new ArrayList<>(); + Collection aggregate = new ArrayList(); for (int i = 0; i < 4; i++) { for (int j = 0; j < subSamples[i].length; j++) { subSampleStats[i].addValue(subSamples[i][j]); diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImpl.java b/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImpl.java index 19b9b9f927..7bdd8009bb 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImpl.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImpl.java @@ -47,7 +47,7 @@ public class ListUnivariateImpl extends DescriptiveStatistics implements Seriali * No argument Constructor */ public ListUnivariateImpl(){ - this(new ArrayList<>()); + this(new ArrayList()); } /** diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImplTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImplTest.java index 2e22fc38ea..964d06618c 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImplTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImplTest.java @@ -49,7 +49,7 @@ public final class ListUnivariateImplTest { /** test stats */ @Test public void testStats() { - List externalList = new ArrayList<>(); + List externalList = new ArrayList(); DescriptiveStatistics u = new ListUnivariateImpl( externalList ); @@ -72,7 +72,7 @@ public void testStats() { @Test public void testN0andN1Conditions() { - List list = new ArrayList<>(); + List list = new ArrayList(); DescriptiveStatistics u = new ListUnivariateImpl( list ); @@ -105,7 +105,7 @@ public void testSkewAndKurtosis() { @Test public void testProductAndGeometricMean() { - ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList<>()); + ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList()); u.setWindowSize(10); u.addValue( 1.0 ); diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/MixedListUnivariateImplTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/MixedListUnivariateImplTest.java index 7d3ab049ec..410a2e1b80 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/MixedListUnivariateImplTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/MixedListUnivariateImplTest.java @@ -59,7 +59,7 @@ public MixedListUnivariateImplTest() { /** test stats */ @Test public void testStats() { - List externalList = new ArrayList<>(); + List externalList = new ArrayList(); DescriptiveStatistics u = new ListUnivariateImpl(externalList,transformers); @@ -82,7 +82,7 @@ public void testStats() { @Test public void testN0andN1Conditions() { - DescriptiveStatistics u = new ListUnivariateImpl(new ArrayList<>(),transformers); + DescriptiveStatistics u = new ListUnivariateImpl(new ArrayList(),transformers); Assert.assertTrue( "Mean of n = 0 set should be NaN", @@ -112,7 +112,7 @@ public void testN0andN1Conditions() { @Test public void testSkewAndKurtosis() { ListUnivariateImpl u = - new ListUnivariateImpl(new ArrayList<>(), transformers); + new ListUnivariateImpl(new ArrayList(), transformers); u.addObject("12.5"); u.addObject(Integer.valueOf(12)); @@ -146,7 +146,7 @@ public void testSkewAndKurtosis() { @Test public void testProductAndGeometricMean() { - ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList<>(),transformers); + ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList(),transformers); u.setWindowSize(10); u.addValue(1.0); diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java index c3542b2911..6f12b1e185 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java @@ -188,7 +188,7 @@ public void testWeightedConsistency() { // and fill valuesList with values from values array with // values[i] repeated weights[i] times, each i final RealDistribution valueDist = new NormalDistribution(mu, sigma); - List valuesList = new ArrayList<>(); + List valuesList = new ArrayList(); for (int i = 0; i < len; i++) { double value = valueDist.sample(); values[i] = value; diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentileTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentileTest.java index bab2ec7083..dfdcd4ece9 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentileTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentileTest.java @@ -209,7 +209,7 @@ public void testMarkers2() { public void testHashCodeInMarkers() { PSquarePercentile p = new PSquarePercentile(95); PSquarePercentile p2 = new PSquarePercentile(95); - Set s = new HashSet<>(); + Set s = new HashSet(); s.add(p); s.add(p2); Assert.assertEquals(1, s.size()); @@ -237,7 +237,7 @@ public void testHashCodeInMarkers() { 95.1959, 95.1442, 95.0610, 95.1591, 95.1195, 95.1772, 95.0925, 95.1990, 95.1682 }), 0.0); Assert.assertTrue(m1.equals(m2)); - Set setMarkers = new LinkedHashSet<>(); + Set setMarkers = new LinkedHashSet(); Assert.assertTrue(setMarkers.add(m1)); Assert.assertFalse(setMarkers.add(m2)); Assert.assertEquals(1, setMarkers.size()); diff --git a/src/test/java/org/apache/commons/math4/stat/inference/OneWayAnovaTest.java b/src/test/java/org/apache/commons/math4/stat/inference/OneWayAnovaTest.java index cf35f3067a..3442382c35 100644 --- a/src/test/java/org/apache/commons/math4/stat/inference/OneWayAnovaTest.java +++ b/src/test/java/org/apache/commons/math4/stat/inference/OneWayAnovaTest.java @@ -47,7 +47,7 @@ public class OneWayAnovaTest { @Test public void testAnovaFValue() { // Target comparison values computed using R version 2.6.0 (Linux version) - List threeClasses = new ArrayList<>(); + List threeClasses = new ArrayList(); threeClasses.add(classA); threeClasses.add(classB); threeClasses.add(classC); @@ -55,14 +55,14 @@ public void testAnovaFValue() { Assert.assertEquals("ANOVA F-value", 24.67361709460624, testStatistic.anovaFValue(threeClasses), 1E-12); - List twoClasses = new ArrayList<>(); + List twoClasses = new ArrayList(); twoClasses.add(classA); twoClasses.add(classB); Assert.assertEquals("ANOVA F-value", 0.0150579150579, testStatistic.anovaFValue(twoClasses), 1E-12); - List emptyContents = new ArrayList<>(); + List emptyContents = new ArrayList(); emptyContents.add(emptyArray); emptyContents.add(classC); try { @@ -72,7 +72,7 @@ public void testAnovaFValue() { // expected } - List tooFew = new ArrayList<>(); + List tooFew = new ArrayList(); tooFew.add(classA); try { testStatistic.anovaFValue(tooFew); @@ -86,7 +86,7 @@ public void testAnovaFValue() { @Test public void testAnovaPValue() { // Target comparison values computed using R version 2.6.0 (Linux version) - List threeClasses = new ArrayList<>(); + List threeClasses = new ArrayList(); threeClasses.add(classA); threeClasses.add(classB); threeClasses.add(classC); @@ -94,7 +94,7 @@ public void testAnovaPValue() { Assert.assertEquals("ANOVA P-value", 6.959446E-06, testStatistic.anovaPValue(threeClasses), 1E-12); - List twoClasses = new ArrayList<>(); + List twoClasses = new ArrayList(); twoClasses.add(classA); twoClasses.add(classB); @@ -106,7 +106,7 @@ public void testAnovaPValue() { @Test public void testAnovaPValueSummaryStatistics() { // Target comparison values computed using R version 2.6.0 (Linux version) - List threeClasses = new ArrayList<>(); + List threeClasses = new ArrayList(); SummaryStatistics statsA = new SummaryStatistics(); for (double a : classA) { statsA.addValue(a); @@ -126,7 +126,7 @@ public void testAnovaPValueSummaryStatistics() { Assert.assertEquals("ANOVA P-value", 6.959446E-06, testStatistic.anovaPValue(threeClasses, true), 1E-12); - List twoClasses = new ArrayList<>(); + List twoClasses = new ArrayList(); twoClasses.add(statsA); twoClasses.add(statsB); @@ -138,14 +138,14 @@ public void testAnovaPValueSummaryStatistics() { @Test public void testAnovaTest() { // Target comparison values computed using R version 2.3.1 (Linux version) - List threeClasses = new ArrayList<>(); + List threeClasses = new ArrayList(); threeClasses.add(classA); threeClasses.add(classB); threeClasses.add(classC); Assert.assertTrue("ANOVA Test P<0.01", testStatistic.anovaTest(threeClasses, 0.01)); - List twoClasses = new ArrayList<>(); + List twoClasses = new ArrayList(); twoClasses.add(classA); twoClasses.add(classB); diff --git a/src/test/java/org/apache/commons/math4/stat/inference/TestUtilsTest.java b/src/test/java/org/apache/commons/math4/stat/inference/TestUtilsTest.java index 59914e050a..b22131e2dc 100644 --- a/src/test/java/org/apache/commons/math4/stat/inference/TestUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/stat/inference/TestUtilsTest.java @@ -457,7 +457,7 @@ public void testPaired() { private double[] classC = {110.0, 115.0, 111.0, 117.0, 128.0}; - private List classes = new ArrayList<>(); + private List classes = new ArrayList(); private OneWayAnova oneWayAnova = new OneWayAnova(); @Test diff --git a/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java b/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java index 1dd31cecc4..fece225154 100644 --- a/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java @@ -125,7 +125,7 @@ public void testGcd() { @Test public void testGcdConsistency() { int[] primeList = {19, 23, 53, 67, 73, 79, 101, 103, 111, 131}; - ArrayList primes = new ArrayList<>(); + ArrayList primes = new ArrayList(); for (int i = 0; i < primeList.length; i++) { primes.add(Integer.valueOf(primeList[i])); } diff --git a/src/test/java/org/apache/commons/math4/util/CombinatoricsUtilsTest.java b/src/test/java/org/apache/commons/math4/util/CombinatoricsUtilsTest.java index faaf786669..0ad8a02e59 100644 --- a/src/test/java/org/apache/commons/math4/util/CombinatoricsUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/util/CombinatoricsUtilsTest.java @@ -38,7 +38,7 @@ public class CombinatoricsUtilsTest { /** cached binomial coefficients */ - private static final List> binomialCache = new ArrayList<>(); + private static final List> binomialCache = new ArrayList>(); /** Verify that b(0,0) = 1 */ @Test diff --git a/src/test/java/org/apache/commons/math4/util/FastMathStrictComparisonTest.java b/src/test/java/org/apache/commons/math4/util/FastMathStrictComparisonTest.java index d38d42e5b5..77a0c7cb16 100644 --- a/src/test/java/org/apache/commons/math4/util/FastMathStrictComparisonTest.java +++ b/src/test/java/org/apache/commons/math4/util/FastMathStrictComparisonTest.java @@ -212,7 +212,7 @@ private static void setupMethodCall(Method mathMethod, Method fastMethod, @Parameters public static List data() throws Exception { String singleMethod = System.getProperty("testMethod"); - List list = new ArrayList<>(); + List list = new ArrayList(); for(Method mathMethod : StrictMath.class.getDeclaredMethods()) { method: if (Modifier.isPublic(mathMethod.getModifiers())){// Only test public methods diff --git a/src/test/java/org/apache/commons/math4/util/IntegerSequenceTest.java b/src/test/java/org/apache/commons/math4/util/IntegerSequenceTest.java index 4b29906a16..25eec4f153 100644 --- a/src/test/java/org/apache/commons/math4/util/IntegerSequenceTest.java +++ b/src/test/java/org/apache/commons/math4/util/IntegerSequenceTest.java @@ -33,7 +33,7 @@ public void testRangeMultipleIterations() { final int max = 7; final int step = 2; - final List seq = new ArrayList<>(); + final List seq = new ArrayList(); final IntegerSequence.Range r = IntegerSequence.range(start, max, step); final int numTimes = 3; @@ -53,7 +53,7 @@ public void testIncreasingRange() { final int max = 7; final int step = 2; - final List seq = new ArrayList<>(); + final List seq = new ArrayList(); final IntegerSequence.Range r = IntegerSequence.range(start, max, step); for (Integer i : r) { seq.add(i); @@ -72,7 +72,7 @@ public void testIncreasingRangeNegativeEnd() { final int max = -1; final int step = 2; - final List seq = new ArrayList<>(); + final List seq = new ArrayList(); final IntegerSequence.Range r = IntegerSequence.range(start, max, step); for (Integer i : r) { seq.add(i); @@ -91,7 +91,7 @@ public void testDecreasingRange() { final int max = -8; final int step = -3; - final List seq = new ArrayList<>(); + final List seq = new ArrayList(); final IntegerSequence.Range r = IntegerSequence.range(start, max, step); for (Integer i : r) { seq.add(i); @@ -110,7 +110,7 @@ public void testSingleElementRange() { final int max = 1; final int step = -1; - final List seq = new ArrayList<>(); + final List seq = new ArrayList(); final IntegerSequence.Range r = IntegerSequence.range(start, max, step); for (Integer i : r) { seq.add(i); @@ -126,7 +126,7 @@ public void testBasicRange() { final int start = -2; final int end = 4; - final List seq = new ArrayList<>(); + final List seq = new ArrayList(); for (Integer i : IntegerSequence.range(start, end)) { seq.add(i); } @@ -141,7 +141,7 @@ public void testEmptyRange() { final int start = 2; final int end = 0; - final List seq = new ArrayList<>(); + final List seq = new ArrayList(); final IntegerSequence.Range r = IntegerSequence.range(start, end); for (Integer i : r) { seq.add(i); @@ -157,7 +157,7 @@ public void testEmptyRangeNegativeStart() { final int max = -1; final int step = -1; - final List seq = new ArrayList<>(); + final List seq = new ArrayList(); final IntegerSequence.Range r = IntegerSequence.range(start, max, step); for (Integer i : r) { seq.add(i); diff --git a/src/test/java/org/apache/commons/math4/util/OpenIntToDoubleHashMapTest.java b/src/test/java/org/apache/commons/math4/util/OpenIntToDoubleHashMapTest.java index eea8560255..0841868cd4 100644 --- a/src/test/java/org/apache/commons/math4/util/OpenIntToDoubleHashMapTest.java +++ b/src/test/java/org/apache/commons/math4/util/OpenIntToDoubleHashMapTest.java @@ -37,7 +37,7 @@ @SuppressWarnings("boxing") public class OpenIntToDoubleHashMapTest { - private Map javaMap = new HashMap<>(); + private Map javaMap = new HashMap(); @Before public void setUp() throws Exception { @@ -60,7 +60,7 @@ public void setUp() throws Exception { } private Map generate() { - Map map = new HashMap<>(); + Map map = new HashMap(); Random r = new Random(); for (int i = 0; i < 2000; ++i) map.put(r.nextInt(), r.nextDouble()); @@ -168,7 +168,7 @@ public void testRemove2() { OpenIntToDoubleHashMap map = createFromJavaMap(); int mapSize = javaMap.size(); int count = 0; - Set keysInMap = new HashSet<>(javaMap.keySet()); + Set keysInMap = new HashSet(javaMap.keySet()); for (Map.Entry mapEntry : javaMap.entrySet()) { keysInMap.remove(mapEntry.getKey()); map.remove(mapEntry.getKey()); @@ -206,7 +206,7 @@ public void testRemoveAbsent() { * Returns a map with at least 100 elements where each element is absent from javaMap. */ private Map generateAbsent() { - Map generated = new HashMap<>(); + Map generated = new HashMap(); do { generated.putAll(generate()); for (Integer key : javaMap.keySet()) diff --git a/src/test/java/org/apache/commons/math4/util/OpenIntToFieldTest.java b/src/test/java/org/apache/commons/math4/util/OpenIntToFieldTest.java index d7de53c083..6df12dd465 100644 --- a/src/test/java/org/apache/commons/math4/util/OpenIntToFieldTest.java +++ b/src/test/java/org/apache/commons/math4/util/OpenIntToFieldTest.java @@ -38,7 +38,7 @@ @SuppressWarnings("boxing") public class OpenIntToFieldTest { - private Map javaMap = new HashMap<>(); + private Map javaMap = new HashMap(); private FractionField field = FractionField.getInstance(); @Before @@ -62,7 +62,7 @@ public void setUp() throws FractionConversionException { } private Map generate() { - Map map = new HashMap<>(); + Map map = new HashMap(); Random r = new Random(); double dd=0; for (int i = 0; i < 2000; ++i) @@ -76,7 +76,7 @@ private Map generate() { } private OpenIntToFieldHashMap createFromJavaMap(Field field) { - OpenIntToFieldHashMap map = new OpenIntToFieldHashMap<>(field); + OpenIntToFieldHashMap map = new OpenIntToFieldHashMap(field); for (Map.Entry mapEntry : javaMap.entrySet()) { map.put(mapEntry.getKey(), mapEntry.getValue()); } @@ -85,19 +85,19 @@ private OpenIntToFieldHashMap createFromJavaMap(Field field) @Test public void testPutAndGetWith0ExpectedSize() { - OpenIntToFieldHashMap map = new OpenIntToFieldHashMap<>(field,0); + OpenIntToFieldHashMap map = new OpenIntToFieldHashMap(field,0); assertPutAndGet(map); } @Test public void testPutAndGetWithExpectedSize() { - OpenIntToFieldHashMap map = new OpenIntToFieldHashMap<>(field,500); + OpenIntToFieldHashMap map = new OpenIntToFieldHashMap(field,500); assertPutAndGet(map); } @Test public void testPutAndGet() { - OpenIntToFieldHashMap map = new OpenIntToFieldHashMap<>(field); + OpenIntToFieldHashMap map = new OpenIntToFieldHashMap(field); assertPutAndGet(map); } @@ -149,7 +149,7 @@ public void testGetAbsent() { @Test public void testGetFromEmpty() { - OpenIntToFieldHashMap map = new OpenIntToFieldHashMap<>(field); + OpenIntToFieldHashMap map = new OpenIntToFieldHashMap(field); Assert.assertTrue(field.getZero().equals(map.get(5))); Assert.assertTrue(field.getZero().equals(map.get(0))); Assert.assertTrue(field.getZero().equals(map.get(50))); @@ -176,7 +176,7 @@ public void testRemove2() { OpenIntToFieldHashMap map = createFromJavaMap(field); int mapSize = javaMap.size(); int count = 0; - Set keysInMap = new HashSet<>(javaMap.keySet()); + Set keysInMap = new HashSet(javaMap.keySet()); for (Map.Entry mapEntry : javaMap.entrySet()) { keysInMap.remove(mapEntry.getKey()); map.remove(mapEntry.getKey()); @@ -192,7 +192,7 @@ public void testRemove2() { @Test public void testRemoveFromEmpty() { - OpenIntToFieldHashMap map = new OpenIntToFieldHashMap<>(field); + OpenIntToFieldHashMap map = new OpenIntToFieldHashMap(field); Assert.assertTrue(field.getZero().equals(map.remove(50))); } @@ -214,7 +214,7 @@ public void testRemoveAbsent() { * Returns a map with at least 100 elements where each element is absent from javaMap. */ private Map generateAbsent() { - Map generated = new HashMap<>(); + Map generated = new HashMap(); do { generated.putAll(generate()); for (Integer key : javaMap.keySet()) @@ -226,7 +226,7 @@ private Map generateAbsent() { @Test public void testCopy() { OpenIntToFieldHashMap copy = - new OpenIntToFieldHashMap<>(createFromJavaMap(field)); + new OpenIntToFieldHashMap(createFromJavaMap(field)); Assert.assertEquals(javaMap.size(), copy.size()); for (Map.Entry mapEntry : javaMap.entrySet()) @@ -292,7 +292,7 @@ public void testConcurrentModification() { */ @Test public void testPutKeysWithCollisions() { - OpenIntToFieldHashMap map = new OpenIntToFieldHashMap<>(field); + OpenIntToFieldHashMap map = new OpenIntToFieldHashMap(field); int key1 = -1996012590; Fraction value1 = new Fraction(1); map.put(key1, value1); @@ -316,7 +316,7 @@ public void testPutKeysWithCollisions() { */ @Test public void testPutKeysWithCollision2() { - OpenIntToFieldHashMapmap = new OpenIntToFieldHashMap<>(field); + OpenIntToFieldHashMapmap = new OpenIntToFieldHashMap(field); int key1 = 837989881; Fraction value1 = new Fraction(1); map.put(key1, value1); diff --git a/src/test/java/org/apache/commons/math4/util/PairTest.java b/src/test/java/org/apache/commons/math4/util/PairTest.java index ba6798ef3c..904c93cbce 100644 --- a/src/test/java/org/apache/commons/math4/util/PairTest.java +++ b/src/test/java/org/apache/commons/math4/util/PairTest.java @@ -25,7 +25,7 @@ public class PairTest { @Test public void testAccessor() { final Pair p - = new Pair<>(new Integer(1), new Double(2)); + = new Pair(new Integer(1), new Double(2)); Assert.assertEquals(new Integer(1), p.getKey()); Assert.assertEquals(2, p.getValue().doubleValue(), Math.ulp(1d)); } @@ -33,7 +33,7 @@ public void testAccessor() { @Test public void testAccessor2() { final Pair p - = new Pair<>(new Integer(1), new Double(2)); + = new Pair(new Integer(1), new Double(2)); // Check that both APIs refer to the same data. @@ -43,19 +43,19 @@ public void testAccessor2() { @Test public void testEquals() { - Pair p1 = new Pair<>(null, null); + Pair p1 = new Pair(null, null); Assert.assertFalse(p1.equals(null)); - Pair p2 = new Pair<>(null, null); + Pair p2 = new Pair(null, null); Assert.assertTrue(p1.equals(p2)); - p1 = new Pair<>(new Integer(1), new Double(2)); + p1 = new Pair(new Integer(1), new Double(2)); Assert.assertFalse(p1.equals(p2)); - p2 = new Pair<>(new Integer(1), new Double(2)); + p2 = new Pair(new Integer(1), new Double(2)); Assert.assertTrue(p1.equals(p2)); - Pair p3 = new Pair<>(new Integer(1), new Float(2)); + Pair p3 = new Pair(new Integer(1), new Float(2)); Assert.assertFalse(p1.equals(p3)); } @@ -64,8 +64,8 @@ public void testHashCode() { final MyInteger m1 = new MyInteger(1); final MyInteger m2 = new MyInteger(1); - final Pair p1 = new Pair<>(m1, m1); - final Pair p2 = new Pair<>(m2, m2); + final Pair p1 = new Pair(m1, m1); + final Pair p2 = new Pair(m2, m2); // Same contents, same hash code. Assert.assertTrue(p1.hashCode() == p2.hashCode()); @@ -76,15 +76,15 @@ public void testHashCode() { @Test public void testToString() { - Assert.assertEquals("[null, null]", new Pair<>(null, null).toString()); - Assert.assertEquals("[foo, 3]", new Pair<>("foo", 3).toString()); + Assert.assertEquals("[null, null]", new Pair(null, null).toString()); + Assert.assertEquals("[foo, 3]", new Pair("foo", 3).toString()); } @Test public void testCreate() { final Pair p1 = Pair.create("foo", 3); Assert.assertNotNull(p1); - final Pair p2 = new Pair<>("foo", 3); + final Pair p2 = new Pair("foo", 3); Assert.assertEquals(p2, p1); }