From de75806149238269ea9ea02788eb117c92446f7e Mon Sep 17 00:00:00 2001 From: Sebastien Brisard Date: Fri, 2 Sep 2011 16:46:20 +0000 Subject: [PATCH] In all unit-tests of DecompositionSolver implementations: removed calls to DecompositionSolver.solve(double[]) (MATH-653) git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1164622 13f79535-47bb-0310-9956-ffa450edef68 --- .../math/linear/CholeskySolverTest.java | 9 +-------- .../commons/math/linear/EigenSolverTest.java | 13 +++---------- .../commons/math/linear/LUSolverTest.java | 15 +-------------- .../commons/math/linear/QRSolverTest.java | 19 ------------------- .../math/linear/SingularValueSolverTest.java | 16 +++------------- 5 files changed, 8 insertions(+), 64 deletions(-) diff --git a/src/test/java/org/apache/commons/math/linear/CholeskySolverTest.java b/src/test/java/org/apache/commons/math/linear/CholeskySolverTest.java index 1f1cdb25d..d14017494 100644 --- a/src/test/java/org/apache/commons/math/linear/CholeskySolverTest.java +++ b/src/test/java/org/apache/commons/math/linear/CholeskySolverTest.java @@ -45,7 +45,7 @@ public class CholeskySolverTest { // expected behavior } try { - solver.solve(b.getColumn(0)); + solver.solve(b.getColumnVector(0)); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException iae) { // expected behavior @@ -84,13 +84,6 @@ public class CholeskySolverTest { // using double[][] Assert.assertEquals(0, MatrixUtils.createRealMatrix(solver.solve(b.getData())).subtract(xRef).getNorm(), 1.0e-13); - // using double[] - for (int i = 0; i < b.getColumnDimension(); ++i) { - Assert.assertEquals(0, - new ArrayRealVector(solver.solve(b.getColumn(i))).subtract(xRef.getColumnVector(i)).getNorm(), - 1.0e-13); - } - // using ArrayRealVector for (int i = 0; i < b.getColumnDimension(); ++i) { Assert.assertEquals(0, diff --git a/src/test/java/org/apache/commons/math/linear/EigenSolverTest.java b/src/test/java/org/apache/commons/math/linear/EigenSolverTest.java index a8829c59d..57bfa0a67 100644 --- a/src/test/java/org/apache/commons/math/linear/EigenSolverTest.java +++ b/src/test/java/org/apache/commons/math/linear/EigenSolverTest.java @@ -74,7 +74,7 @@ public class EigenSolverTest { // expected behavior } try { - es.solve(b.getColumn(0)); + es.solve(b.getColumnVector(0)); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException iae) { // expected behavior @@ -124,21 +124,14 @@ public class EigenSolverTest { solution = MatrixUtils.createRealMatrix(es.solve(b.getData())); Assert.assertEquals(0, solution.subtract(xRef).getNorm(), 2.5e-12); - // using double[] - for (int i = 0; i < b.getColumnDimension(); ++i) { - Assert.assertEquals(0, - new ArrayRealVector(es.solve(b.getColumn(i))).subtract(xRef.getColumnVector(i)).getNorm(), - 2.0e-11); - } - - // using Array2DRowRealMatrix + // using RealVector for (int i = 0; i < b.getColumnDimension(); ++i) { Assert.assertEquals(0, es.solve(b.getColumnVector(i)).subtract(xRef.getColumnVector(i)).getNorm(), 2.0e-11); } - // using RealMatrix with an alternate implementation + // using RealVector with an alternate implementation for (int i = 0; i < b.getColumnDimension(); ++i) { ArrayRealVectorTest.RealVectorTestImpl v = new ArrayRealVectorTest.RealVectorTestImpl(b.getColumn(i)); diff --git a/src/test/java/org/apache/commons/math/linear/LUSolverTest.java b/src/test/java/org/apache/commons/math/linear/LUSolverTest.java index c8d5fc681..7b643d83b 100644 --- a/src/test/java/org/apache/commons/math/linear/LUSolverTest.java +++ b/src/test/java/org/apache/commons/math/linear/LUSolverTest.java @@ -83,7 +83,7 @@ public class LUSolverTest { // expected behavior } try { - solver.solve(b.getColumn(0)); + solver.solve(b.getColumnVector(0)); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException iae) { // expected behavior @@ -108,12 +108,6 @@ public class LUSolverTest { } catch (SingularMatrixException ime) { // expected behavior } - try { - solver.solve(b.getColumn(0)); - Assert.fail("an exception should have been thrown"); - } catch (SingularMatrixException ime) { - // expected behavior - } try { solver.solve(b.getColumnVector(0)); Assert.fail("an exception should have been thrown"); @@ -146,13 +140,6 @@ public class LUSolverTest { // using double[][] Assert.assertEquals(0, MatrixUtils.createRealMatrix(solver.solve(b.getData())).subtract(xRef).getNorm(), 1.0e-13); - // using double[] - for (int i = 0; i < b.getColumnDimension(); ++i) { - Assert.assertEquals(0, - new ArrayRealVector(solver.solve(b.getColumn(i))).subtract(xRef.getColumnVector(i)).getNorm(), - 1.0e-13); - } - // using ArrayRealVector for (int i = 0; i < b.getColumnDimension(); ++i) { Assert.assertEquals(0, diff --git a/src/test/java/org/apache/commons/math/linear/QRSolverTest.java b/src/test/java/org/apache/commons/math/linear/QRSolverTest.java index 70fc1f336..296c5eb82 100644 --- a/src/test/java/org/apache/commons/math/linear/QRSolverTest.java +++ b/src/test/java/org/apache/commons/math/linear/QRSolverTest.java @@ -81,12 +81,6 @@ public class QRSolverTest { } catch (MathIllegalArgumentException iae) { // expected behavior } - try { - solver.solve(b.getColumn(0)); - Assert.fail("an exception should have been thrown"); - } catch (MathIllegalArgumentException iae) { - // expected behavior - } try { solver.solve(b.getColumnVector(0)); Assert.fail("an exception should have been thrown"); @@ -107,12 +101,6 @@ public class QRSolverTest { } catch (SingularMatrixException iae) { // expected behavior } - try { - solver.solve(b.getColumn(0)); - Assert.fail("an exception should have been thrown"); - } catch (SingularMatrixException iae) { - // expected behavior - } try { solver.solve(b.getColumnVector(0)); Assert.fail("an exception should have been thrown"); @@ -140,13 +128,6 @@ public class QRSolverTest { // using double[][] Assert.assertEquals(0, MatrixUtils.createRealMatrix(solver.solve(b.getData())).subtract(xRef).getNorm(), 2.0e-16 * xRef.getNorm()); - // using double[] - for (int i = 0; i < b.getColumnDimension(); ++i) { - final double[] x = solver.solve(b.getColumn(i)); - final double error = new ArrayRealVector(x).subtract(xRef.getColumnVector(i)).getNorm(); - Assert.assertEquals(0, error, 3.0e-16 * xRef.getColumnVector(i).getNorm()); - } - // using ArrayRealVector for (int i = 0; i < b.getColumnDimension(); ++i) { final RealVector x = solver.solve(b.getColumnVector(i)); diff --git a/src/test/java/org/apache/commons/math/linear/SingularValueSolverTest.java b/src/test/java/org/apache/commons/math/linear/SingularValueSolverTest.java index 4d301be70..98c36bcd0 100644 --- a/src/test/java/org/apache/commons/math/linear/SingularValueSolverTest.java +++ b/src/test/java/org/apache/commons/math/linear/SingularValueSolverTest.java @@ -44,7 +44,7 @@ public class SingularValueSolverTest { // expected behavior } try { - solver.solve(b.getColumn(0)); + solver.solve(b.getColumnVector(0)); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException iae) { // expected behavior @@ -74,9 +74,6 @@ public class SingularValueSolverTest { Assert.assertEquals(12, xMatrix.getEntry(0, 1), 1.0e-15); Assert.assertEquals(0, xMatrix.getEntry(1, 0), 1.0e-15); Assert.assertEquals(0, xMatrix.getEntry(1, 1), 1.0e-15); - double[] xCol = solver.solve(b.getColumn(0)); - Assert.assertEquals(11, xCol[0], 1.0e-15); - Assert.assertEquals(0, xCol[1], 1.0e-15); RealVector xColVec = solver.solve(b.getColumnVector(0)); Assert.assertEquals(11, xColVec.getEntry(0), 1.0e-15); Assert.assertEquals(0, xColVec.getEntry(1), 1.0e-15); @@ -104,21 +101,14 @@ public class SingularValueSolverTest { // using double[][] Assert.assertEquals(0, MatrixUtils.createRealMatrix(solver.solve(b.getData())).subtract(xRef).getNorm(), normTolerance); - // using double[] - for (int i = 0; i < b.getColumnDimension(); ++i) { - Assert.assertEquals(0, - new ArrayRealVector(solver.solve(b.getColumn(i))).subtract(xRef.getColumnVector(i)).getNorm(), - 1.0e-13); - } - - // using Array2DRowRealMatrix + // using ArrayRealVector for (int i = 0; i < b.getColumnDimension(); ++i) { Assert.assertEquals(0, solver.solve(b.getColumnVector(i)).subtract(xRef.getColumnVector(i)).getNorm(), 1.0e-13); } - // using RealMatrix with an alternate implementation + // using RealVector with an alternate implementation for (int i = 0; i < b.getColumnDimension(); ++i) { ArrayRealVectorTest.RealVectorTestImpl v = new ArrayRealVectorTest.RealVectorTestImpl(b.getColumn(i));