http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/distribution/LevyDistributionTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/distribution/LevyDistributionTest.java b/src/test/java/org/apache/commons/math4/distribution/LevyDistributionTest.java index 659e418..0e25259 100644 --- a/src/test/java/org/apache/commons/math4/distribution/LevyDistributionTest.java +++ b/src/test/java/org/apache/commons/math4/distribution/LevyDistributionTest.java @@ -17,7 +17,7 @@ package org.apache.commons.math4.distribution; import org.apache.commons.math4.distribution.LevyDistribution; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/distribution/LogisticsDistributionTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/distribution/LogisticsDistributionTest.java b/src/test/java/org/apache/commons/math4/distribution/LogisticsDistributionTest.java index b43daac..b866dd9 100644 --- a/src/test/java/org/apache/commons/math4/distribution/LogisticsDistributionTest.java +++ b/src/test/java/org/apache/commons/math4/distribution/LogisticsDistributionTest.java @@ -17,7 +17,7 @@ package org.apache.commons.math4.distribution; import org.apache.commons.math4.distribution.LogisticDistribution; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/distribution/NakagamiDistributionTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/distribution/NakagamiDistributionTest.java b/src/test/java/org/apache/commons/math4/distribution/NakagamiDistributionTest.java index aa7e927..75628de 100644 --- a/src/test/java/org/apache/commons/math4/distribution/NakagamiDistributionTest.java +++ b/src/test/java/org/apache/commons/math4/distribution/NakagamiDistributionTest.java @@ -17,7 +17,7 @@ package org.apache.commons.math4.distribution; import org.apache.commons.math4.distribution.NakagamiDistribution; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/distribution/UniformIntegerDistributionTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/distribution/UniformIntegerDistributionTest.java b/src/test/java/org/apache/commons/math4/distribution/UniformIntegerDistributionTest.java index d1fc316..7d552dc 100644 --- a/src/test/java/org/apache/commons/math4/distribution/UniformIntegerDistributionTest.java +++ b/src/test/java/org/apache/commons/math4/distribution/UniformIntegerDistributionTest.java @@ -22,7 +22,7 @@ import org.junit.Test; import org.apache.commons.math4.distribution.IntegerDistribution; import org.apache.commons.math4.distribution.UniformIntegerDistribution; import org.apache.commons.math4.exception.NumberIsTooLargeException; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; /** * Test cases for UniformIntegerDistribution. See class javadoc for http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/filter/KalmanFilterTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/filter/KalmanFilterTest.java b/src/test/java/org/apache/commons/math4/filter/KalmanFilterTest.java index 3bb50cb..744fe41 100644 --- a/src/test/java/org/apache/commons/math4/filter/KalmanFilterTest.java +++ b/src/test/java/org/apache/commons/math4/filter/KalmanFilterTest.java @@ -29,7 +29,7 @@ import org.apache.commons.math4.linear.RealMatrix; import org.apache.commons.math4.linear.RealVector; import org.apache.commons.rng.simple.RandomSource; import org.apache.commons.math4.util.FastMath; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/fitting/WeightedObservedPointsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/fitting/WeightedObservedPointsTest.java b/src/test/java/org/apache/commons/math4/fitting/WeightedObservedPointsTest.java index 773e883..1022847 100644 --- a/src/test/java/org/apache/commons/math4/fitting/WeightedObservedPointsTest.java +++ b/src/test/java/org/apache/commons/math4/fitting/WeightedObservedPointsTest.java @@ -22,7 +22,7 @@ import org.junit.Assert; import org.junit.Test; import org.apache.commons.math4.fitting.WeightedObservedPoint; import org.apache.commons.math4.fitting.WeightedObservedPoints; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; /** * Tests {@link WeightedObservedPoints}. http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/fitting/leastsquares/EvaluationTest.java ---------------------------------------------------------------------- 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 f8bcc9d..43dd903 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 @@ -31,7 +31,7 @@ import org.apache.commons.math4.linear.RealVector; import org.apache.commons.math4.linear.SingularMatrixException; import org.apache.commons.math4.util.FastMath; import org.apache.commons.math4.util.Pair; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java ---------------------------------------------------------------------- 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 5d4a4d7..d0b9d4d 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 @@ -35,7 +35,7 @@ import org.apache.commons.math4.linear.RealVector; import org.apache.commons.math4.linear.SingularMatrixException; import org.apache.commons.math4.optim.ConvergenceChecker; import org.apache.commons.math4.util.FastMath; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalTest.java index 3c85434..e4a88d3 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalTest.java @@ -19,7 +19,7 @@ package org.apache.commons.math4.geometry.euclidean.oned; import org.apache.commons.math4.geometry.euclidean.oned.Interval; import org.apache.commons.math4.geometry.partitioning.Region; import org.apache.commons.math4.util.FastMath; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.apache.commons.math4.exception.NumberIsTooSmallException; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java ---------------------------------------------------------------------- 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 b7c8399..de5d9e0 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 @@ -25,7 +25,7 @@ import org.apache.commons.math4.geometry.euclidean.oned.Vector1D; import org.apache.commons.math4.geometry.partitioning.Region; import org.apache.commons.math4.geometry.partitioning.RegionFactory; import org.apache.commons.math4.util.FastMath; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java index 0bf6b84..7029d94 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java @@ -27,7 +27,7 @@ import org.apache.commons.math4.exception.MathArithmeticException; import org.apache.commons.math4.geometry.Space; import org.apache.commons.math4.geometry.euclidean.oned.Vector1D; import org.apache.commons.math4.util.FastMath; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java ---------------------------------------------------------------------- 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 e832ea8..1d7d248 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 @@ -30,7 +30,7 @@ import org.apache.commons.math4.geometry.euclidean.threed.Vector3D; import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.simple.RandomSource; import org.apache.commons.math4.util.FastMath; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PLYParser.java ---------------------------------------------------------------------- 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 7670e69..24ac99c 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 @@ -27,7 +27,7 @@ import java.util.Arrays; import java.util.List; import java.util.StringTokenizer; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; /** This class is a small and incomplete parser for PLY files. * <p> http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DTest.java index dbf1b3e..530a06a 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DTest.java @@ -31,7 +31,7 @@ import org.apache.commons.math4.geometry.euclidean.threed.Vector3D; import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.simple.RandomSource; import org.apache.commons.math4.util.FastMath; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java ---------------------------------------------------------------------- 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 818c109..46d0aa4 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 @@ -33,7 +33,7 @@ import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.simple.RandomSource; import org.apache.commons.math4.util.FastMath; import org.apache.commons.math4.util.MathArrays; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Before; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/geometry/spherical/oned/ArcTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/spherical/oned/ArcTest.java b/src/test/java/org/apache/commons/math4/geometry/spherical/oned/ArcTest.java index 0f707bb..3a2e6b1 100644 --- a/src/test/java/org/apache/commons/math4/geometry/spherical/oned/ArcTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/spherical/oned/ArcTest.java @@ -21,7 +21,7 @@ import org.apache.commons.math4.geometry.partitioning.Region; import org.apache.commons.math4.geometry.spherical.oned.Arc; import org.apache.commons.math4.util.FastMath; import org.apache.commons.math4.util.MathUtils; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSetTest.java ---------------------------------------------------------------------- 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 6f86857..663af6a 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 @@ -36,7 +36,7 @@ import org.apache.commons.math4.geometry.spherical.oned.Sphere1D; import org.apache.commons.math4.geometry.spherical.oned.SubLimitAngle; import org.apache.commons.math4.util.FastMath; import org.apache.commons.math4.util.MathUtils; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/linear/DiagonalMatrixTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/linear/DiagonalMatrixTest.java b/src/test/java/org/apache/commons/math4/linear/DiagonalMatrixTest.java index fb41169..388fc07 100644 --- a/src/test/java/org/apache/commons/math4/linear/DiagonalMatrixTest.java +++ b/src/test/java/org/apache/commons/math4/linear/DiagonalMatrixTest.java @@ -27,7 +27,7 @@ import org.apache.commons.math4.linear.MatrixUtils; import org.apache.commons.math4.linear.RealMatrix; import org.apache.commons.math4.linear.RealVector; import org.apache.commons.math4.linear.SingularMatrixException; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/linear/EigenDecompositionTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/linear/EigenDecompositionTest.java b/src/test/java/org/apache/commons/math4/linear/EigenDecompositionTest.java index e189d19..df472a2 100644 --- a/src/test/java/org/apache/commons/math4/linear/EigenDecompositionTest.java +++ b/src/test/java/org/apache/commons/math4/linear/EigenDecompositionTest.java @@ -32,7 +32,7 @@ import org.apache.commons.math4.linear.RealVector; import org.apache.commons.math4.linear.TriDiagonalTransformer; import org.apache.commons.math4.util.FastMath; import org.apache.commons.math4.util.MathArrays; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.apache.commons.rng.simple.RandomSource; import org.junit.After; import org.junit.Assert; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/linear/EigenSolverTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/linear/EigenSolverTest.java b/src/test/java/org/apache/commons/math4/linear/EigenSolverTest.java index 541a8a7..cf0794f 100644 --- a/src/test/java/org/apache/commons/math4/linear/EigenSolverTest.java +++ b/src/test/java/org/apache/commons/math4/linear/EigenSolverTest.java @@ -25,7 +25,7 @@ import org.apache.commons.math4.linear.EigenDecomposition; import org.apache.commons.math4.linear.MatrixUtils; import org.apache.commons.math4.linear.RealMatrix; import org.apache.commons.math4.linear.SingularMatrixException; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Test; import org.junit.Assert; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/optim/linear/SimplexSolverTest.java ---------------------------------------------------------------------- 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 503f782..c540652 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 @@ -35,7 +35,7 @@ import org.apache.commons.math4.optim.linear.SimplexSolver; import org.apache.commons.math4.optim.linear.SolutionCallback; import org.apache.commons.math4.optim.linear.UnboundedSolutionException; import org.apache.commons.math4.optim.nonlinear.scalar.GoalType; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Test; import org.junit.Assert; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/stat/StatUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/stat/StatUtilsTest.java b/src/test/java/org/apache/commons/math4/stat/StatUtilsTest.java index eae66fb..d10c8f4 100644 --- a/src/test/java/org/apache/commons/math4/stat/StatUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/stat/StatUtilsTest.java @@ -23,7 +23,7 @@ import org.apache.commons.math4.exception.NullArgumentException; import org.apache.commons.math4.stat.StatUtils; import org.apache.commons.math4.stat.descriptive.DescriptiveStatistics; import org.apache.commons.math4.util.FastMath; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatisticsTest.java ---------------------------------------------------------------------- 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 7767605..2f31b4c 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 @@ -26,7 +26,7 @@ import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.math4.distribution.AbstractRealDistribution; import org.apache.commons.math4.distribution.UniformIntegerDistribution; import org.apache.commons.math4.distribution.UniformRealDistribution; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.apache.commons.rng.simple.RandomSource; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java index e11e171..d5a4ae4 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java @@ -28,7 +28,7 @@ import org.apache.commons.math4.stat.descriptive.rank.Min; import org.apache.commons.math4.stat.descriptive.rank.Percentile; import org.apache.commons.math4.stat.descriptive.summary.Sum; import org.apache.commons.math4.stat.descriptive.summary.SumOfSquares; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/transform/FastHadamardTransformerTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/transform/FastHadamardTransformerTest.java b/src/test/java/org/apache/commons/math4/transform/FastHadamardTransformerTest.java index 8fe0173..4513732 100644 --- a/src/test/java/org/apache/commons/math4/transform/FastHadamardTransformerTest.java +++ b/src/test/java/org/apache/commons/math4/transform/FastHadamardTransformerTest.java @@ -19,7 +19,7 @@ package org.apache.commons.math4.transform; import org.apache.commons.math4.exception.MathIllegalArgumentException; import org.apache.commons.math4.transform.FastHadamardTransformer; import org.apache.commons.math4.transform.TransformType; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/util/FastMathStrictComparisonTest.java ---------------------------------------------------------------------- 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 d38d42e..38e39ca 100644 --- a/src/test/java/org/apache/commons/math4/util/FastMathStrictComparisonTest.java +++ b/src/test/java/org/apache/commons/math4/util/FastMathStrictComparisonTest.java @@ -26,7 +26,7 @@ import java.util.List; import org.apache.commons.math4.exception.MathArithmeticException; import org.apache.commons.math4.util.FastMath; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/util/FastMathTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/util/FastMathTest.java b/src/test/java/org/apache/commons/math4/util/FastMathTest.java index 125a02d..702510a 100644 --- a/src/test/java/org/apache/commons/math4/util/FastMathTest.java +++ b/src/test/java/org/apache/commons/math4/util/FastMathTest.java @@ -27,6 +27,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; +import org.apache.commons.numbers.core.Precision; import org.apache.commons.math4.TestUtils; import org.apache.commons.math4.dfp.Dfp; import org.apache.commons.math4.dfp.DfpField; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/util/MathArraysTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/util/MathArraysTest.java b/src/test/java/org/apache/commons/math4/util/MathArraysTest.java index 0f0f06c..950b980 100644 --- a/src/test/java/org/apache/commons/math4/util/MathArraysTest.java +++ b/src/test/java/org/apache/commons/math4/util/MathArraysTest.java @@ -29,7 +29,7 @@ import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.simple.RandomSource; import org.apache.commons.math4.util.FastMath; import org.apache.commons.math4.util.MathArrays; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/util/OpenIntToDoubleHashMapTest.java ---------------------------------------------------------------------- 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 5da2f71..4223f1d 100644 --- a/src/test/java/org/apache/commons/math4/util/OpenIntToDoubleHashMapTest.java +++ b/src/test/java/org/apache/commons/math4/util/OpenIntToDoubleHashMapTest.java @@ -25,7 +25,7 @@ import java.util.Random; import java.util.Set; import org.apache.commons.math4.util.OpenIntToDoubleHashMap; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; import org.junit.Assert; import org.junit.Before; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/test/java/org/apache/commons/math4/util/PrecisionTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/util/PrecisionTest.java b/src/test/java/org/apache/commons/math4/util/PrecisionTest.java deleted file mode 100644 index 3d133d7..0000000 --- a/src/test/java/org/apache/commons/math4/util/PrecisionTest.java +++ /dev/null @@ -1,553 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law - * or agreed to in writing, software distributed under the License is - * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.apache.commons.math4.util; - -import java.math.BigDecimal; - -import org.apache.commons.math4.TestUtils; -import org.apache.commons.math4.exception.MathArithmeticException; -import org.apache.commons.math4.exception.MathIllegalArgumentException; -import org.apache.commons.math4.util.FastMath; -import org.apache.commons.math4.util.Precision; -import org.junit.Assert; -import org.junit.Test; - -/** - * Test cases for the {@link Precision} class. - * - */ -public class PrecisionTest { - @Test - public void testEqualsWithRelativeTolerance() { - Assert.assertTrue(Precision.equalsWithRelativeTolerance(0d, 0d, 0d)); - Assert.assertTrue(Precision.equalsWithRelativeTolerance(0d, 1 / Double.NEGATIVE_INFINITY, 0d)); - - final double eps = 1e-14; - Assert.assertFalse(Precision.equalsWithRelativeTolerance(1.987654687654968, 1.987654687654988, eps)); - Assert.assertTrue(Precision.equalsWithRelativeTolerance(1.987654687654968, 1.987654687654987, eps)); - Assert.assertFalse(Precision.equalsWithRelativeTolerance(1.987654687654968, 1.987654687654948, eps)); - Assert.assertTrue(Precision.equalsWithRelativeTolerance(1.987654687654968, 1.987654687654949, eps)); - - Assert.assertFalse(Precision.equalsWithRelativeTolerance(Precision.SAFE_MIN, 0.0, eps)); - - Assert.assertFalse(Precision.equalsWithRelativeTolerance(1.0000000000001e-300, 1e-300, eps)); - Assert.assertTrue(Precision.equalsWithRelativeTolerance(1.00000000000001e-300, 1e-300, eps)); - - Assert.assertFalse(Precision.equalsWithRelativeTolerance(Double.NEGATIVE_INFINITY, 1.23, eps)); - Assert.assertFalse(Precision.equalsWithRelativeTolerance(Double.POSITIVE_INFINITY, 1.23, eps)); - - Assert.assertTrue(Precision.equalsWithRelativeTolerance(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, eps)); - Assert.assertTrue(Precision.equalsWithRelativeTolerance(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, eps)); - Assert.assertFalse(Precision.equalsWithRelativeTolerance(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, eps)); - - Assert.assertFalse(Precision.equalsWithRelativeTolerance(Double.NaN, 1.23, eps)); - Assert.assertFalse(Precision.equalsWithRelativeTolerance(Double.NaN, Double.NaN, eps)); - } - - @Test - public void testEqualsIncludingNaN() { - double[] testArray = { - Double.NaN, - Double.POSITIVE_INFINITY, - Double.NEGATIVE_INFINITY, - 1d, - 0d }; - for (int i = 0; i < testArray.length; i++) { - for (int j = 0; j < testArray.length; j++) { - if (i == j) { - Assert.assertTrue(Precision.equalsIncludingNaN(testArray[i], testArray[j])); - Assert.assertTrue(Precision.equalsIncludingNaN(testArray[j], testArray[i])); - } else { - Assert.assertTrue(!Precision.equalsIncludingNaN(testArray[i], testArray[j])); - Assert.assertTrue(!Precision.equalsIncludingNaN(testArray[j], testArray[i])); - } - } - } - } - - @Test - public void testEqualsWithAllowedDelta() { - Assert.assertTrue(Precision.equals(153.0000, 153.0000, .0625)); - Assert.assertTrue(Precision.equals(153.0000, 153.0625, .0625)); - Assert.assertTrue(Precision.equals(152.9375, 153.0000, .0625)); - Assert.assertFalse(Precision.equals(153.0000, 153.0625, .0624)); - Assert.assertFalse(Precision.equals(152.9374, 153.0000, .0625)); - Assert.assertFalse(Precision.equals(Double.NaN, Double.NaN, 1.0)); - Assert.assertTrue(Precision.equals(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0)); - Assert.assertTrue(Precision.equals(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 1.0)); - Assert.assertFalse(Precision.equals(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0)); - } - - @Test - public void testMath475() { - final double a = 1.7976931348623182E16; - final double b = FastMath.nextUp(a); - - double diff = FastMath.abs(a - b); - // Because they are adjacent floating point numbers, "a" and "b" are - // considered equal even though the allowed error is smaller than - // their difference. - Assert.assertTrue(Precision.equals(a, b, 0.5 * diff)); - - final double c = FastMath.nextUp(b); - diff = FastMath.abs(a - c); - // Because "a" and "c" are not adjacent, the tolerance is taken into - // account for assessing equality. - Assert.assertTrue(Precision.equals(a, c, diff)); - Assert.assertFalse(Precision.equals(a, c, (1 - 1e-16) * diff)); - } - - @Test - public void testEqualsIncludingNaNWithAllowedDelta() { - Assert.assertTrue(Precision.equalsIncludingNaN(153.0000, 153.0000, .0625)); - Assert.assertTrue(Precision.equalsIncludingNaN(153.0000, 153.0625, .0625)); - Assert.assertTrue(Precision.equalsIncludingNaN(152.9375, 153.0000, .0625)); - Assert.assertTrue(Precision.equalsIncludingNaN(Double.NaN, Double.NaN, 1.0)); - Assert.assertTrue(Precision.equalsIncludingNaN(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0)); - Assert.assertTrue(Precision.equalsIncludingNaN(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 1.0)); - Assert.assertFalse(Precision.equalsIncludingNaN(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0)); - Assert.assertFalse(Precision.equalsIncludingNaN(153.0000, 153.0625, .0624)); - Assert.assertFalse(Precision.equalsIncludingNaN(152.9374, 153.0000, .0625)); - } - - // Tests for floating point equality - @Test - public void testFloatEqualsWithAllowedUlps() { - Assert.assertTrue("+0.0f == -0.0f",Precision.equals(0.0f, -0.0f)); - Assert.assertTrue("+0.0f == -0.0f (1 ulp)",Precision.equals(0.0f, -0.0f, 1)); - float oneFloat = 1.0f; - Assert.assertTrue("1.0f == 1.0f + 1 ulp",Precision.equals(oneFloat, Float.intBitsToFloat(1 + Float.floatToIntBits(oneFloat)))); - Assert.assertTrue("1.0f == 1.0f + 1 ulp (1 ulp)",Precision.equals(oneFloat, Float.intBitsToFloat(1 + Float.floatToIntBits(oneFloat)), 1)); - Assert.assertFalse("1.0f != 1.0f + 2 ulp (1 ulp)",Precision.equals(oneFloat, Float.intBitsToFloat(2 + Float.floatToIntBits(oneFloat)), 1)); - - Assert.assertTrue(Precision.equals(153.0f, 153.0f, 1)); - - // These tests need adjusting for floating point precision -// Assert.assertTrue(Precision.equals(153.0f, 153.00000000000003f, 1)); -// Assert.assertFalse(Precision.equals(153.0f, 153.00000000000006f, 1)); -// Assert.assertTrue(Precision.equals(153.0f, 152.99999999999997f, 1)); -// Assert.assertFalse(Precision.equals(153f, 152.99999999999994f, 1)); -// -// Assert.assertTrue(Precision.equals(-128.0f, -127.99999999999999f, 1)); -// Assert.assertFalse(Precision.equals(-128.0f, -127.99999999999997f, 1)); -// Assert.assertTrue(Precision.equals(-128.0f, -128.00000000000003f, 1)); -// Assert.assertFalse(Precision.equals(-128.0f, -128.00000000000006f, 1)); - - Assert.assertTrue(Precision.equals(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, 1)); - Assert.assertTrue(Precision.equals(Double.MAX_VALUE, Float.POSITIVE_INFINITY, 1)); - - Assert.assertTrue(Precision.equals(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY, 1)); - Assert.assertTrue(Precision.equals(-Float.MAX_VALUE, Float.NEGATIVE_INFINITY, 1)); - - Assert.assertFalse(Precision.equals(Float.NaN, Float.NaN, 1)); - Assert.assertFalse(Precision.equals(Float.NaN, Float.NaN, 0)); - Assert.assertFalse(Precision.equals(Float.NaN, 0, 0)); - Assert.assertFalse(Precision.equals(Float.NaN, Float.POSITIVE_INFINITY, 0)); - Assert.assertFalse(Precision.equals(Float.NaN, Float.NEGATIVE_INFINITY, 0)); - - Assert.assertFalse(Precision.equals(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, 100000)); - } - - @Test - public void testEqualsWithAllowedUlps() { - Assert.assertTrue(Precision.equals(0.0, -0.0, 1)); - - Assert.assertTrue(Precision.equals(1.0, 1 + FastMath.ulp(1d), 1)); - Assert.assertFalse(Precision.equals(1.0, 1 + 2 * FastMath.ulp(1d), 1)); - - final double nUp1 = FastMath.nextAfter(1d, Double.POSITIVE_INFINITY); - final double nnUp1 = FastMath.nextAfter(nUp1, Double.POSITIVE_INFINITY); - Assert.assertTrue(Precision.equals(1.0, nUp1, 1)); - Assert.assertTrue(Precision.equals(nUp1, nnUp1, 1)); - Assert.assertFalse(Precision.equals(1.0, nnUp1, 1)); - - Assert.assertTrue(Precision.equals(0.0, FastMath.ulp(0d), 1)); - Assert.assertTrue(Precision.equals(0.0, -FastMath.ulp(0d), 1)); - - Assert.assertTrue(Precision.equals(153.0, 153.0, 1)); - - Assert.assertTrue(Precision.equals(153.0, 153.00000000000003, 1)); - Assert.assertFalse(Precision.equals(153.0, 153.00000000000006, 1)); - Assert.assertTrue(Precision.equals(153.0, 152.99999999999997, 1)); - Assert.assertFalse(Precision.equals(153, 152.99999999999994, 1)); - - Assert.assertTrue(Precision.equals(-128.0, -127.99999999999999, 1)); - Assert.assertFalse(Precision.equals(-128.0, -127.99999999999997, 1)); - Assert.assertTrue(Precision.equals(-128.0, -128.00000000000003, 1)); - Assert.assertFalse(Precision.equals(-128.0, -128.00000000000006, 1)); - - Assert.assertTrue(Precision.equals(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 1)); - Assert.assertTrue(Precision.equals(Double.MAX_VALUE, Double.POSITIVE_INFINITY, 1)); - - Assert.assertTrue(Precision.equals(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 1)); - Assert.assertTrue(Precision.equals(-Double.MAX_VALUE, Double.NEGATIVE_INFINITY, 1)); - - Assert.assertFalse(Precision.equals(Double.NaN, Double.NaN, 1)); - Assert.assertFalse(Precision.equals(Double.NaN, Double.NaN, 0)); - Assert.assertFalse(Precision.equals(Double.NaN, 0, 0)); - Assert.assertFalse(Precision.equals(Double.NaN, Double.POSITIVE_INFINITY, 0)); - Assert.assertFalse(Precision.equals(Double.NaN, Double.NEGATIVE_INFINITY, 0)); - - Assert.assertFalse(Precision.equals(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 100000)); - } - - @Test - public void testEqualsIncludingNaNWithAllowedUlps() { - Assert.assertTrue(Precision.equalsIncludingNaN(0.0, -0.0, 1)); - - Assert.assertTrue(Precision.equalsIncludingNaN(1.0, 1 + FastMath.ulp(1d), 1)); - Assert.assertFalse(Precision.equalsIncludingNaN(1.0, 1 + 2 * FastMath.ulp(1d), 1)); - - final double nUp1 = FastMath.nextAfter(1d, Double.POSITIVE_INFINITY); - final double nnUp1 = FastMath.nextAfter(nUp1, Double.POSITIVE_INFINITY); - Assert.assertTrue(Precision.equalsIncludingNaN(1.0, nUp1, 1)); - Assert.assertTrue(Precision.equalsIncludingNaN(nUp1, nnUp1, 1)); - Assert.assertFalse(Precision.equalsIncludingNaN(1.0, nnUp1, 1)); - - Assert.assertTrue(Precision.equalsIncludingNaN(0.0, FastMath.ulp(0d), 1)); - Assert.assertTrue(Precision.equalsIncludingNaN(0.0, -FastMath.ulp(0d), 1)); - - Assert.assertTrue(Precision.equalsIncludingNaN(153.0, 153.0, 1)); - - Assert.assertTrue(Precision.equalsIncludingNaN(153.0, 153.00000000000003, 1)); - Assert.assertFalse(Precision.equalsIncludingNaN(153.0, 153.00000000000006, 1)); - Assert.assertTrue(Precision.equalsIncludingNaN(153.0, 152.99999999999997, 1)); - Assert.assertFalse(Precision.equalsIncludingNaN(153, 152.99999999999994, 1)); - - Assert.assertTrue(Precision.equalsIncludingNaN(-128.0, -127.99999999999999, 1)); - Assert.assertFalse(Precision.equalsIncludingNaN(-128.0, -127.99999999999997, 1)); - Assert.assertTrue(Precision.equalsIncludingNaN(-128.0, -128.00000000000003, 1)); - Assert.assertFalse(Precision.equalsIncludingNaN(-128.0, -128.00000000000006, 1)); - - Assert.assertTrue(Precision.equalsIncludingNaN(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 1)); - Assert.assertTrue(Precision.equalsIncludingNaN(Double.MAX_VALUE, Double.POSITIVE_INFINITY, 1)); - - Assert.assertTrue(Precision.equalsIncludingNaN(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 1)); - Assert.assertTrue(Precision.equalsIncludingNaN(-Double.MAX_VALUE, Double.NEGATIVE_INFINITY, 1)); - - Assert.assertTrue(Precision.equalsIncludingNaN(Double.NaN, Double.NaN, 1)); - - Assert.assertFalse(Precision.equalsIncludingNaN(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 100000)); - } - - @Test - public void testCompareToEpsilon() { - Assert.assertEquals(0, Precision.compareTo(152.33, 152.32, .011)); - Assert.assertTrue(Precision.compareTo(152.308, 152.32, .011) < 0); - Assert.assertTrue(Precision.compareTo(152.33, 152.318, .011) > 0); - Assert.assertEquals(0, Precision.compareTo(Double.MIN_VALUE, +0.0, Double.MIN_VALUE)); - Assert.assertEquals(0, Precision.compareTo(Double.MIN_VALUE, -0.0, Double.MIN_VALUE)); - } - - @Test - public void testCompareToMaxUlps() { - double a = 152.32; - double delta = FastMath.ulp(a); - for (int i = 0; i <= 10; ++i) { - if (i <= 5) { - Assert.assertEquals( 0, Precision.compareTo(a, a + i * delta, 5)); - Assert.assertEquals( 0, Precision.compareTo(a, a - i * delta, 5)); - } else { - Assert.assertEquals(-1, Precision.compareTo(a, a + i * delta, 5)); - Assert.assertEquals(+1, Precision.compareTo(a, a - i * delta, 5)); - } - } - - Assert.assertEquals( 0, Precision.compareTo(-0.0, 0.0, 0)); - - Assert.assertEquals(-1, Precision.compareTo(-Double.MIN_VALUE, -0.0, 0)); - Assert.assertEquals( 0, Precision.compareTo(-Double.MIN_VALUE, -0.0, 1)); - Assert.assertEquals(-1, Precision.compareTo(-Double.MIN_VALUE, +0.0, 0)); - Assert.assertEquals( 0, Precision.compareTo(-Double.MIN_VALUE, +0.0, 1)); - - Assert.assertEquals(+1, Precision.compareTo( Double.MIN_VALUE, -0.0, 0)); - Assert.assertEquals( 0, Precision.compareTo( Double.MIN_VALUE, -0.0, 1)); - Assert.assertEquals(+1, Precision.compareTo( Double.MIN_VALUE, +0.0, 0)); - Assert.assertEquals( 0, Precision.compareTo( Double.MIN_VALUE, +0.0, 1)); - - Assert.assertEquals(-1, Precision.compareTo(-Double.MIN_VALUE, Double.MIN_VALUE, 0)); - Assert.assertEquals(-1, Precision.compareTo(-Double.MIN_VALUE, Double.MIN_VALUE, 1)); - Assert.assertEquals( 0, Precision.compareTo(-Double.MIN_VALUE, Double.MIN_VALUE, 2)); - - Assert.assertEquals( 0, Precision.compareTo(Double.MAX_VALUE, Double.POSITIVE_INFINITY, 1)); - Assert.assertEquals(-1, Precision.compareTo(Double.MAX_VALUE, Double.POSITIVE_INFINITY, 0)); - - Assert.assertEquals(+1, Precision.compareTo(Double.MAX_VALUE, Double.NaN, Integer.MAX_VALUE)); - Assert.assertEquals(+1, Precision.compareTo(Double.NaN, Double.MAX_VALUE, Integer.MAX_VALUE)); - } - - @Test - public void testRoundDouble() { - double x = 1.234567890; - Assert.assertEquals(1.23, Precision.round(x, 2), 0.0); - Assert.assertEquals(1.235, Precision.round(x, 3), 0.0); - Assert.assertEquals(1.2346, Precision.round(x, 4), 0.0); - - // JIRA MATH-151 - Assert.assertEquals(39.25, Precision.round(39.245, 2), 0.0); - Assert.assertEquals(39.24, Precision.round(39.245, 2, BigDecimal.ROUND_DOWN), 0.0); - double xx = 39.0; - xx += 245d / 1000d; - Assert.assertEquals(39.25, Precision.round(xx, 2), 0.0); - - // BZ 35904 - Assert.assertEquals(30.1d, Precision.round(30.095d, 2), 0.0d); - Assert.assertEquals(30.1d, Precision.round(30.095d, 1), 0.0d); - Assert.assertEquals(33.1d, Precision.round(33.095d, 1), 0.0d); - Assert.assertEquals(33.1d, Precision.round(33.095d, 2), 0.0d); - Assert.assertEquals(50.09d, Precision.round(50.085d, 2), 0.0d); - Assert.assertEquals(50.19d, Precision.round(50.185d, 2), 0.0d); - Assert.assertEquals(50.01d, Precision.round(50.005d, 2), 0.0d); - Assert.assertEquals(30.01d, Precision.round(30.005d, 2), 0.0d); - Assert.assertEquals(30.65d, Precision.round(30.645d, 2), 0.0d); - - Assert.assertEquals(1.24, Precision.round(x, 2, BigDecimal.ROUND_CEILING), 0.0); - Assert.assertEquals(1.235, Precision.round(x, 3, BigDecimal.ROUND_CEILING), 0.0); - Assert.assertEquals(1.2346, Precision.round(x, 4, BigDecimal.ROUND_CEILING), 0.0); - Assert.assertEquals(-1.23, Precision.round(-x, 2, BigDecimal.ROUND_CEILING), 0.0); - Assert.assertEquals(-1.234, Precision.round(-x, 3, BigDecimal.ROUND_CEILING), 0.0); - Assert.assertEquals(-1.2345, Precision.round(-x, 4, BigDecimal.ROUND_CEILING), 0.0); - - Assert.assertEquals(1.23, Precision.round(x, 2, BigDecimal.ROUND_DOWN), 0.0); - Assert.assertEquals(1.234, Precision.round(x, 3, BigDecimal.ROUND_DOWN), 0.0); - Assert.assertEquals(1.2345, Precision.round(x, 4, BigDecimal.ROUND_DOWN), 0.0); - Assert.assertEquals(-1.23, Precision.round(-x, 2, BigDecimal.ROUND_DOWN), 0.0); - Assert.assertEquals(-1.234, Precision.round(-x, 3, BigDecimal.ROUND_DOWN), 0.0); - Assert.assertEquals(-1.2345, Precision.round(-x, 4, BigDecimal.ROUND_DOWN), 0.0); - - Assert.assertEquals(1.23, Precision.round(x, 2, BigDecimal.ROUND_FLOOR), 0.0); - Assert.assertEquals(1.234, Precision.round(x, 3, BigDecimal.ROUND_FLOOR), 0.0); - Assert.assertEquals(1.2345, Precision.round(x, 4, BigDecimal.ROUND_FLOOR), 0.0); - Assert.assertEquals(-1.24, Precision.round(-x, 2, BigDecimal.ROUND_FLOOR), 0.0); - Assert.assertEquals(-1.235, Precision.round(-x, 3, BigDecimal.ROUND_FLOOR), 0.0); - Assert.assertEquals(-1.2346, Precision.round(-x, 4, BigDecimal.ROUND_FLOOR), 0.0); - - Assert.assertEquals(1.23, Precision.round(x, 2, BigDecimal.ROUND_HALF_DOWN), 0.0); - Assert.assertEquals(1.235, Precision.round(x, 3, BigDecimal.ROUND_HALF_DOWN), 0.0); - Assert.assertEquals(1.2346, Precision.round(x, 4, BigDecimal.ROUND_HALF_DOWN), 0.0); - Assert.assertEquals(-1.23, Precision.round(-x, 2, BigDecimal.ROUND_HALF_DOWN), 0.0); - Assert.assertEquals(-1.235, Precision.round(-x, 3, BigDecimal.ROUND_HALF_DOWN), 0.0); - Assert.assertEquals(-1.2346, Precision.round(-x, 4, BigDecimal.ROUND_HALF_DOWN), 0.0); - Assert.assertEquals(1.234, Precision.round(1.2345, 3, BigDecimal.ROUND_HALF_DOWN), 0.0); - Assert.assertEquals(-1.234, Precision.round(-1.2345, 3, BigDecimal.ROUND_HALF_DOWN), 0.0); - - Assert.assertEquals(1.23, Precision.round(x, 2, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(1.235, Precision.round(x, 3, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(1.2346, Precision.round(x, 4, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(-1.23, Precision.round(-x, 2, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(-1.235, Precision.round(-x, 3, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(-1.2346, Precision.round(-x, 4, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(1.234, Precision.round(1.2345, 3, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(-1.234, Precision.round(-1.2345, 3, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(1.236, Precision.round(1.2355, 3, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(-1.236, Precision.round(-1.2355, 3, BigDecimal.ROUND_HALF_EVEN), 0.0); - - Assert.assertEquals(1.23, Precision.round(x, 2, BigDecimal.ROUND_HALF_UP), 0.0); - Assert.assertEquals(1.235, Precision.round(x, 3, BigDecimal.ROUND_HALF_UP), 0.0); - Assert.assertEquals(1.2346, Precision.round(x, 4, BigDecimal.ROUND_HALF_UP), 0.0); - Assert.assertEquals(-1.23, Precision.round(-x, 2, BigDecimal.ROUND_HALF_UP), 0.0); - Assert.assertEquals(-1.235, Precision.round(-x, 3, BigDecimal.ROUND_HALF_UP), 0.0); - Assert.assertEquals(-1.2346, Precision.round(-x, 4, BigDecimal.ROUND_HALF_UP), 0.0); - Assert.assertEquals(1.235, Precision.round(1.2345, 3, BigDecimal.ROUND_HALF_UP), 0.0); - Assert.assertEquals(-1.235, Precision.round(-1.2345, 3, BigDecimal.ROUND_HALF_UP), 0.0); - - Assert.assertEquals(-1.23, Precision.round(-1.23, 2, BigDecimal.ROUND_UNNECESSARY), 0.0); - Assert.assertEquals(1.23, Precision.round(1.23, 2, BigDecimal.ROUND_UNNECESSARY), 0.0); - - try { - Precision.round(1.234, 2, BigDecimal.ROUND_UNNECESSARY); - Assert.fail(); - } catch (ArithmeticException ex) { - // expected - } - - Assert.assertEquals(1.24, Precision.round(x, 2, BigDecimal.ROUND_UP), 0.0); - Assert.assertEquals(1.235, Precision.round(x, 3, BigDecimal.ROUND_UP), 0.0); - Assert.assertEquals(1.2346, Precision.round(x, 4, BigDecimal.ROUND_UP), 0.0); - Assert.assertEquals(-1.24, Precision.round(-x, 2, BigDecimal.ROUND_UP), 0.0); - Assert.assertEquals(-1.235, Precision.round(-x, 3, BigDecimal.ROUND_UP), 0.0); - Assert.assertEquals(-1.2346, Precision.round(-x, 4, BigDecimal.ROUND_UP), 0.0); - - try { - Precision.round(1.234, 2, 1923); - Assert.fail(); - } catch (IllegalArgumentException ex) { - // expected - } - - // MATH-151 - Assert.assertEquals(39.25, Precision.round(39.245, 2, BigDecimal.ROUND_HALF_UP), 0.0); - - // special values - TestUtils.assertEquals(Double.NaN, Precision.round(Double.NaN, 2), 0.0); - Assert.assertEquals(0.0, Precision.round(0.0, 2), 0.0); - Assert.assertEquals(Double.POSITIVE_INFINITY, Precision.round(Double.POSITIVE_INFINITY, 2), 0.0); - Assert.assertEquals(Double.NEGATIVE_INFINITY, Precision.round(Double.NEGATIVE_INFINITY, 2), 0.0); - // comparison of positive and negative zero is not possible -> always equal thus do string comparison - Assert.assertEquals("-0.0", Double.toString(Precision.round(-0.0, 0))); - Assert.assertEquals("-0.0", Double.toString(Precision.round(-1e-10, 0))); - } - - @Test - public void testRoundFloat() { - float x = 1.234567890f; - Assert.assertEquals(1.23f, Precision.round(x, 2), 0.0); - Assert.assertEquals(1.235f, Precision.round(x, 3), 0.0); - Assert.assertEquals(1.2346f, Precision.round(x, 4), 0.0); - - // BZ 35904 - Assert.assertEquals(30.1f, Precision.round(30.095f, 2), 0.0f); - Assert.assertEquals(30.1f, Precision.round(30.095f, 1), 0.0f); - Assert.assertEquals(50.09f, Precision.round(50.085f, 2), 0.0f); - Assert.assertEquals(50.19f, Precision.round(50.185f, 2), 0.0f); - Assert.assertEquals(50.01f, Precision.round(50.005f, 2), 0.0f); - Assert.assertEquals(30.01f, Precision.round(30.005f, 2), 0.0f); - Assert.assertEquals(30.65f, Precision.round(30.645f, 2), 0.0f); - - Assert.assertEquals(1.24f, Precision.round(x, 2, BigDecimal.ROUND_CEILING), 0.0); - Assert.assertEquals(1.235f, Precision.round(x, 3, BigDecimal.ROUND_CEILING), 0.0); - Assert.assertEquals(1.2346f, Precision.round(x, 4, BigDecimal.ROUND_CEILING), 0.0); - Assert.assertEquals(-1.23f, Precision.round(-x, 2, BigDecimal.ROUND_CEILING), 0.0); - Assert.assertEquals(-1.234f, Precision.round(-x, 3, BigDecimal.ROUND_CEILING), 0.0); - Assert.assertEquals(-1.2345f, Precision.round(-x, 4, BigDecimal.ROUND_CEILING), 0.0); - - Assert.assertEquals(1.23f, Precision.round(x, 2, BigDecimal.ROUND_DOWN), 0.0); - Assert.assertEquals(1.234f, Precision.round(x, 3, BigDecimal.ROUND_DOWN), 0.0); - Assert.assertEquals(1.2345f, Precision.round(x, 4, BigDecimal.ROUND_DOWN), 0.0); - Assert.assertEquals(-1.23f, Precision.round(-x, 2, BigDecimal.ROUND_DOWN), 0.0); - Assert.assertEquals(-1.234f, Precision.round(-x, 3, BigDecimal.ROUND_DOWN), 0.0); - Assert.assertEquals(-1.2345f, Precision.round(-x, 4, BigDecimal.ROUND_DOWN), 0.0); - - Assert.assertEquals(1.23f, Precision.round(x, 2, BigDecimal.ROUND_FLOOR), 0.0); - Assert.assertEquals(1.234f, Precision.round(x, 3, BigDecimal.ROUND_FLOOR), 0.0); - Assert.assertEquals(1.2345f, Precision.round(x, 4, BigDecimal.ROUND_FLOOR), 0.0); - Assert.assertEquals(-1.24f, Precision.round(-x, 2, BigDecimal.ROUND_FLOOR), 0.0); - Assert.assertEquals(-1.235f, Precision.round(-x, 3, BigDecimal.ROUND_FLOOR), 0.0); - Assert.assertEquals(-1.2346f, Precision.round(-x, 4, BigDecimal.ROUND_FLOOR), 0.0); - - Assert.assertEquals(1.23f, Precision.round(x, 2, BigDecimal.ROUND_HALF_DOWN), 0.0); - Assert.assertEquals(1.235f, Precision.round(x, 3, BigDecimal.ROUND_HALF_DOWN), 0.0); - Assert.assertEquals(1.2346f, Precision.round(x, 4, BigDecimal.ROUND_HALF_DOWN), 0.0); - Assert.assertEquals(-1.23f, Precision.round(-x, 2, BigDecimal.ROUND_HALF_DOWN), 0.0); - Assert.assertEquals(-1.235f, Precision.round(-x, 3, BigDecimal.ROUND_HALF_DOWN), 0.0); - Assert.assertEquals(-1.2346f, Precision.round(-x, 4, BigDecimal.ROUND_HALF_DOWN), 0.0); - Assert.assertEquals(1.234f, Precision.round(1.2345f, 3, BigDecimal.ROUND_HALF_DOWN), 0.0); - Assert.assertEquals(-1.234f, Precision.round(-1.2345f, 3, BigDecimal.ROUND_HALF_DOWN), 0.0); - - Assert.assertEquals(1.23f, Precision.round(x, 2, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(1.235f, Precision.round(x, 3, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(1.2346f, Precision.round(x, 4, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(-1.23f, Precision.round(-x, 2, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(-1.235f, Precision.round(-x, 3, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(-1.2346f, Precision.round(-x, 4, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(1.234f, Precision.round(1.2345f, 3, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(-1.234f, Precision.round(-1.2345f, 3, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(1.236f, Precision.round(1.2355f, 3, BigDecimal.ROUND_HALF_EVEN), 0.0); - Assert.assertEquals(-1.236f, Precision.round(-1.2355f, 3, BigDecimal.ROUND_HALF_EVEN), 0.0); - - Assert.assertEquals(1.23f, Precision.round(x, 2, BigDecimal.ROUND_HALF_UP), 0.0); - Assert.assertEquals(1.235f, Precision.round(x, 3, BigDecimal.ROUND_HALF_UP), 0.0); - Assert.assertEquals(1.2346f, Precision.round(x, 4, BigDecimal.ROUND_HALF_UP), 0.0); - Assert.assertEquals(-1.23f, Precision.round(-x, 2, BigDecimal.ROUND_HALF_UP), 0.0); - Assert.assertEquals(-1.235f, Precision.round(-x, 3, BigDecimal.ROUND_HALF_UP), 0.0); - Assert.assertEquals(-1.2346f, Precision.round(-x, 4, BigDecimal.ROUND_HALF_UP), 0.0); - Assert.assertEquals(1.235f, Precision.round(1.2345f, 3, BigDecimal.ROUND_HALF_UP), 0.0); - Assert.assertEquals(-1.235f, Precision.round(-1.2345f, 3, BigDecimal.ROUND_HALF_UP), 0.0); - - Assert.assertEquals(-1.23f, Precision.round(-1.23f, 2, BigDecimal.ROUND_UNNECESSARY), 0.0); - Assert.assertEquals(1.23f, Precision.round(1.23f, 2, BigDecimal.ROUND_UNNECESSARY), 0.0); - - try { - Precision.round(1.234f, 2, BigDecimal.ROUND_UNNECESSARY); - Assert.fail(); - } catch (MathArithmeticException ex) { - // success - } - - Assert.assertEquals(1.24f, Precision.round(x, 2, BigDecimal.ROUND_UP), 0.0); - Assert.assertEquals(1.235f, Precision.round(x, 3, BigDecimal.ROUND_UP), 0.0); - Assert.assertEquals(1.2346f, Precision.round(x, 4, BigDecimal.ROUND_UP), 0.0); - Assert.assertEquals(-1.24f, Precision.round(-x, 2, BigDecimal.ROUND_UP), 0.0); - Assert.assertEquals(-1.235f, Precision.round(-x, 3, BigDecimal.ROUND_UP), 0.0); - Assert.assertEquals(-1.2346f, Precision.round(-x, 4, BigDecimal.ROUND_UP), 0.0); - - try { - Precision.round(1.234f, 2, 1923); - Assert.fail(); - } catch (MathIllegalArgumentException ex) { - // success - } - - // special values - TestUtils.assertEquals(Float.NaN, Precision.round(Float.NaN, 2), 0.0f); - Assert.assertEquals(0.0f, Precision.round(0.0f, 2), 0.0f); - Assert.assertEquals(Float.POSITIVE_INFINITY, Precision.round(Float.POSITIVE_INFINITY, 2), 0.0f); - Assert.assertEquals(Float.NEGATIVE_INFINITY, Precision.round(Float.NEGATIVE_INFINITY, 2), 0.0f); - // comparison of positive and negative zero is not possible -> always equal thus do string comparison - Assert.assertEquals("-0.0", Float.toString(Precision.round(-0.0f, 0))); - Assert.assertEquals("-0.0", Float.toString(Precision.round(-1e-10f, 0))); - - // MATH-1070 - Assert.assertEquals(0.0f, Precision.round(0f, 2, BigDecimal.ROUND_UP), 0.0f); - Assert.assertEquals(0.05f, Precision.round(0.05f, 2, BigDecimal.ROUND_UP), 0.0f); - Assert.assertEquals(0.06f, Precision.round(0.051f, 2, BigDecimal.ROUND_UP), 0.0f); - Assert.assertEquals(0.06f, Precision.round(0.0505f, 2, BigDecimal.ROUND_UP), 0.0f); - Assert.assertEquals(0.06f, Precision.round(0.059f, 2, BigDecimal.ROUND_UP), 0.0f); - } - - - @Test - public void testIssue721() { - Assert.assertEquals(-53, FastMath.getExponent(Precision.EPSILON)); - Assert.assertEquals(-1022, FastMath.getExponent(Precision.SAFE_MIN)); - } - - - @Test - public void testRepresentableDelta() { - int nonRepresentableCount = 0; - final double x = 100; - final int numTrials = 10000; - for (int i = 0; i < numTrials; i++) { - final double originalDelta = FastMath.random(); - final double delta = Precision.representableDelta(x, originalDelta); - if (delta != originalDelta) { - ++nonRepresentableCount; - } - } - - Assert.assertTrue(nonRepresentableCount / (double) numTrials > 0.9); - } - - @Test - public void testMath843() { - final double afterEpsilon = FastMath.nextAfter(Precision.EPSILON, - Double.POSITIVE_INFINITY); - - // a) 1 + EPSILON is equal to 1. - Assert.assertTrue(1 + Precision.EPSILON == 1); - - // b) 1 + "the number after EPSILON" is not equal to 1. - Assert.assertFalse(1 + afterEpsilon == 1); - } - - @Test - public void testMath1127() { - Assert.assertFalse(Precision.equals(2.0, -2.0, 1)); - Assert.assertTrue(Precision.equals(0.0, -0.0, 0)); - Assert.assertFalse(Precision.equals(2.0f, -2.0f, 1)); - Assert.assertTrue(Precision.equals(0.0f, -0.0f, 0)); - } - -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/e082e0c4/src/userguide/java/org/apache/commons/math4/userguide/genetics/HelloWorldExample.java ---------------------------------------------------------------------- diff --git a/src/userguide/java/org/apache/commons/math4/userguide/genetics/HelloWorldExample.java b/src/userguide/java/org/apache/commons/math4/userguide/genetics/HelloWorldExample.java index a02cc8e..d5eeba0 100644 --- a/src/userguide/java/org/apache/commons/math4/userguide/genetics/HelloWorldExample.java +++ b/src/userguide/java/org/apache/commons/math4/userguide/genetics/HelloWorldExample.java @@ -35,7 +35,7 @@ import org.apache.commons.math4.genetics.Population; import org.apache.commons.math4.genetics.StoppingCondition; import org.apache.commons.math4.genetics.TournamentSelection; import org.apache.commons.math4.util.FastMath; -import org.apache.commons.math4.util.Precision; +import org.apache.commons.numbers.core.Precision; public class HelloWorldExample { public static final int POPULATION_SIZE = 1000;
