Repository: commons-math Updated Branches: refs/heads/master f7ab3a70e -> 49bb370a6
http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/special/ErfTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/special/ErfTest.java b/src/test/java/org/apache/commons/math4/special/ErfTest.java index e9d6813..3bd9bf0 100644 --- a/src/test/java/org/apache/commons/math4/special/ErfTest.java +++ b/src/test/java/org/apache/commons/math4/special/ErfTest.java @@ -89,7 +89,7 @@ public class ErfTest { Assert.assertEquals(expected, actual, 1.0e-5); Assert.assertEquals(1 - expected, Erf.erfc(-x), 1.0e-5); } - + /** * MATH-301, MATH-456 */ @@ -107,14 +107,14 @@ public class ErfTest { Assert.assertTrue(result >= 0 && result < 1); result = Erf.erfc(-i); Assert.assertFalse(Double.isNaN(result)); - Assert.assertTrue(result >= 1 && result <= 2); + Assert.assertTrue(result >= 1 && result <= 2); } Assert.assertEquals(-1, Erf.erf(Double.NEGATIVE_INFINITY), 0); Assert.assertEquals(1, Erf.erf(Double.POSITIVE_INFINITY), 0); Assert.assertEquals(2, Erf.erfc(Double.NEGATIVE_INFINITY), 0); Assert.assertEquals(0, Erf.erfc(Double.POSITIVE_INFINITY), 0); } - + /** * Compare Erf.erf against reference values computed using GCC 4.2.1 (Apple OSX packaged version) * erfl (extended precision erf). @@ -122,15 +122,15 @@ public class ErfTest { @Test public void testErfGnu() { final double tol = 1E-15; - final double[] gnuValues = new double[] {-1, -1, -1, -1, -1, - -1, -1, -1, -0.99999999999999997848, - -0.99999999999999264217, -0.99999999999846254017, -0.99999999980338395581, -0.99999998458274209971, - -0.9999992569016276586, -0.99997790950300141459, -0.99959304798255504108, -0.99532226501895273415, - -0.96610514647531072711, -0.84270079294971486948, -0.52049987781304653809, 0, - 0.52049987781304653809, 0.84270079294971486948, 0.96610514647531072711, 0.99532226501895273415, - 0.99959304798255504108, 0.99997790950300141459, 0.9999992569016276586, 0.99999998458274209971, - 0.99999999980338395581, 0.99999999999846254017, 0.99999999999999264217, 0.99999999999999997848, - 1, 1, 1, 1, + final double[] gnuValues = new double[] {-1, -1, -1, -1, -1, + -1, -1, -1, -0.99999999999999997848, + -0.99999999999999264217, -0.99999999999846254017, -0.99999999980338395581, -0.99999998458274209971, + -0.9999992569016276586, -0.99997790950300141459, -0.99959304798255504108, -0.99532226501895273415, + -0.96610514647531072711, -0.84270079294971486948, -0.52049987781304653809, 0, + 0.52049987781304653809, 0.84270079294971486948, 0.96610514647531072711, 0.99532226501895273415, + 0.99959304798255504108, 0.99997790950300141459, 0.9999992569016276586, 0.99999998458274209971, + 0.99999999980338395581, 0.99999999999846254017, 0.99999999999999264217, 0.99999999999999997848, + 1, 1, 1, 1, 1, 1, 1, 1}; double x = -10d; for (int i = 0; i < 41; i++) { @@ -138,7 +138,7 @@ public class ErfTest { x += 0.5d; } } - + /** * Compare Erf.erfc against reference values computed using GCC 4.2.1 (Apple OSX packaged version) * erfcl (extended precision erfc). @@ -146,15 +146,15 @@ public class ErfTest { @Test public void testErfcGnu() { final double tol = 1E-15; - final double[] gnuValues = new double[] { 2, 2, 2, 2, 2, - 2, 2, 2, 1.9999999999999999785, - 1.9999999999999926422, 1.9999999999984625402, 1.9999999998033839558, 1.9999999845827420998, - 1.9999992569016276586, 1.9999779095030014146, 1.9995930479825550411, 1.9953222650189527342, - 1.9661051464753107271, 1.8427007929497148695, 1.5204998778130465381, 1, - 0.47950012218695346194, 0.15729920705028513051, 0.033894853524689272893, 0.0046777349810472658333, - 0.00040695201744495893941, 2.2090496998585441366E-05, 7.4309837234141274516E-07, 1.5417257900280018858E-08, - 1.966160441542887477E-10, 1.5374597944280348501E-12, 7.3578479179743980661E-15, 2.1519736712498913103E-17, - 3.8421483271206474691E-20, 4.1838256077794144006E-23, 2.7766493860305691016E-26, 1.1224297172982927079E-29, + final double[] gnuValues = new double[] { 2, 2, 2, 2, 2, + 2, 2, 2, 1.9999999999999999785, + 1.9999999999999926422, 1.9999999999984625402, 1.9999999998033839558, 1.9999999845827420998, + 1.9999992569016276586, 1.9999779095030014146, 1.9995930479825550411, 1.9953222650189527342, + 1.9661051464753107271, 1.8427007929497148695, 1.5204998778130465381, 1, + 0.47950012218695346194, 0.15729920705028513051, 0.033894853524689272893, 0.0046777349810472658333, + 0.00040695201744495893941, 2.2090496998585441366E-05, 7.4309837234141274516E-07, 1.5417257900280018858E-08, + 1.966160441542887477E-10, 1.5374597944280348501E-12, 7.3578479179743980661E-15, 2.1519736712498913103E-17, + 3.8421483271206474691E-20, 4.1838256077794144006E-23, 2.7766493860305691016E-26, 1.1224297172982927079E-29, 2.7623240713337714448E-33, 4.1370317465138102353E-37, 3.7692144856548799402E-41, 2.0884875837625447567E-45}; double x = -10d; for (int i = 0; i < 41; i++) { @@ -162,9 +162,9 @@ public class ErfTest { x += 0.5d; } } - + /** - * Tests erfc against reference data computed using Maple reported in Marsaglia, G,, + * Tests erfc against reference data computed using Maple reported in Marsaglia, G,, * "Evaluating the Normal Distribution," Journal of Statistical Software, July, 2004. * http//www.jstatsoft.org/v11/a05/paper */ @@ -176,13 +176,13 @@ public class ErfTest { {2.3, 1.07241100216758e-02}, {3.4, 3.36929265676881e-04}, {4.5, 3.39767312473006e-06}, - {5.6, 1.07175902583109e-08}, + {5.6, 1.07175902583109e-08}, {6.7, 1.04209769879652e-11}, {7.8, 3.09535877195870e-15}, {8.9, 2.79233437493966e-19}, {10.0, 7.61985302416053e-24}, {11.1, 6.27219439321703e-29}, - {12.2, 1.55411978638959e-34}, + {12.2, 1.55411978638959e-34}, {13.3, 1.15734162836904e-40}, {14.4, 2.58717592540226e-47}, {15.5, 1.73446079179387e-54}, @@ -194,7 +194,7 @@ public class ErfTest { TestUtils.assertRelativelyEquals(ref[i][1], result, 1E-13); } } - + /** * Test the implementation of Erf.erf(double, double) for consistency with results * obtained from Erf.erf(double) and Erf.erfc(double). http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/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 2528f3c..eae66fb 100644 --- a/src/test/java/org/apache/commons/math4/stat/StatUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/stat/StatUtilsTest.java @@ -271,7 +271,7 @@ public final class StatUtilsTest { x = new double[] {ONE, TWO, TWO, THREE}; TestUtils.assertEquals(0.5, StatUtils.variance(x,2.5, 2, 2), TOLERANCE); } - + @Test public void testPopulationVariance() { double[] x = null; @@ -463,10 +463,10 @@ public final class StatUtilsTest { Assert.assertEquals(FastMath.exp(0.5 * StatUtils.sumLog(test, 0, 2)), StatUtils.geometricMean(test, 0, 2), Double.MIN_VALUE); } - - + + /** - * Run the test with the values 50 and 100 and assume standardized values + * Run the test with the values 50 and 100 and assume standardized values */ @Test @@ -487,7 +487,7 @@ public final class StatUtilsTest { @Test public void testNormalize2() { - // create an sample with 77 values + // create an sample with 77 values int length = 77; double sample[] = new double[length]; for (int i = 0; i < length; i++) { @@ -501,14 +501,14 @@ public final class StatUtilsTest { for (int i = 0; i < length; i++) { stats.addValue(standardizedSample[i]); } - // the calculations do have a limited precision + // the calculations do have a limited precision double distance = 1E-10; // check the mean an standard deviation Assert.assertEquals(0.0, stats.getMean(), distance); Assert.assertEquals(1.0, stats.getStandardDeviation(), distance); } - + @Test public void testMode() { final double[] singleMode = {0, 1, 0, 2, 7, 11, 12}; @@ -544,7 +544,7 @@ public final class StatUtilsTest { final double[] nansOnly = {Double.NaN, Double.NaN}; final double[] modeNansOnly = StatUtils.mode(nansOnly); Assert.assertEquals(0, modeNansOnly.length); - + final double[] nullArray = null; try { StatUtils.mode(nullArray); http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/stat/correlation/StorelessCovarianceTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/stat/correlation/StorelessCovarianceTest.java b/src/test/java/org/apache/commons/math4/stat/correlation/StorelessCovarianceTest.java index 09a2297..dc2197b 100644 --- a/src/test/java/org/apache/commons/math4/stat/correlation/StorelessCovarianceTest.java +++ b/src/test/java/org/apache/commons/math4/stat/correlation/StorelessCovarianceTest.java @@ -223,7 +223,7 @@ public class StorelessCovarianceTest { } } } - + /** * Test equality of covariance. chk: covariance of two * samples separately and adds them together. cov: computes @@ -234,22 +234,22 @@ public class StorelessCovarianceTest { int num_sets = 2; StorelessBivariateCovariance cov = new StorelessBivariateCovariance();// covariance of the superset StorelessBivariateCovariance chk = new StorelessBivariateCovariance();// check covariance made by appending covariance of subsets - + ISAACRandom rand = new ISAACRandom(10L);// Seed can be changed for (int s = 0; s < num_sets; s++) {// loop through sets of samlpes StorelessBivariateCovariance covs = new StorelessBivariateCovariance(); for (int i = 0; i < 5; i++) { // loop through individual samlpes. double x = rand.nextDouble(); double y = rand.nextDouble(); - covs.increment(x, y);// add sample to the subset + covs.increment(x, y);// add sample to the subset cov.increment(x, y);// add sample to the superset } chk.append(covs); } - + TestUtils.assertEquals("covariance subset test", chk.getResult(), cov.getResult(), 10E-7); } - + protected RealMatrix createRealMatrix(double[] data, int nRows, int nCols) { double[][] matrixData = new double[nRows][nCols]; int ptr = 0; http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/stat/descriptive/StatisticalSummaryValuesTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/StatisticalSummaryValuesTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/StatisticalSummaryValuesTest.java index 1c27d8c..0917ba7 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/StatisticalSummaryValuesTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/StatisticalSummaryValuesTest.java @@ -64,7 +64,7 @@ public final class StatisticalSummaryValuesTest { TestUtils.assertEquals("min",s.getMin(),u.getMin(), 0); TestUtils.assertEquals("max",s.getMax(),u.getMax(), 0); } - + @Test public void testToString() { StatisticalSummaryValues u = new StatisticalSummaryValues(4.5, 16, 10, 5, 4, 45); http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PercentileTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PercentileTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PercentileTest.java index 8b2107b..65a25b1 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PercentileTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PercentileTest.java @@ -776,12 +776,12 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{ Assert.assertEquals(2d,new Percentile(50d).withEstimationType(Percentile.EstimationType.R_1).withNaNStrategy(NaNStrategy.REMOVED).evaluate(specialValues),0d); Assert.assertEquals(Double.NaN,new Percentile(50d).withEstimationType(Percentile.EstimationType.R_5).withNaNStrategy(NaNStrategy.REMOVED).evaluate(new double[] {Double.NaN,Double.NaN,Double.NaN}),0d); Assert.assertEquals(50d,new Percentile(50d).withEstimationType(Percentile.EstimationType.R_7).withNaNStrategy(NaNStrategy.MINIMAL).evaluate(new double[] {50d,50d,50d},1,2),0d); - + specialValues = new double[] { 0d, 1d, 2d, 3d, 4d, Double.NaN, Double.NaN }; Assert.assertEquals(3.5,new Percentile().evaluate(specialValues, 3, 4),0d); Assert.assertEquals(4d,new Percentile().evaluate(specialValues, 4, 3),0d); Assert.assertTrue(Double.isNaN(new Percentile().evaluate(specialValues, 5, 2))); - + specialValues = new double[] { 0d, 1d, 2d, 3d, 4d, Double.NaN, Double.NaN, 5d, 6d }; Assert.assertEquals(4.5,new Percentile().evaluate(specialValues, 3, 6),0d); Assert.assertEquals(5d,new Percentile().evaluate(specialValues, 4, 5),0d); http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/stat/interval/AgrestiCoullIntervalTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/stat/interval/AgrestiCoullIntervalTest.java b/src/test/java/org/apache/commons/math4/stat/interval/AgrestiCoullIntervalTest.java index ec804d1..77b64d3 100644 --- a/src/test/java/org/apache/commons/math4/stat/interval/AgrestiCoullIntervalTest.java +++ b/src/test/java/org/apache/commons/math4/stat/interval/AgrestiCoullIntervalTest.java @@ -32,7 +32,7 @@ public class AgrestiCoullIntervalTest extends BinomialConfidenceIntervalAbstract protected BinomialConfidenceInterval createBinomialConfidenceInterval() { return new AgrestiCoullInterval(); } - + @Test public void testStandardInterval() { ConfidenceInterval confidenceInterval = createStandardTestInterval(); http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/stat/interval/BinomialConfidenceIntervalAbstractTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/stat/interval/BinomialConfidenceIntervalAbstractTest.java b/src/test/java/org/apache/commons/math4/stat/interval/BinomialConfidenceIntervalAbstractTest.java index 621c8ac..3909353 100644 --- a/src/test/java/org/apache/commons/math4/stat/interval/BinomialConfidenceIntervalAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/stat/interval/BinomialConfidenceIntervalAbstractTest.java @@ -35,10 +35,10 @@ public abstract class BinomialConfidenceIntervalAbstractTest { private final double confidenceLevel = 0.9; protected abstract BinomialConfidenceInterval createBinomialConfidenceInterval(); - + /** * Returns the confidence interval for the given statistic with the following values: - * + * * <ul> * <li>trials: 500</li> * <li>successes: 50</li> http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/stat/interval/ClopperPearsonIntervalTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/stat/interval/ClopperPearsonIntervalTest.java b/src/test/java/org/apache/commons/math4/stat/interval/ClopperPearsonIntervalTest.java index e0bcc5b..e50ab58 100644 --- a/src/test/java/org/apache/commons/math4/stat/interval/ClopperPearsonIntervalTest.java +++ b/src/test/java/org/apache/commons/math4/stat/interval/ClopperPearsonIntervalTest.java @@ -32,7 +32,7 @@ public class ClopperPearsonIntervalTest extends BinomialConfidenceIntervalAbstra protected BinomialConfidenceInterval createBinomialConfidenceInterval() { return new ClopperPearsonInterval(); } - + @Test public void testStandardInterval() { ConfidenceInterval confidenceInterval = createStandardTestInterval(); http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/stat/interval/IntervalUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/stat/interval/IntervalUtilsTest.java b/src/test/java/org/apache/commons/math4/stat/interval/IntervalUtilsTest.java index a1715a6..2a5bbb8 100644 --- a/src/test/java/org/apache/commons/math4/stat/interval/IntervalUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/stat/interval/IntervalUtilsTest.java @@ -27,14 +27,14 @@ import org.junit.Test; /** * Test cases for the IntervalUtils class. - * + * */ public class IntervalUtilsTest { private final int successes = 50; private final int trials = 500; private final double confidenceLevel = 0.9; - + // values to test must be exactly the same private final double eps = 0.0; http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/stat/interval/NormalApproximationIntervalTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/stat/interval/NormalApproximationIntervalTest.java b/src/test/java/org/apache/commons/math4/stat/interval/NormalApproximationIntervalTest.java index 269b93c..25209d3 100644 --- a/src/test/java/org/apache/commons/math4/stat/interval/NormalApproximationIntervalTest.java +++ b/src/test/java/org/apache/commons/math4/stat/interval/NormalApproximationIntervalTest.java @@ -32,7 +32,7 @@ public class NormalApproximationIntervalTest extends BinomialConfidenceIntervalA protected BinomialConfidenceInterval createBinomialConfidenceInterval() { return new NormalApproximationInterval(); } - + @Test public void testStandardInterval() { ConfidenceInterval confidenceInterval = createStandardTestInterval(); http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/stat/interval/WilsonScoreIntervalTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/stat/interval/WilsonScoreIntervalTest.java b/src/test/java/org/apache/commons/math4/stat/interval/WilsonScoreIntervalTest.java index 7ed37cb..2355cd2 100644 --- a/src/test/java/org/apache/commons/math4/stat/interval/WilsonScoreIntervalTest.java +++ b/src/test/java/org/apache/commons/math4/stat/interval/WilsonScoreIntervalTest.java @@ -32,7 +32,7 @@ public class WilsonScoreIntervalTest extends BinomialConfidenceIntervalAbstractT protected BinomialConfidenceInterval createBinomialConfidenceInterval() { return new WilsonScoreInterval(); } - + @Test public void testStandardInterval() { ConfidenceInterval confidenceInterval = createStandardTestInterval(); http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/stat/ranking/NaturalRankingTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/stat/ranking/NaturalRankingTest.java b/src/test/java/org/apache/commons/math4/stat/ranking/NaturalRankingTest.java index e713720..73e0370 100644 --- a/src/test/java/org/apache/commons/math4/stat/ranking/NaturalRankingTest.java +++ b/src/test/java/org/apache/commons/math4/stat/ranking/NaturalRankingTest.java @@ -46,28 +46,28 @@ public class NaturalRankingTest { public void testDefault() { // Ties averaged, NaNs failed NaturalRanking ranking = new NaturalRanking(); double[] ranks; - + try { ranks = ranking.rank(exampleData); Assert.fail("expected NotANumberException due to NaNStrategy.FAILED"); } catch (NotANumberException e) { // expected } - + ranks = ranking.rank(tiesFirst); double[] correctRanks = new double[] { 1.5, 1.5, 4, 3, 5 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesLast); correctRanks = new double[] { 3.5, 3.5, 2, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); - + try { ranks = ranking.rank(multipleNaNs); Assert.fail("expected NotANumberException due to NaNStrategy.FAILED"); } catch (NotANumberException e) { // expected } - + ranks = ranking.rank(multipleTies); correctRanks = new double[] { 3, 2, 4.5, 4.5, 6.5, 6.5, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); @@ -209,14 +209,14 @@ public class NaturalRankingTest { correctRanks = new double[] { 3, 4, 1.5, 1.5 }; TestUtils.assertEquals(correctRanks, ranks, 0d); } - + @Test(expected=NotANumberException.class) public void testNaNsFailed() { double[] data = { 0, Double.POSITIVE_INFINITY, Double.NaN, Double.NEGATIVE_INFINITY }; NaturalRanking ranking = new NaturalRanking(NaNStrategy.FAILED); ranking.rank(data); } - + @Test public void testNoNaNsFailed() { double[] data = { 1, 2, 3, 4 }; @@ -224,5 +224,5 @@ public class NaturalRankingTest { double[] ranks = ranking.rank(data); TestUtils.assertEquals(data, ranks, 0d); } - + } http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/stat/regression/SimpleRegressionTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/stat/regression/SimpleRegressionTest.java b/src/test/java/org/apache/commons/math4/stat/regression/SimpleRegressionTest.java index c31b8c3..e37dda0 100644 --- a/src/test/java/org/apache/commons/math4/stat/regression/SimpleRegressionTest.java +++ b/src/test/java/org/apache/commons/math4/stat/regression/SimpleRegressionTest.java @@ -551,7 +551,7 @@ public final class SimpleRegressionTest { Assert.assertTrue(regression.getSlope() > 0.0); Assert.assertTrue(regression.getSumSquaredErrors() >= 0.0); } - + @Test public void testPerfect2() { SimpleRegression regression = new SimpleRegression(); http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java ---------------------------------------------------------------------- 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 336126a..fece225 100644 --- a/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java @@ -587,7 +587,7 @@ public class ArithmeticUtilsTest { // success } } - + /** * Testing helper method. * @return an array of int numbers containing corner cases:<ul> @@ -619,7 +619,7 @@ public class ArithmeticUtilsTest { } return ints; } - + /** * Testing helper method. * @return an array of long numbers containing corner cases:<ul> @@ -656,37 +656,37 @@ public class ArithmeticUtilsTest { } return longs; } - + private static long toUnsignedLong(int number) { return number < 0 ? 0x100000000L + (long)number : (long)number; } - + private static int remainderUnsignedExpected(int dividend, int divisor) { return (int)remainderUnsignedExpected(toUnsignedLong(dividend), toUnsignedLong(divisor)); } - + private static int divideUnsignedExpected(int dividend, int divisor) { return (int)divideUnsignedExpected(toUnsignedLong(dividend), toUnsignedLong(divisor)); } - + private static BigInteger toUnsignedBigInteger(long number) { return number < 0L ? BigInteger.ONE.shiftLeft(64).add(BigInteger.valueOf(number)) : BigInteger.valueOf(number); } - + private static long remainderUnsignedExpected(long dividend, long divisor) { return toUnsignedBigInteger(dividend).remainder(toUnsignedBigInteger(divisor)).longValue(); } - + private static long divideUnsignedExpected(long dividend, long divisor) { return toUnsignedBigInteger(dividend).divide(toUnsignedBigInteger(divisor)).longValue(); } - + @Test(timeout=5000L) public void testRemainderUnsignedInt() { Assert.assertEquals(36, ArithmeticUtils.remainderUnsigned(-2147479015, 63)); Assert.assertEquals(6, ArithmeticUtils.remainderUnsigned(-2147479015, 25)); } - + @Test(timeout=5000L) public void testRemainderUnsignedIntSpecialCases() { int ints[] = getIntSpecialCases(); @@ -705,12 +705,12 @@ public class ArithmeticUtilsTest { } } } - + @Test(timeout=5000L) public void testRemainderUnsignedLong() { Assert.assertEquals(48L, ArithmeticUtils.remainderUnsigned(-2147479015L, 63L)); } - + @Test//(timeout=5000L) public void testRemainderUnsignedLongSpecialCases() { long longs[] = getLongSpecialCases(); @@ -729,7 +729,7 @@ public class ArithmeticUtilsTest { } } } - + @Test(timeout=5000L) public void testDivideUnsignedInt() { Assert.assertEquals(34087115, ArithmeticUtils.divideUnsigned(-2147479015, 63)); @@ -743,7 +743,7 @@ public class ArithmeticUtilsTest { Assert.assertEquals(1, ArithmeticUtils.divideUnsigned(-16, 2147483647)); Assert.assertEquals(1, ArithmeticUtils.divideUnsigned(-16, 2147483646)); } - + @Test(timeout=5000L) public void testDivideUnsignedIntSpecialCases() { int ints[] = getIntSpecialCases(); @@ -762,12 +762,12 @@ public class ArithmeticUtilsTest { } } } - + @Test(timeout=5000L) public void testDivideUnsignedLong() { Assert.assertEquals(292805461453366231L, ArithmeticUtils.divideUnsigned(-2147479015L, 63L)); } - + @Test(timeout=5000L) public void testDivideUnsignedLongSpecialCases() { long longs[] = getLongSpecialCases(); http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/util/CombinationsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/util/CombinationsTest.java b/src/test/java/org/apache/commons/math4/util/CombinationsTest.java index 83baa89..a2b0c4b 100644 --- a/src/test/java/org/apache/commons/math4/util/CombinationsTest.java +++ b/src/test/java/org/apache/commons/math4/util/CombinationsTest.java @@ -148,7 +148,7 @@ public class CombinationsTest { * Verifies that the iterator generates a lexicographically * increasing sequence of b(n,k) arrays, each having length k * and each array itself increasing. - * + * * @param c Combinations. */ private void checkLexicographicIterator(Combinations c) { @@ -180,7 +180,7 @@ public class CombinationsTest { Assert.assertEquals(CombinatoricsUtils.binomialCoefficient(n, k), numIterates); } - + @Test public void testCombinationsIteratorFail() { try { http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/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 1e93148..26c1cd9 100644 --- a/src/test/java/org/apache/commons/math4/util/FastMathTest.java +++ b/src/test/java/org/apache/commons/math4/util/FastMathTest.java @@ -184,14 +184,14 @@ public class FastMathTest { for (double x = start; x < end; x += 1e-3) { final double tst = FastMath.cosh(x); final double ref = Math.cosh(x); - maxErr = FastMath.max(maxErr, FastMath.abs(ref - tst) / FastMath.ulp(ref)); + maxErr = FastMath.max(maxErr, FastMath.abs(ref - tst) / FastMath.ulp(ref)); } Assert.assertEquals(0, maxErr, 3); for (double x = start; x < end; x += 1e-3) { final double tst = FastMath.sinh(x); final double ref = Math.sinh(x); - maxErr = FastMath.max(maxErr, FastMath.abs(ref - tst) / FastMath.ulp(ref)); + maxErr = FastMath.max(maxErr, FastMath.abs(ref - tst) / FastMath.ulp(ref)); } Assert.assertEquals(0, maxErr, 3); } @@ -206,18 +206,18 @@ public class FastMathTest { for (double x = start; x > end; x -= 1e-3) { final double tst = FastMath.cosh(x); final double ref = Math.cosh(x); - maxErr = FastMath.max(maxErr, FastMath.abs(ref - tst) / FastMath.ulp(ref)); + maxErr = FastMath.max(maxErr, FastMath.abs(ref - tst) / FastMath.ulp(ref)); } Assert.assertEquals(0, maxErr, 3); for (double x = start; x > end; x -= 1e-3) { final double tst = FastMath.sinh(x); final double ref = Math.sinh(x); - maxErr = FastMath.max(maxErr, FastMath.abs(ref - tst) / FastMath.ulp(ref)); + maxErr = FastMath.max(maxErr, FastMath.abs(ref - tst) / FastMath.ulp(ref)); } Assert.assertEquals(0, maxErr, 3); } - + @Test public void testMath1269() { final double arg = 709.8125; @@ -1029,13 +1029,13 @@ public class FastMathTest { */ @Test public void testAcosSpecialCases() { - + Assert.assertTrue("acos(NaN) should be NaN", Double.isNaN(FastMath.acos(Double.NaN))); - + Assert.assertTrue("acos(-1.1) should be NaN", Double.isNaN(FastMath.acos(-1.1))); Assert.assertTrue("acos(-1.1) should be NaN", Double.isNaN(FastMath.acos(1.1))); - + Assert.assertEquals("acos(-1.0) should be PI", FastMath.acos(-1.0), FastMath.PI, Precision.EPSILON); Assert.assertEquals("acos(1.0) should be 0.0", FastMath.acos(1.0), 0.0, Precision.EPSILON); @@ -1048,13 +1048,13 @@ public class FastMathTest { */ @Test public void testAsinSpecialCases() { - + Assert.assertTrue("asin(NaN) should be NaN", Double.isNaN(FastMath.asin(Double.NaN))); - + Assert.assertTrue("asin(1.1) should be NaN", Double.isNaN(FastMath.asin(1.1))); - + Assert.assertTrue("asin(-1.1) should be NaN", Double.isNaN(FastMath.asin(-1.1))); - + Assert.assertEquals("asin(1.0) should be PI/2", FastMath.asin(1.0), FastMath.PI / 2.0, Precision.EPSILON); Assert.assertEquals("asin(-1.0) should be -PI/2", FastMath.asin(-1.0), -FastMath.PI / 2.0, Precision.EPSILON); @@ -1460,7 +1460,7 @@ public class FastMathTest { public void testIntPowLongMinValue() { Assert.assertEquals(1.0, FastMath.pow(1.0, Long.MIN_VALUE), -1.0); } - + @Test(timeout=5000L) public void testIntPowSpecialCases() { final double EXACT = -1.0; http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/util/IncrementorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/util/IncrementorTest.java b/src/test/java/org/apache/commons/math4/util/IncrementorTest.java index 72cde88..f25b3ff 100644 --- a/src/test/java/org/apache/commons/math4/util/IncrementorTest.java +++ b/src/test/java/org/apache/commons/math4/util/IncrementorTest.java @@ -135,4 +135,4 @@ public class IncrementorTest { i.incrementCount(1); Assert.assertEquals(3, i.getCount()); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/commons-math/blob/49bb370a/src/test/java/org/apache/commons/math4/util/ResizableDoubleArrayTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/util/ResizableDoubleArrayTest.java b/src/test/java/org/apache/commons/math4/util/ResizableDoubleArrayTest.java index 88392e1..be897a5 100644 --- a/src/test/java/org/apache/commons/math4/util/ResizableDoubleArrayTest.java +++ b/src/test/java/org/apache/commons/math4/util/ResizableDoubleArrayTest.java @@ -124,7 +124,7 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest { ResizableDoubleArray copyDa = new ResizableDoubleArray(testDa); Assert.assertEquals(copyDa, testDa); Assert.assertEquals(testDa, copyDa); - + // JIRA: MATH-1252 final double[] values = {1}; testDa = new ResizableDoubleArray(values);