diff --git a/src/test/org/apache/commons/math/distribution/IntegerDistributionAbstractTest.java b/src/test/org/apache/commons/math/distribution/IntegerDistributionAbstractTest.java index 474e25f85..13db9117c 100644 --- a/src/test/org/apache/commons/math/distribution/IntegerDistributionAbstractTest.java +++ b/src/test/org/apache/commons/math/distribution/IntegerDistributionAbstractTest.java @@ -196,14 +196,14 @@ public abstract class IntegerDistributionAbstractTest extends TestCase { */ public void testFloatingPointArguments() throws Exception { for (int i = 0; i < cumulativeTestPoints.length; i++) { - double arg = (double) cumulativeTestPoints[i]; + double arg = cumulativeTestPoints[i]; assertEquals( "Incorrect cumulative probability value returned for " + cumulativeTestPoints[i], cumulativeTestValues[i], distribution.cumulativeProbability(arg), tolerance); if (i < cumulativeTestPoints.length - 1) { - double arg2 = (double) cumulativeTestPoints[i + 1]; + double arg2 = cumulativeTestPoints[i + 1]; assertEquals("Inconsistent probability for discrete range " + "[ " + arg + "," + arg2 + " ]", distribution.cumulativeProbability( @@ -223,9 +223,9 @@ public abstract class IntegerDistributionAbstractTest extends TestCase { int one = 1; int ten = 10; int two = 2; - double oned = (double) one; - double twod = (double) two; - double tend = (double) ten; + double oned = one; + double twod = two; + double tend = ten; assertEquals(distribution.cumulativeProbability(one, two), distribution.cumulativeProbability(oned, twod), tolerance); assertEquals(distribution.cumulativeProbability(one, two), diff --git a/src/test/org/apache/commons/math/distribution/NormalDistributionTest.java b/src/test/org/apache/commons/math/distribution/NormalDistributionTest.java index 2e33d0601..dd607f3f7 100644 --- a/src/test/org/apache/commons/math/distribution/NormalDistributionTest.java +++ b/src/test/org/apache/commons/math/distribution/NormalDistributionTest.java @@ -149,8 +149,8 @@ public class NormalDistributionTest extends ContinuousDistributionAbstractTest distribution.setMean(0); distribution.setStandardDeviation(1); for (int i = 0; i < 100; i+=5) { // make sure no convergence exception - double lowerTail = distribution.cumulativeProbability((double)-i); - double upperTail = distribution.cumulativeProbability((double) i); + double lowerTail = distribution.cumulativeProbability(-i); + double upperTail = distribution.cumulativeProbability(i); if (i < 10) { // make sure not top-coded assertTrue(lowerTail > 0.0d); assertTrue(upperTail < 1.0d); diff --git a/src/test/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java b/src/test/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java index 2764b8710..329142f62 100644 --- a/src/test/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java +++ b/src/test/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java @@ -237,7 +237,7 @@ public class GaussNewtonEstimatorTest } - public void testNonInversible() throws EstimationException { + public void testNonInversible() { EstimatedParameter[] p = { new EstimatedParameter("p0", 0), @@ -322,7 +322,7 @@ public class GaussNewtonEstimatorTest } - public void testMoreEstimatedParametersSimple() throws EstimationException { + public void testMoreEstimatedParametersSimple() { EstimatedParameter[] p = { new EstimatedParameter("p0", 7), @@ -354,7 +354,7 @@ public class GaussNewtonEstimatorTest } - public void testMoreEstimatedParametersUnsorted() throws EstimationException { + public void testMoreEstimatedParametersUnsorted() { EstimatedParameter[] p = { new EstimatedParameter("p0", 2), new EstimatedParameter("p1", 2), @@ -516,7 +516,7 @@ public class GaussNewtonEstimatorTest assertEquals(48.13516790438953, circle.getY(), 1.0e-10); } - public void testCircleFittingBadInit() throws EstimationException { + public void testCircleFittingBadInit() { Circle circle = new Circle(-12, -12); double[][] points = new double[][] { {-0.312967, 0.072366}, {-0.339248, 0.132965}, {-0.379780, 0.202724}, @@ -637,7 +637,7 @@ public class GaussNewtonEstimatorTest } public WeightedMeasurement[] getMeasurements() { - return (WeightedMeasurement[]) points.toArray(new PointModel[points.size()]); + return points.toArray(new PointModel[points.size()]); } public EstimatedParameter[] getAllParameters() { diff --git a/src/test/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java b/src/test/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java index 35ddd8530..af27e260a 100644 --- a/src/test/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java +++ b/src/test/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java @@ -457,7 +457,7 @@ public class LevenbergMarquardtEstimatorTest } - public void testControlParameters() throws EstimationException { + public void testControlParameters() { Circle circle = new Circle(98.680, 47.345); circle.addPoint( 30.0, 68.0); circle.addPoint( 50.0, -6.0); @@ -620,7 +620,7 @@ public class LevenbergMarquardtEstimatorTest set.add(parameters[j]); } } - return (EstimatedParameter[]) set.toArray(new EstimatedParameter[set.size()]); + return set.toArray(new EstimatedParameter[set.size()]); } private LinearMeasurement[] measurements; @@ -682,7 +682,7 @@ public class LevenbergMarquardtEstimatorTest } public WeightedMeasurement[] getMeasurements() { - return (WeightedMeasurement[]) points.toArray(new PointModel[points.size()]); + return points.toArray(new PointModel[points.size()]); } public EstimatedParameter[] getAllParameters() { diff --git a/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java b/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java index 23f311353..5b9adeb9c 100644 --- a/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java +++ b/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java @@ -236,7 +236,7 @@ public final class BigMatrixImplTest extends TestCase { m.add(m2); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { - ; + // ignored } } @@ -258,7 +258,7 @@ public final class BigMatrixImplTest extends TestCase { m.subtract(new BigMatrixImpl(testData2)); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } } @@ -282,7 +282,7 @@ public final class BigMatrixImplTest extends TestCase { m.multiply(new BigMatrixImpl(bigSingular)); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } } @@ -350,32 +350,32 @@ public final class BigMatrixImplTest extends TestCase { asDouble(m.solve(asBigDecimal(testVector2))); fail("expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } BigMatrix bs = new BigMatrixImpl(bigSingular); try { bs.solve(bs); fail("Expecting InvalidMatrixException"); } catch (InvalidMatrixException ex) { - ; + // ignored } try { m.solve(bs); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } try { new BigMatrixImpl(testData2).solve(bs); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } try { (new BigMatrixImpl(testData2)).luDecompose(); fail("Expecting InvalidMatrixException"); } catch (InvalidMatrixException ex) { - ; + // ignored } } @@ -396,7 +396,7 @@ public final class BigMatrixImplTest extends TestCase { new BigMatrixImpl(testData2).getDeterminant().doubleValue(); fail("Expecting InvalidMatrixException"); } catch (InvalidMatrixException ex) { - ; + // ignored } } @@ -409,7 +409,7 @@ public final class BigMatrixImplTest extends TestCase { m.getTrace().doubleValue(); fail("Expecting NonSquareMatrixException"); } catch (NonSquareMatrixException ex) { - ; + // ignored } } @@ -430,7 +430,7 @@ public final class BigMatrixImplTest extends TestCase { asDouble(m.operate(asBigDecimal(testVector))); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } } @@ -467,7 +467,7 @@ public final class BigMatrixImplTest extends TestCase { m.preMultiply(asBigDecimal(testVector)); fail("expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } } @@ -493,7 +493,7 @@ public final class BigMatrixImplTest extends TestCase { m.preMultiply(new BigMatrixImpl(bigSingular)); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } } @@ -505,24 +505,24 @@ public final class BigMatrixImplTest extends TestCase { m.getRowAsDoubleArray(10); fail("expecting MatrixIndexException"); } catch (MatrixIndexException ex) { - ; + // ignored } try { m.getColumnAsDoubleArray(-1); fail("expecting MatrixIndexException"); } catch (MatrixIndexException ex) { - ; + // ignored } } public void testLUDecomposition() throws Exception { BigMatrixImpl m = new BigMatrixImpl(testData); BigMatrix lu = m.getLUMatrix(); - assertClose("LU decomposition", lu, (BigMatrix) new BigMatrixImpl(testDataLU), normTolerance); + assertClose("LU decomposition", lu, new BigMatrixImpl(testDataLU), normTolerance); verifyDecomposition(m, lu); m = new BigMatrixImpl(luData); lu = m.getLUMatrix(); - assertClose("LU decomposition", lu, (BigMatrix) new BigMatrixImpl(luDataLUDecomposition), normTolerance); + assertClose("LU decomposition", lu, new BigMatrixImpl(luDataLUDecomposition), normTolerance); verifyDecomposition(m, lu); m = new BigMatrixImpl(testDataMinus); lu = m.getLUMatrix(); diff --git a/src/test/org/apache/commons/math/linear/MatrixUtilsTest.java b/src/test/org/apache/commons/math/linear/MatrixUtilsTest.java index 204d9a115..c62574ee8 100644 --- a/src/test/org/apache/commons/math/linear/MatrixUtilsTest.java +++ b/src/test/org/apache/commons/math/linear/MatrixUtilsTest.java @@ -132,11 +132,11 @@ public final class MatrixUtilsTest extends TestCase { } public void testCreateRowBigMatrix() { - assertEquals((BigMatrixImpl) MatrixUtils.createRowBigMatrix(row), + assertEquals(MatrixUtils.createRowBigMatrix(row), new BigMatrixImpl(rowMatrix)); - assertEquals((BigMatrixImpl) MatrixUtils.createRowBigMatrix(bigRow), + assertEquals(MatrixUtils.createRowBigMatrix(bigRow), new BigMatrixImpl(bigRowMatrix)); - assertEquals((BigMatrixImpl) MatrixUtils.createRowBigMatrix(stringRow), + assertEquals(MatrixUtils.createRowBigMatrix(stringRow), new BigMatrixImpl(stringRowMatrix)); try { MatrixUtils.createRowBigMatrix(new double[] {}); // empty @@ -170,11 +170,11 @@ public final class MatrixUtilsTest extends TestCase { } public void testCreateColumnBigMatrix() { - assertEquals((BigMatrixImpl) MatrixUtils.createColumnBigMatrix(col), + assertEquals(MatrixUtils.createColumnBigMatrix(col), new BigMatrixImpl(colMatrix)); - assertEquals((BigMatrixImpl) MatrixUtils.createColumnBigMatrix(bigCol), + assertEquals(MatrixUtils.createColumnBigMatrix(bigCol), new BigMatrixImpl(bigColMatrix)); - assertEquals((BigMatrixImpl) MatrixUtils.createColumnBigMatrix(stringCol), + assertEquals(MatrixUtils.createColumnBigMatrix(stringCol), new BigMatrixImpl(stringColMatrix)); try { diff --git a/src/test/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java b/src/test/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java index 48d38f881..01fddde4a 100644 --- a/src/test/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java +++ b/src/test/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java @@ -63,7 +63,7 @@ public class EulerStepInterpolatorTest double t0 = 0; double[] y0 = {0.0, 1.0, -2.0}; - double[] y = (double[]) y0.clone(); + double[] y = y0.clone(); double[][] yDot = { new double[y0.length] }; EulerStepInterpolator interpolator = new EulerStepInterpolator(); interpolator.reinitialize(new DummyEquations(), y, yDot, true); diff --git a/src/test/org/apache/commons/math/ode/nonstiff/TestProblem1.java b/src/test/org/apache/commons/math/ode/nonstiff/TestProblem1.java index 2ba8eb19a..d60474d08 100644 --- a/src/test/org/apache/commons/math/ode/nonstiff/TestProblem1.java +++ b/src/test/org/apache/commons/math/ode/nonstiff/TestProblem1.java @@ -59,7 +59,7 @@ public class TestProblem1 */ public TestProblem1(TestProblem1 problem) { super(problem); - y = (double[]) problem.y.clone(); + y = problem.y.clone(); } /** diff --git a/src/test/org/apache/commons/math/ode/nonstiff/TestProblem2.java b/src/test/org/apache/commons/math/ode/nonstiff/TestProblem2.java index 08fa679dc..61fb28346 100644 --- a/src/test/org/apache/commons/math/ode/nonstiff/TestProblem2.java +++ b/src/test/org/apache/commons/math/ode/nonstiff/TestProblem2.java @@ -60,7 +60,7 @@ public class TestProblem2 */ public TestProblem2(TestProblem2 problem) { super(problem); - y = (double[]) problem.y.clone(); + y = problem.y.clone(); } /** diff --git a/src/test/org/apache/commons/math/ode/nonstiff/TestProblem3.java b/src/test/org/apache/commons/math/ode/nonstiff/TestProblem3.java index 9fd6bc857..14fcedaea 100644 --- a/src/test/org/apache/commons/math/ode/nonstiff/TestProblem3.java +++ b/src/test/org/apache/commons/math/ode/nonstiff/TestProblem3.java @@ -75,7 +75,7 @@ public class TestProblem3 public TestProblem3(TestProblem3 problem) { super(problem); e = problem.e; - y = (double[]) problem.y.clone(); + y = problem.y.clone(); } /** diff --git a/src/test/org/apache/commons/math/ode/nonstiff/TestProblem4.java b/src/test/org/apache/commons/math/ode/nonstiff/TestProblem4.java index 0037f998b..c9f1eb8c5 100644 --- a/src/test/org/apache/commons/math/ode/nonstiff/TestProblem4.java +++ b/src/test/org/apache/commons/math/ode/nonstiff/TestProblem4.java @@ -65,7 +65,7 @@ public class TestProblem4 public TestProblem4(TestProblem4 problem) { super(problem); a = problem.a; - y = (double[]) problem.y.clone(); + y = problem.y.clone(); } /** diff --git a/src/test/org/apache/commons/math/ode/nonstiff/TestProblemAbstract.java b/src/test/org/apache/commons/math/ode/nonstiff/TestProblemAbstract.java index c14d76050..0c94094a4 100644 --- a/src/test/org/apache/commons/math/ode/nonstiff/TestProblemAbstract.java +++ b/src/test/org/apache/commons/math/ode/nonstiff/TestProblemAbstract.java @@ -71,12 +71,12 @@ public abstract class TestProblemAbstract if (problem.y0 == null) { y0 = null; } else { - y0 = (double[]) problem.y0.clone(); + y0 = problem.y0.clone(); } if (problem.errorScale == null) { errorScale = null; } else { - errorScale = (double[]) problem.errorScale.clone(); + errorScale = problem.errorScale.clone(); } t1 = problem.t1; } @@ -97,7 +97,7 @@ public abstract class TestProblemAbstract calls = 0; n = y0.length; this.t0 = t0; - this.y0 = (double[]) y0.clone(); + this.y0 = y0.clone(); } /** @@ -113,7 +113,7 @@ public abstract class TestProblemAbstract * @param errorScale error scale */ protected void setErrorScale(double[] errorScale) { - this.errorScale = (double[]) errorScale.clone(); + this.errorScale = errorScale.clone(); } public int getDimension() { diff --git a/src/test/org/apache/commons/math/random/RandomDataTest.java b/src/test/org/apache/commons/math/random/RandomDataTest.java index c2f1ac503..942ae7c2d 100644 --- a/src/test/org/apache/commons/math/random/RandomDataTest.java +++ b/src/test/org/apache/commons/math/random/RandomDataTest.java @@ -18,8 +18,6 @@ package org.apache.commons.math.random; import junit.framework.Test; import junit.framework.TestSuite; -import java.security.NoSuchProviderException; -import java.security.NoSuchAlgorithmException; import java.util.HashSet; import org.apache.commons.math.RetryTestCase; @@ -72,7 +70,7 @@ public class RandomDataTest extends RetryTestCase { randomData.nextInt(4,3); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { - ; + // ignored } Frequency freq = new Frequency(); int value = 0; @@ -99,7 +97,7 @@ public class RandomDataTest extends RetryTestCase { randomData.nextLong(4,3); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { - ; + // ignored } Frequency freq = new Frequency(); long value = 0; @@ -126,7 +124,7 @@ public class RandomDataTest extends RetryTestCase { randomData.nextSecureLong(4,3); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { - ; + // ignored } Frequency freq = new Frequency(); long value = 0; @@ -153,7 +151,7 @@ public class RandomDataTest extends RetryTestCase { randomData.nextSecureInt(4,3); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { - ; + // ignored } Frequency freq = new Frequency(); int value = 0; @@ -185,7 +183,7 @@ public class RandomDataTest extends RetryTestCase { randomData.nextPoisson(0); fail("zero mean -- expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } Frequency f = new Frequency(); for (int i = 0; i set size, expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } // Make sure we fail for empty collection @@ -530,7 +527,7 @@ public class RandomDataTest extends RetryTestCase { one = randomData.nextSample(hs,0); fail("n = k = 0, expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } } @@ -577,7 +574,7 @@ public class RandomDataTest extends RetryTestCase { perm = randomData.nextPermutation(2,3); fail("permutation k > n, expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } // Make sure we fail for n = 0 @@ -585,7 +582,7 @@ public class RandomDataTest extends RetryTestCase { perm = randomData.nextPermutation(0,0); fail("permutation k = n = 0, expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } // Make sure we fail for k < n < 0 @@ -593,7 +590,7 @@ public class RandomDataTest extends RetryTestCase { perm = randomData.nextPermutation(-1,-3); fail("permutation k < n < 0, expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } } diff --git a/src/test/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java b/src/test/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java index 3fcb0d9f8..5cf8f98ed 100644 --- a/src/test/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java +++ b/src/test/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java @@ -112,7 +112,7 @@ public abstract class CertifiedDataAbstractTest extends TestCase { public void testCertifiedValues() { for (String name : certifiedValues.keySet()) { - Double expectedValue = (Double)certifiedValues.get(name); + Double expectedValue = certifiedValues.get(name); Double summariesValue = getProperty(summaries, name); if (summariesValue != null) { diff --git a/src/test/org/apache/commons/math/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java b/src/test/org/apache/commons/math/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java index 7f82b7a87..59ef257fa 100644 --- a/src/test/org/apache/commons/math/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java +++ b/src/test/org/apache/commons/math/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java @@ -183,11 +183,11 @@ public abstract class StorelessUnivariateStatisticAbstractTest StorelessUnivariateStatistic replica = null; // Randomly select a portion of testArray to load first - long index = Math.round((Math.random()) * (double) testArray.length); + long index = Math.round((Math.random()) * testArray.length); // Put first half in master and copy master to replica master.incrementAll(testArray, 0, (int) index); - replica = (StorelessUnivariateStatistic) master.copy(); + replica = master.copy(); // Check same assertTrue(replica.equals(master)); diff --git a/src/test/org/apache/commons/math/stat/descriptive/moment/StandardDeviationTest.java b/src/test/org/apache/commons/math/stat/descriptive/moment/StandardDeviationTest.java index 72f809e99..c60acaf83 100644 --- a/src/test/org/apache/commons/math/stat/descriptive/moment/StandardDeviationTest.java +++ b/src/test/org/apache/commons/math/stat/descriptive/moment/StandardDeviationTest.java @@ -101,7 +101,7 @@ public class StandardDeviationTest extends StorelessUnivariateStatisticAbstractT for (int i = 0; i < v.length; i++) { sum += (v[i] - mean) * (v[i] - mean); } - return Math.sqrt(sum / (double) v.length); + return Math.sqrt(sum / v.length); } } diff --git a/src/test/org/apache/commons/math/stat/descriptive/moment/VarianceTest.java b/src/test/org/apache/commons/math/stat/descriptive/moment/VarianceTest.java index 3cd079f34..143df1f86 100644 --- a/src/test/org/apache/commons/math/stat/descriptive/moment/VarianceTest.java +++ b/src/test/org/apache/commons/math/stat/descriptive/moment/VarianceTest.java @@ -100,7 +100,7 @@ public class VarianceTest extends StorelessUnivariateStatisticAbstractTest{ for (int i = 0; i < v.length; i++) { sum += (v[i] - mean) * (v[i] - mean); } - return sum / (double) v.length; + return sum / v.length; } } diff --git a/src/test/org/apache/commons/math/transform/FastFourierTransformerTest.java b/src/test/org/apache/commons/math/transform/FastFourierTransformerTest.java index 49561dfce..6123ee662 100644 --- a/src/test/org/apache/commons/math/transform/FastFourierTransformerTest.java +++ b/src/test/org/apache/commons/math/transform/FastFourierTransformerTest.java @@ -34,7 +34,7 @@ public final class FastFourierTransformerTest extends TestCase { /** * Test of transformer for the ad hoc data taken from Mathematica. */ - public void testAdHocData() throws MathException { + public void testAdHocData() { FastFourierTransformer transformer = new FastFourierTransformer(); Complex result[]; double tolerance = 1E-12; @@ -78,7 +78,7 @@ public final class FastFourierTransformerTest extends TestCase { } } - public void test2DData() throws MathException { + public void test2DData() { FastFourierTransformer transformer = new FastFourierTransformer(); double tolerance = 1E-12; Complex[][] input = new Complex[][] {new Complex[] {new Complex(1, 0), diff --git a/src/test/org/apache/commons/math/transform/FastHadamardTransformerTest.java b/src/test/org/apache/commons/math/transform/FastHadamardTransformerTest.java index bfc355064..84c362def 100644 --- a/src/test/org/apache/commons/math/transform/FastHadamardTransformerTest.java +++ b/src/test/org/apache/commons/math/transform/FastHadamardTransformerTest.java @@ -77,7 +77,7 @@ public final class FastHadamardTransformerTest extends TestCase { // check double transform double[] dX = new double[x.length]; for (int i = 0; i < dX.length; ++i) { - dX[i] = (double) x[i]; + dX[i] = x[i]; } double dResult[] = transformer.transform(dX); for (int i = 0; i < dResult.length; i++) { @@ -106,7 +106,7 @@ public final class FastHadamardTransformerTest extends TestCase { // check double transform double[] dY = new double[y.length]; for (int i = 0; i < dY.length; ++i) { - dY[i] = (double) y[i]; + dY[i] = y[i]; } double dResult[] = transformer.inversetransform(dY); for (int i = 0; i < dResult.length; i++) { diff --git a/src/test/org/apache/commons/math/util/MathUtilsTest.java b/src/test/org/apache/commons/math/util/MathUtilsTest.java index 392c6e177..967b48d57 100644 --- a/src/test/org/apache/commons/math/util/MathUtilsTest.java +++ b/src/test/org/apache/commons/math/util/MathUtilsTest.java @@ -170,8 +170,8 @@ public final class MathUtilsTest extends TestCase { for (int n = 1; n < 10; n++) { for (int k = 0; k <= n; k++) { assertEquals(n + " choose " + k, binomialCoefficient(n, k), MathUtils.binomialCoefficient(n, k)); - assertEquals(n + " choose " + k, (double)binomialCoefficient(n, k), MathUtils.binomialCoefficientDouble(n, k), Double.MIN_VALUE); - assertEquals(n + " choose " + k, Math.log((double)binomialCoefficient(n, k)), MathUtils.binomialCoefficientLog(n, k), 10E-12); + assertEquals(n + " choose " + k, binomialCoefficient(n, k), MathUtils.binomialCoefficientDouble(n, k), Double.MIN_VALUE); + assertEquals(n + " choose " + k, Math.log(binomialCoefficient(n, k)), MathUtils.binomialCoefficientLog(n, k), 10E-12); } } @@ -181,7 +181,7 @@ public final class MathUtilsTest extends TestCase { long expected = binomialCoefficient(n[i], k[i]); assertEquals(n[i] + " choose " + k[i], expected, MathUtils.binomialCoefficient(n[i], k[i])); - assertEquals(n[i] + " choose " + k[i], (double) expected, + assertEquals(n[i] + " choose " + k[i], expected, MathUtils.binomialCoefficientDouble(n[i], k[i]), 0.0); assertEquals("log(" + n[i] + " choose " + k[i] + ")", Math.log(expected), MathUtils.binomialCoefficientLog(n[i], k[i]), 0.0); @@ -253,53 +253,53 @@ public final class MathUtilsTest extends TestCase { MathUtils.binomialCoefficient(4, 5); fail("expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } try { MathUtils.binomialCoefficientDouble(4, 5); fail("expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } try { MathUtils.binomialCoefficientLog(4, 5); fail("expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } try { MathUtils.binomialCoefficient(-1, -2); fail("expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } try { MathUtils.binomialCoefficientDouble(-1, -2); fail("expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } try { MathUtils.binomialCoefficientLog(-1, -2); fail("expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } try { MathUtils.binomialCoefficient(67, 30); fail("expecting ArithmeticException"); } catch (ArithmeticException ex) { - ; + // ignored } try { MathUtils.binomialCoefficient(67, 34); fail("expecting ArithmeticException"); } catch (ArithmeticException ex) { - ; + // ignored } double x = MathUtils.binomialCoefficientDouble(1030, 515); assertTrue("expecting infinite binomial coefficient", Double @@ -378,8 +378,8 @@ public final class MathUtilsTest extends TestCase { public void testFactorial() { for (int i = 1; i < 21; i++) { assertEquals(i + "! ", factorial(i), MathUtils.factorial(i)); - assertEquals(i + "! ", (double)factorial(i), MathUtils.factorialDouble(i), Double.MIN_VALUE); - assertEquals(i + "! ", Math.log((double)factorial(i)), MathUtils.factorialLog(i), 10E-12); + assertEquals(i + "! ", factorial(i), MathUtils.factorialDouble(i), Double.MIN_VALUE); + assertEquals(i + "! ", Math.log(factorial(i)), MathUtils.factorialLog(i), 10E-12); } assertEquals("0", 1, MathUtils.factorial(0)); @@ -392,25 +392,25 @@ public final class MathUtilsTest extends TestCase { MathUtils.factorial(-1); fail("expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } try { MathUtils.factorialDouble(-1); fail("expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } try { MathUtils.factorialLog(-1); fail("expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - ; + // ignored } try { MathUtils.factorial(21); fail("expecting ArithmeticException"); } catch (ArithmeticException ex) { - ; + // ignored } assertTrue("expecting infinite factorial value", Double.isInfinite(MathUtils.factorialDouble(171))); } @@ -515,7 +515,7 @@ public final class MathUtilsTest extends TestCase { // Generate 10 distinct random values for (int i = 0; i < 10; i++) { - original[i] = random.nextUniform((double)i + 0.5, (double)i + 0.75); + original[i] = random.nextUniform(i + 0.5, i + 0.75); } // Generate a random permutation, making sure it is not the identity @@ -556,9 +556,9 @@ public final class MathUtilsTest extends TestCase { } public void testIndicatorInt() { - assertEquals((int)1, MathUtils.indicator((int)(2))); - assertEquals((int)1, MathUtils.indicator((int)(0))); - assertEquals((int)(-1), MathUtils.indicator((int)(-2))); + assertEquals(1, MathUtils.indicator((2))); + assertEquals(1, MathUtils.indicator((0))); + assertEquals((-1), MathUtils.indicator((-2))); } public void testIndicatorLong() { @@ -999,9 +999,9 @@ public final class MathUtilsTest extends TestCase { } public void testSignInt() { - assertEquals((int) 1, MathUtils.sign((int) 2)); - assertEquals((int) 0, MathUtils.sign((int) 0)); - assertEquals((int) (-1), MathUtils.sign((int) (-2))); + assertEquals(1, MathUtils.sign(2)); + assertEquals(0, MathUtils.sign(0)); + assertEquals((-1), MathUtils.sign((-2))); } public void testSignLong() {