diff --git a/src/test/org/apache/commons/math/analysis/LaguerreSolverTest.java b/src/test/org/apache/commons/math/analysis/LaguerreSolverTest.java index caaa00ec5..12d2bd553 100644 --- a/src/test/org/apache/commons/math/analysis/LaguerreSolverTest.java +++ b/src/test/org/apache/commons/math/analysis/LaguerreSolverTest.java @@ -169,7 +169,7 @@ public final class LaguerreSolverTest extends TestCase { try { // bad function UnivariateRealFunction f2 = new SinFunction(); - UnivariateRealSolver solver2 = new LaguerreSolver(f2); + new LaguerreSolver(f2); fail("Expecting IllegalArgumentException - bad function"); } catch (IllegalArgumentException ex) { // expected diff --git a/src/test/org/apache/commons/math/analysis/PolynomialFunctionLagrangeFormTest.java b/src/test/org/apache/commons/math/analysis/PolynomialFunctionLagrangeFormTest.java index 8e0dfa418..4906f289f 100644 --- a/src/test/org/apache/commons/math/analysis/PolynomialFunctionLagrangeFormTest.java +++ b/src/test/org/apache/commons/math/analysis/PolynomialFunctionLagrangeFormTest.java @@ -126,13 +126,12 @@ public final class PolynomialFunctionLagrangeFormTest extends TestCase { * Test of parameters for the polynomial. */ public void testParameters() throws Exception { - PolynomialFunctionLagrangeForm p; try { // bad input array length double x[] = { 1.0 }; double y[] = { 2.0 }; - p = new PolynomialFunctionLagrangeForm(x, y); + new PolynomialFunctionLagrangeForm(x, y); fail("Expecting IllegalArgumentException - bad input array length"); } catch (IllegalArgumentException ex) { // expected @@ -141,7 +140,7 @@ public final class PolynomialFunctionLagrangeFormTest extends TestCase { // mismatch input arrays double x[] = { 1.0, 2.0, 3.0, 4.0 }; double y[] = { 0.0, -4.0, -24.0 }; - p = new PolynomialFunctionLagrangeForm(x, y); + new PolynomialFunctionLagrangeForm(x, y); fail("Expecting IllegalArgumentException - mismatch input arrays"); } catch (IllegalArgumentException ex) { // expected diff --git a/src/test/org/apache/commons/math/analysis/PolynomialFunctionNewtonFormTest.java b/src/test/org/apache/commons/math/analysis/PolynomialFunctionNewtonFormTest.java index 22b0e9075..005c79f6e 100644 --- a/src/test/org/apache/commons/math/analysis/PolynomialFunctionNewtonFormTest.java +++ b/src/test/org/apache/commons/math/analysis/PolynomialFunctionNewtonFormTest.java @@ -125,13 +125,12 @@ public final class PolynomialFunctionNewtonFormTest extends TestCase { * Test of parameters for the polynomial. */ public void testParameters() throws Exception { - PolynomialFunctionNewtonForm p; try { // bad input array length double a[] = { 1.0 }; double c[] = { 2.0 }; - p = new PolynomialFunctionNewtonForm(a, c); + new PolynomialFunctionNewtonForm(a, c); fail("Expecting IllegalArgumentException - bad input array length"); } catch (IllegalArgumentException ex) { // expected @@ -140,7 +139,7 @@ public final class PolynomialFunctionNewtonFormTest extends TestCase { // mismatch input arrays double a[] = { 1.0, 2.0, 3.0, 4.0 }; double c[] = { 4.0, 3.0, 2.0, 1.0 }; - p = new PolynomialFunctionNewtonForm(a, c); + new PolynomialFunctionNewtonForm(a, c); fail("Expecting IllegalArgumentException - mismatch input arrays"); } catch (IllegalArgumentException ex) { // expected diff --git a/src/test/org/apache/commons/math/analysis/PolynomialFunctionTest.java b/src/test/org/apache/commons/math/analysis/PolynomialFunctionTest.java index bafd8e44d..8bb069369 100644 --- a/src/test/org/apache/commons/math/analysis/PolynomialFunctionTest.java +++ b/src/test/org/apache/commons/math/analysis/PolynomialFunctionTest.java @@ -132,13 +132,13 @@ public final class PolynomialFunctionTest extends TestCase { /** - * tests the firstDerivative function by comparision + * tests the firstDerivative function by comparison * *

This will test the functions * f(x) = x^3 - 2x^2 + 6x + 3, g(x) = 3x^2 - 4x + 6 * and h(x) = 6x - 4 */ - public void testfirstDerivativeComparision() throws MathException { + public void testfirstDerivativeComparison() throws MathException { double[] f_coeff = { 3.0, 6.0, -2.0, 1.0 }; double[] g_coeff = { 6.0, -4.0, 3.0 }; double[] h_coeff = { -4.0, 6.0 }; @@ -155,9 +155,9 @@ public final class PolynomialFunctionTest extends TestCase { assertEquals( f.derivative().value(-3.25), g.value(-3.25), tolerance ); // compare g' = h + assertEquals( g.derivative().value(Math.PI), h.value(Math.PI), tolerance ); + assertEquals( g.derivative().value(Math.E), h.value(Math.E), tolerance ); - - // compare f'' = h } } diff --git a/src/test/org/apache/commons/math/analysis/PolynomialSplineFunctionTest.java b/src/test/org/apache/commons/math/analysis/PolynomialSplineFunctionTest.java index 3bce57cff..926e81ce4 100644 --- a/src/test/org/apache/commons/math/analysis/PolynomialSplineFunctionTest.java +++ b/src/test/org/apache/commons/math/analysis/PolynomialSplineFunctionTest.java @@ -63,24 +63,21 @@ public class PolynomialSplineFunctionTest extends TestCase { assertEquals(3, spline.getN()); try { // too few knots - spline = - new PolynomialSplineFunction(new double[] {0}, polynomials); + new PolynomialSplineFunction(new double[] {0}, polynomials); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { // expected } try { // too many knots - spline = - new PolynomialSplineFunction(new double[] {0,1,2,3,4}, polynomials); + new PolynomialSplineFunction(new double[] {0,1,2,3,4}, polynomials); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { // expected } try { // knots not increasing - spline = - new PolynomialSplineFunction(new double[] {0,1, 3, 2}, polynomials); + new PolynomialSplineFunction(new double[] {0,1, 3, 2}, polynomials); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { // expected diff --git a/src/test/org/apache/commons/math/analysis/UnivariateRealSolverFactoryImplTest.java b/src/test/org/apache/commons/math/analysis/UnivariateRealSolverFactoryImplTest.java index 8b5d4a505..292e914c9 100644 --- a/src/test/org/apache/commons/math/analysis/UnivariateRealSolverFactoryImplTest.java +++ b/src/test/org/apache/commons/math/analysis/UnivariateRealSolverFactoryImplTest.java @@ -52,7 +52,7 @@ public class UnivariateRealSolverFactoryImplTest extends TestCase { public void testNewBisectionSolverNull() { try { - UnivariateRealSolver solver = factory.newBisectionSolver(null); + factory.newBisectionSolver(null); fail(); } catch(IllegalArgumentException ex) { // success @@ -67,7 +67,7 @@ public class UnivariateRealSolverFactoryImplTest extends TestCase { public void testNewNewtonSolverNull() { try { - UnivariateRealSolver solver = factory.newNewtonSolver(null); + factory.newNewtonSolver(null); fail(); } catch(IllegalArgumentException ex) { // success @@ -82,7 +82,7 @@ public class UnivariateRealSolverFactoryImplTest extends TestCase { public void testNewBrentSolverNull() { try { - UnivariateRealSolver solver = factory.newBrentSolver(null); + factory.newBrentSolver(null); fail(); } catch(IllegalArgumentException ex) { // success @@ -97,7 +97,7 @@ public class UnivariateRealSolverFactoryImplTest extends TestCase { public void testNewSecantSolverNull() { try { - UnivariateRealSolver solver = factory.newSecantSolver(null); + factory.newSecantSolver(null); fail(); } catch(IllegalArgumentException ex) { // success diff --git a/src/test/org/apache/commons/math/analysis/UnivariateRealSolverUtilsTest.java b/src/test/org/apache/commons/math/analysis/UnivariateRealSolverUtilsTest.java index 5e5734b68..49c310c0a 100644 --- a/src/test/org/apache/commons/math/analysis/UnivariateRealSolverUtilsTest.java +++ b/src/test/org/apache/commons/math/analysis/UnivariateRealSolverUtilsTest.java @@ -40,20 +40,19 @@ public class UnivariateRealSolverUtilsTest extends TestCase { public void testSolveBadParameters() throws MathException { try { // bad endpoints - double x = UnivariateRealSolverUtils.solve(sin,0.0, 4.0, 4.0); + UnivariateRealSolverUtils.solve(sin,0.0, 4.0, 4.0); } catch (IllegalArgumentException ex) { // expected } try { // bad accuracy - double x = UnivariateRealSolverUtils.solve(sin, 0.0, 4.0, 0.0); + UnivariateRealSolverUtils.solve(sin, 0.0, 4.0, 0.0); } catch (IllegalArgumentException ex) { // expected } } public void testSolveSin() throws MathException { - double x = UnivariateRealSolverUtils.solve(sin, 1.0, - 4.0); + double x = UnivariateRealSolverUtils.solve(sin, 1.0, 4.0); assertEquals(Math.PI, x, 1.0e-4); } @@ -76,8 +75,7 @@ public class UnivariateRealSolverUtilsTest extends TestCase { public void testSolveNoRoot() throws MathException { try { - double x = UnivariateRealSolverUtils.solve(sin, 1.0, - 1.5); + UnivariateRealSolverUtils.solve(sin, 1.0, 1.5); fail("Expecting IllegalArgumentException "); } catch (IllegalArgumentException ex) { // expected @@ -93,8 +91,7 @@ public class UnivariateRealSolverUtilsTest extends TestCase { public void testBracketCornerSolution() throws MathException { try { - double[] result = UnivariateRealSolverUtils.bracket(sin, - 1.5, 0, 2.0); + UnivariateRealSolverUtils.bracket(sin, 1.5, 0, 2.0); fail("Expecting ConvergenceException"); } catch (ConvergenceException ex) { // expected @@ -103,25 +100,25 @@ public class UnivariateRealSolverUtilsTest extends TestCase { public void testBadParameters() throws MathException { try { // null function - double[] result = UnivariateRealSolverUtils.bracket(null, 1.5, 0, 2.0); + UnivariateRealSolverUtils.bracket(null, 1.5, 0, 2.0); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { // expected } try { // initial not between endpoints - double[] result = UnivariateRealSolverUtils.bracket(sin, 2.5, 0, 2.0); + UnivariateRealSolverUtils.bracket(sin, 2.5, 0, 2.0); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { // expected } try { // endpoints not valid - double[] result = UnivariateRealSolverUtils.bracket(sin, 1.5, 2.0, 1.0); + UnivariateRealSolverUtils.bracket(sin, 1.5, 2.0, 1.0); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { // expected } try { // bad maximum iterations - double[] result = UnivariateRealSolverUtils.bracket(sin, 1.5, 0, 2.0, 0); + UnivariateRealSolverUtils.bracket(sin, 1.5, 0, 2.0, 0); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { // expected diff --git a/src/test/org/apache/commons/math/complex/ComplexUtilsTest.java b/src/test/org/apache/commons/math/complex/ComplexUtilsTest.java index 6b1eb1789..bc4fe72f8 100644 --- a/src/test/org/apache/commons/math/complex/ComplexUtilsTest.java +++ b/src/test/org/apache/commons/math/complex/ComplexUtilsTest.java @@ -39,7 +39,6 @@ public class ComplexUtilsTest extends TestCase { private Complex infNegInf = new Complex(inf, negInf); private Complex infInf = new Complex(inf, inf); private Complex negInfNegInf = new Complex(negInf, negInf); - private Complex oneNaN = new Complex(1, nan); private Complex infNaN = new Complex(inf, nan); private Complex negInfNaN = new Complex(negInf, nan); private Complex nanInf = new Complex(nan, inf); @@ -48,11 +47,8 @@ public class ComplexUtilsTest extends TestCase { private Complex nanZero = new Complex(nan, 0); private Complex infZero = new Complex(inf, 0); private Complex zeroInf = new Complex(0, inf); - private Complex zeroNegInf = new Complex(0, negInf); private Complex negInfZero = new Complex(negInf, 0); - private ComplexFormat fmt = new ComplexFormat(); - public void testAcos() { Complex z = new Complex(3, 4); Complex expected = new Complex(0.936812, -2.30551); @@ -78,7 +74,7 @@ public class ComplexUtilsTest extends TestCase { public void testAcosNull() { try { - Complex z = ComplexUtils.acos(null); + ComplexUtils.acos(null); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected @@ -108,7 +104,7 @@ public class ComplexUtilsTest extends TestCase { public void testAsinNull() { try { - Complex z = ComplexUtils.asin(null); + ComplexUtils.asin(null); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected @@ -139,7 +135,7 @@ public class ComplexUtilsTest extends TestCase { public void testAtanNull() { try { - Complex z = ComplexUtils.atan(null); + ComplexUtils.atan(null); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected @@ -169,7 +165,7 @@ public class ComplexUtilsTest extends TestCase { public void testCosNull() { try { - Complex z = ComplexUtils.cos(null); + ComplexUtils.cos(null); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected @@ -199,7 +195,7 @@ public class ComplexUtilsTest extends TestCase { public void testCoshNull() { try { - Complex z = ComplexUtils.cosh(null); + ComplexUtils.cosh(null); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected @@ -234,7 +230,7 @@ public class ComplexUtilsTest extends TestCase { public void testExpNull() { try { - Complex z = ComplexUtils.exp(null); + ComplexUtils.exp(null); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected @@ -275,7 +271,7 @@ public class ComplexUtilsTest extends TestCase { public void testlogNull() { try { - Complex z = ComplexUtils.log(null); + ComplexUtils.log(null); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected @@ -318,7 +314,7 @@ public class ComplexUtilsTest extends TestCase { public void testPolar2ComplexIllegalModulus() { try { - Complex z = ComplexUtils.polar2Complex(-1, 0); + ComplexUtils.polar2Complex(-1, 0); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { // expected @@ -405,13 +401,13 @@ public class ComplexUtilsTest extends TestCase { public void testpowNull() { try { - Complex z = ComplexUtils.pow(null, Complex.ONE); + ComplexUtils.pow(null, Complex.ONE); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected } try { - Complex z = ComplexUtils.pow(Complex.ONE, null); + ComplexUtils.pow(Complex.ONE, null); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected @@ -441,7 +437,7 @@ public class ComplexUtilsTest extends TestCase { public void testSinNull() { try { - Complex z = ComplexUtils.sin(null); + ComplexUtils.sin(null); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected @@ -471,7 +467,7 @@ public class ComplexUtilsTest extends TestCase { public void testsinhNull() { try { - Complex z = ComplexUtils.sinh(null); + ComplexUtils.sinh(null); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected @@ -539,7 +535,7 @@ public class ComplexUtilsTest extends TestCase { public void testSqrtNull() { try { - Complex z = ComplexUtils.sqrt(null); + ComplexUtils.sqrt(null); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected @@ -558,7 +554,7 @@ public class ComplexUtilsTest extends TestCase { public void testSqrt1zNull() { try { - Complex z = ComplexUtils.sqrt1z(null); + ComplexUtils.sqrt1z(null); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected @@ -593,7 +589,7 @@ public class ComplexUtilsTest extends TestCase { public void testTanNull() { try { - Complex z = ComplexUtils.tan(null); + ComplexUtils.tan(null); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected @@ -627,7 +623,7 @@ public class ComplexUtilsTest extends TestCase { public void testTanhNull() { try { - Complex z = ComplexUtils.tanh(null); + ComplexUtils.tanh(null); fail("Expecting NullPointerException"); } catch (NullPointerException ex) { // expected diff --git a/src/test/org/apache/commons/math/fraction/FractionFormatTest.java b/src/test/org/apache/commons/math/fraction/FractionFormatTest.java index fc3f1851c..8e14fdbd0 100644 --- a/src/test/org/apache/commons/math/fraction/FractionFormatTest.java +++ b/src/test/org/apache/commons/math/fraction/FractionFormatTest.java @@ -233,14 +233,14 @@ public class FractionFormatTest extends TestCase { public void testParseProperInvalidMinus() { String source = "2 -2 / 3"; try { - Fraction c = properFormat.parse(source); + properFormat.parse(source); fail("invalid minus in improper fraction."); } catch (ParseException ex) { // expected } source = "2 2 / -3"; try { - Fraction c = properFormat.parse(source); + properFormat.parse(source); fail("invalid minus in improper fraction."); } catch (ParseException ex) { // expected diff --git a/src/test/org/apache/commons/math/fraction/FractionTest.java b/src/test/org/apache/commons/math/fraction/FractionTest.java index cdd7a1c82..8c8763394 100644 --- a/src/test/org/apache/commons/math/fraction/FractionTest.java +++ b/src/test/org/apache/commons/math/fraction/FractionTest.java @@ -280,7 +280,7 @@ public class FractionTest extends TestCase { Fraction f1 = new Fraction(3, 5); Fraction f2 = Fraction.ZERO; try { - Fraction f = f1.divide(f2); + f1.divide(f2); fail("expecting ArithmeticException"); } catch (ArithmeticException ex) {} @@ -417,7 +417,6 @@ public class FractionTest extends TestCase { public void testEqualsAndHashCode() { Fraction zero = new Fraction(0,1); Fraction nullFraction = null; - int zeroHash = zero.hashCode(); assertTrue( zero.equals(zero)); assertFalse(zero.equals(nullFraction)); assertFalse(zero.equals(new Double(0))); @@ -433,7 +432,7 @@ public class FractionTest extends TestCase { assertTrue(threeFourths.equals(Fraction.getReducedFraction(6, 8))); assertTrue(Fraction.ZERO.equals(Fraction.getReducedFraction(0, -1))); try { - Fraction f = Fraction.getReducedFraction(1, 0); + Fraction.getReducedFraction(1, 0); fail("expecting ArithmeticException"); } catch (ArithmeticException ex) { // expected diff --git a/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java b/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java index 695fa5fe1..93eebaf00 100644 --- a/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java +++ b/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java @@ -170,38 +170,38 @@ public final class BigMatrixImplTest extends TestCase { assertClose("double, BigDecimal", m1, m3, Double.MIN_VALUE); assertClose("string, BigDecimal", m2, m3, Double.MIN_VALUE); try { - BigMatrix m4 = new BigMatrixImpl(new String[][] {{"0", "hello", "1"}}); + new BigMatrixImpl(new String[][] {{"0", "hello", "1"}}); fail("Expecting NumberFormatException"); } catch (NumberFormatException ex) { // expected } try { - BigMatrix m4 = new BigMatrixImpl(new String[][] {}); + new BigMatrixImpl(new String[][] {}); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { // expected } try { - BigMatrix m4 = new BigMatrixImpl(new String[][] {{},{}}); + new BigMatrixImpl(new String[][] {{},{}}); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { // expected } try { - BigMatrix m4 = new BigMatrixImpl(new String[][] {{"a", "b"},{"c"}}); + new BigMatrixImpl(new String[][] {{"a", "b"},{"c"}}); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { // expected } try { - BigMatrix m4 = new BigMatrixImpl(0, 1); + new BigMatrixImpl(0, 1); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { // expected } try { - BigMatrix m4 = new BigMatrixImpl(1, 0); + new BigMatrixImpl(1, 0); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { // expected @@ -228,7 +228,7 @@ public final class BigMatrixImplTest extends TestCase { BigMatrixImpl m = new BigMatrixImpl(testData); BigMatrixImpl m2 = new BigMatrixImpl(testData2); try { - BigMatrixImpl mPlusMInv = (BigMatrixImpl)m.add(m2); + m.add(m2); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { ; @@ -250,7 +250,7 @@ public final class BigMatrixImplTest extends TestCase { assertClose("m-n = m + -n",m.subtract(m2), m2.scalarMultiply(new BigDecimal(-1d)).add(m),entryTolerance); try { - BigMatrix a = m.subtract(new BigMatrixImpl(testData2)); + m.subtract(new BigMatrixImpl(testData2)); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { ; @@ -274,7 +274,7 @@ public final class BigMatrixImplTest extends TestCase { assertClose("identity multiply",m2.multiply(identity), m2,entryTolerance); try { - BigMatrix a = m.multiply(new BigMatrixImpl(bigSingular)); + m.multiply(new BigMatrixImpl(bigSingular)); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { ; @@ -342,26 +342,26 @@ public final class BigMatrixImplTest extends TestCase { asDouble(m.solve(asBigDecimal(testVector))), normTolerance); try { - double[] x = asDouble(m.solve(asBigDecimal(testVector2))); + asDouble(m.solve(asBigDecimal(testVector2))); fail("expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { ; } BigMatrix bs = new BigMatrixImpl(bigSingular); try { - BigMatrix a = bs.solve(bs); + bs.solve(bs); fail("Expecting InvalidMatrixException"); } catch (InvalidMatrixException ex) { ; } try { - BigMatrix a = m.solve(bs); + m.solve(bs); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { ; } try { - BigMatrix a = (new BigMatrixImpl(testData2)).solve(bs); + new BigMatrixImpl(testData2).solve(bs); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { ; @@ -388,7 +388,7 @@ public final class BigMatrixImplTest extends TestCase { assertEquals("nonsingular R test 2",-1d,m.getDeterminant().doubleValue(),normTolerance); try { - double a = new BigMatrixImpl(testData2).getDeterminant().doubleValue(); + new BigMatrixImpl(testData2).getDeterminant().doubleValue(); fail("Expecting InvalidMatrixException"); } catch (InvalidMatrixException ex) { ; @@ -401,7 +401,7 @@ public final class BigMatrixImplTest extends TestCase { assertEquals("identity trace",3d,m.getTrace().doubleValue(),entryTolerance); m = new BigMatrixImpl(testData2); try { - double x = m.getTrace().doubleValue(); + m.getTrace().doubleValue(); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { ; @@ -422,7 +422,7 @@ public final class BigMatrixImplTest extends TestCase { assertClose("identity operate",testVector,x,entryTolerance); m = new BigMatrixImpl(bigSingular); try { - x = asDouble(m.operate(asBigDecimal(testVector))); + asDouble(m.operate(asBigDecimal(testVector))); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { ; @@ -461,7 +461,7 @@ public final class BigMatrixImplTest extends TestCase { BigMatrixImpl m = new BigMatrixImpl(testData); BigMatrixImpl mInv = new BigMatrixImpl(testDataInv); BigMatrixImpl identity = new BigMatrixImpl(id); - BigMatrixImpl m2 = new BigMatrixImpl(testData2); + new BigMatrixImpl(testData2); assertClose("inverse multiply",m.preMultiply(mInv), identity,entryTolerance); assertClose("inverse multiply",mInv.preMultiply(m), @@ -471,7 +471,7 @@ public final class BigMatrixImplTest extends TestCase { assertClose("identity multiply",identity.preMultiply(mInv), mInv,entryTolerance); try { - BigMatrix a = m.preMultiply(new BigMatrixImpl(bigSingular)); + m.preMultiply(new BigMatrixImpl(bigSingular)); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { ; @@ -483,13 +483,13 @@ public final class BigMatrixImplTest extends TestCase { assertClose("get row",m.getRowAsDoubleArray(0),testDataRow1,entryTolerance); assertClose("get col",m.getColumnAsDoubleArray(2),testDataCol3,entryTolerance); try { - double[] x = m.getRowAsDoubleArray(10); + m.getRowAsDoubleArray(10); fail("expecting MatrixIndexException"); } catch (MatrixIndexException ex) { ; } try { - double[] x = m.getColumnAsDoubleArray(-1); + m.getColumnAsDoubleArray(-1); fail("expecting MatrixIndexException"); } catch (MatrixIndexException ex) { ; diff --git a/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java b/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java index 04729dd3d..8f3dc6cad 100644 --- a/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java +++ b/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java @@ -141,7 +141,7 @@ public final class RealMatrixImplTest extends TestCase { RealMatrixImpl m = new RealMatrixImpl(testData); RealMatrixImpl m2 = new RealMatrixImpl(testData2); try { - RealMatrixImpl mPlusMInv = (RealMatrixImpl)m.add(m2); + m.add(m2); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { ; @@ -163,7 +163,7 @@ public final class RealMatrixImplTest extends TestCase { assertClose("m-n = m + -n",m.subtract(m2), m2.scalarMultiply(-1d).add(m),entryTolerance); try { - RealMatrix a = m.subtract(new RealMatrixImpl(testData2)); + m.subtract(new RealMatrixImpl(testData2)); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { ; @@ -187,7 +187,7 @@ public final class RealMatrixImplTest extends TestCase { assertClose("identity multiply",m2.multiply(identity), m2,entryTolerance); try { - RealMatrix a = m.multiply(new RealMatrixImpl(bigSingular)); + m.multiply(new RealMatrixImpl(bigSingular)); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { ; @@ -253,26 +253,26 @@ public final class RealMatrixImplTest extends TestCase { assertClose("inverse-operate",mInv.operate(testVector), m.solve(testVector),normTolerance); try { - double[] x = m.solve(testVector2); + m.solve(testVector2); fail("expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { ; } RealMatrix bs = new RealMatrixImpl(bigSingular); try { - RealMatrix a = bs.solve(bs); + bs.solve(bs); fail("Expecting InvalidMatrixException"); } catch (InvalidMatrixException ex) { ; } try { - RealMatrix a = m.solve(bs); + m.solve(bs); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { ; } try { - RealMatrix a = (new RealMatrixImpl(testData2)).solve(bs); + new RealMatrixImpl(testData2).solve(bs); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { ; @@ -299,7 +299,7 @@ public final class RealMatrixImplTest extends TestCase { assertEquals("nonsingular R test 2",-1d,m.getDeterminant(),normTolerance); try { - double a = new RealMatrixImpl(testData2).getDeterminant(); + new RealMatrixImpl(testData2).getDeterminant(); fail("Expecting InvalidMatrixException"); } catch (InvalidMatrixException ex) { ; @@ -312,7 +312,7 @@ public final class RealMatrixImplTest extends TestCase { assertEquals("identity trace",3d,m.getTrace(),entryTolerance); m = new RealMatrixImpl(testData2); try { - double x = m.getTrace(); + m.getTrace(); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { ; @@ -333,7 +333,7 @@ public final class RealMatrixImplTest extends TestCase { assertClose("identity operate",testVector,x,entryTolerance); m = new RealMatrixImpl(bigSingular); try { - x = m.operate(testVector); + m.operate(testVector); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { ; @@ -372,7 +372,6 @@ public final class RealMatrixImplTest extends TestCase { RealMatrixImpl m = new RealMatrixImpl(testData); RealMatrixImpl mInv = new RealMatrixImpl(testDataInv); RealMatrixImpl identity = new RealMatrixImpl(id); - RealMatrixImpl m2 = new RealMatrixImpl(testData2); assertClose("inverse multiply",m.preMultiply(mInv), identity,entryTolerance); assertClose("inverse multiply",mInv.preMultiply(m), @@ -382,7 +381,7 @@ public final class RealMatrixImplTest extends TestCase { assertClose("identity multiply",identity.preMultiply(mInv), mInv,entryTolerance); try { - RealMatrix a = m.preMultiply(new RealMatrixImpl(bigSingular)); + m.preMultiply(new RealMatrixImpl(bigSingular)); fail("Expecting illegalArgumentException"); } catch (IllegalArgumentException ex) { ; @@ -394,13 +393,13 @@ public final class RealMatrixImplTest extends TestCase { assertClose("get row",m.getRow(0),testDataRow1,entryTolerance); assertClose("get col",m.getColumn(2),testDataCol3,entryTolerance); try { - double[] x = m.getRow(10); + m.getRow(10); fail("expecting MatrixIndexException"); } catch (MatrixIndexException ex) { ; } try { - double[] x = m.getColumn(-1); + m.getColumn(-1); fail("expecting MatrixIndexException"); } catch (MatrixIndexException ex) { ; diff --git a/src/test/org/apache/commons/math/random/AbstractRandomGeneratorTest.java b/src/test/org/apache/commons/math/random/AbstractRandomGeneratorTest.java index 6c91af3ec..00da08f74 100644 --- a/src/test/org/apache/commons/math/random/AbstractRandomGeneratorTest.java +++ b/src/test/org/apache/commons/math/random/AbstractRandomGeneratorTest.java @@ -44,7 +44,7 @@ public class AbstractRandomGeneratorTest extends RandomDataTest { public void testNextInt() { try { - int x = testGenerator.nextInt(-1); + testGenerator.nextInt(-1); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { ; diff --git a/src/test/org/apache/commons/math/random/RandomDataTest.java b/src/test/org/apache/commons/math/random/RandomDataTest.java index f4cedaeec..87cd7b9ee 100644 --- a/src/test/org/apache/commons/math/random/RandomDataTest.java +++ b/src/test/org/apache/commons/math/random/RandomDataTest.java @@ -43,7 +43,6 @@ public class RandomDataTest extends RetryTestCase { protected long smallSampleSize = 1000; protected double[] expected = {250,250,250,250}; protected int largeSampleSize = 10000; - private int tolerance = 50; private String[] hex = {"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}; protected RandomDataImpl randomData = null; @@ -73,7 +72,7 @@ public class RandomDataTest extends RetryTestCase { /** test dispersion and failure modes for nextInt() */ public void testNextInt() { try { - int x = randomData.nextInt(4,3); + randomData.nextInt(4,3); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { ; @@ -100,7 +99,7 @@ public class RandomDataTest extends RetryTestCase { /** test dispersion and failure modes for nextLong() */ public void testNextLong() { try { - long x = randomData.nextLong(4,3); + randomData.nextLong(4,3); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { ; @@ -127,7 +126,7 @@ public class RandomDataTest extends RetryTestCase { /** test dispersion and failure modes for nextSecureLong() */ public void testNextSecureLong() { try { - long x = randomData.nextSecureLong(4,3); + randomData.nextSecureLong(4,3); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { ; @@ -154,7 +153,7 @@ public class RandomDataTest extends RetryTestCase { /** test dispersion and failure modes for nextSecureInt() */ public void testNextSecureInt() { try { - long x = randomData.nextSecureInt(4,3); + randomData.nextSecureInt(4,3); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { ; @@ -186,13 +185,12 @@ public class RandomDataTest extends RetryTestCase { */ public void testNextPoisson() { try { - long x = randomData.nextPoisson(0); + randomData.nextPoisson(0); fail("zero mean -- expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { ; } Frequency f = new Frequency(); - long v = 0; for (int i = 0; i + + Fixed numerous warnings in test code. + Use the initial guess provided by the user in BrentSolver.solve(), thus improving speed. - + Added the estimation optimization, geometry and ode package from the Mantissa library.