You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2009/09/05 19:37:05 UTC
svn commit: r811685 [19/24] - in /commons/proper/math/trunk: ./
src/main/java/org/apache/commons/math/
src/main/java/org/apache/commons/math/analysis/
src/main/java/org/apache/commons/math/analysis/integration/
src/main/java/org/apache/commons/math/ana...
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockRealMatrixTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockRealMatrixTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockRealMatrixTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockRealMatrixTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,45 +32,45 @@
*/
public final class BlockRealMatrixTest extends TestCase {
-
+
// 3 x 3 identity matrix
protected double[][] id = { {1d,0d,0d}, {0d,1d,0d}, {0d,0d,1d} };
-
+
// Test data for group operations
protected double[][] testData = { {1d,2d,3d}, {2d,5d,3d}, {1d,0d,8d} };
protected double[][] testDataLU = {{2d, 5d, 3d}, {.5d, -2.5d, 6.5d}, {0.5d, 0.2d, .2d}};
protected double[][] testDataPlus2 = { {3d,4d,5d}, {4d,7d,5d}, {3d,2d,10d} };
- protected double[][] testDataMinus = { {-1d,-2d,-3d}, {-2d,-5d,-3d},
+ protected double[][] testDataMinus = { {-1d,-2d,-3d}, {-2d,-5d,-3d},
{-1d,0d,-8d} };
protected double[] testDataRow1 = {1d,2d,3d};
protected double[] testDataCol3 = {3d,3d,8d};
- protected double[][] testDataInv =
+ protected double[][] testDataInv =
{ {-40d,16d,9d}, {13d,-5d,-3d}, {5d,-2d,-1d} };
protected double[] preMultTest = {8,12,33};
protected double[][] testData2 ={ {1d,2d,3d}, {2d,5d,3d}};
protected double[][] testData2T = { {1d,2d}, {2d,5d}, {3d,3d}};
- protected double[][] testDataPlusInv =
+ protected double[][] testDataPlusInv =
{ {-39d,18d,12d}, {15d,0d,0d}, {6d,-2d,7d} };
-
+
// lu decomposition tests
protected double[][] luData = { {2d,3d,3d}, {0d,5d,7d}, {6d,9d,8d} };
protected double[][] luDataLUDecomposition = { {6d,9d,8d}, {0d,5d,7d},
{0.33333333333333,0d,0.33333333333333} };
-
+
// singular matrices
protected double[][] singular = { {2d,3d}, {2d,3d} };
protected double[][] bigSingular = {{1d,2d,3d,4d}, {2d,5d,3d,4d},
{7d,3d,256d,1930d}, {3d,7d,6d,8d}}; // 4th row = 1st + 2nd
protected double[][] detData = { {1d,2d,3d}, {4d,5d,6d}, {7d,8d,10d} };
protected double[][] detData2 = { {1d, 3d}, {2d, 4d}};
-
+
// vectors
protected double[] testVector = {1,2,3};
protected double[] testVector2 = {1,2,3,4};
-
+
// submatrix accessor tests
protected double[][] subTestData = {{1, 2, 3, 4}, {1.5, 2.5, 3.5, 4.5},
- {2, 4, 6, 8}, {4, 5, 6, 7}};
+ {2, 4, 6, 8}, {4, 5, 6, 7}};
// array selections
protected double[][] subRows02Cols13 = { {2, 4}, {4, 8}};
protected double[][] subRows03Cols12 = { {2, 3}, {5, 6}};
@@ -88,21 +88,21 @@
// column matrices
protected double[][] subColumn1 = {{2}, {2.5}, {4}, {5}};
protected double[][] subColumn3 = {{4}, {4.5}, {8}, {7}};
-
+
// tolerances
protected double entryTolerance = 10E-16;
protected double normTolerance = 10E-14;
-
+
public BlockRealMatrixTest(String name) {
super(name);
}
-
+
public static Test suite() {
TestSuite suite = new TestSuite(BlockRealMatrixTest.class);
suite.setName("BlockRealMatrix Tests");
return suite;
}
-
+
/** test dimensions */
public void testDimensions() {
BlockRealMatrix m = new BlockRealMatrix(testData);
@@ -113,8 +113,8 @@
assertEquals("testData2 row dimension",m2.getRowDimension(),2);
assertEquals("testData2 column dimension",m2.getColumnDimension(),3);
assertTrue("testData2 is not square",!m2.isSquare());
- }
-
+ }
+
/** test copy functions */
public void testCopyFunctions() {
Random r = new Random(66636328996002l);
@@ -124,8 +124,8 @@
BlockRealMatrix m3 = new BlockRealMatrix(testData);
BlockRealMatrix m4 = new BlockRealMatrix(m3.getData());
assertEquals(m3, m4);
- }
-
+ }
+
/** test add */
public void testAdd() {
BlockRealMatrix m = new BlockRealMatrix(testData);
@@ -138,9 +138,9 @@
testDataPlusInv[row][col],sumEntries[row][col],
entryTolerance);
}
- }
+ }
}
-
+
/** test add failure */
public void testAddFail() {
BlockRealMatrix m = new BlockRealMatrix(testData);
@@ -152,7 +152,7 @@
// ignored
}
}
-
+
/** test norm */
public void testNorm() {
BlockRealMatrix m = new BlockRealMatrix(testData);
@@ -160,7 +160,7 @@
assertEquals("testData norm",14d,m.getNorm(),entryTolerance);
assertEquals("testData2 norm",7d,m2.getNorm(),entryTolerance);
}
-
+
/** test Frobenius norm */
public void testFrobeniusNorm() {
BlockRealMatrix m = new BlockRealMatrix(testData);
@@ -168,20 +168,20 @@
assertEquals("testData Frobenius norm", Math.sqrt(117.0), m.getFrobeniusNorm(), entryTolerance);
assertEquals("testData2 Frobenius norm", Math.sqrt(52.0), m2.getFrobeniusNorm(), entryTolerance);
}
-
+
/** test m-n = m + -n */
public void testPlusMinus() {
BlockRealMatrix m = new BlockRealMatrix(testData);
BlockRealMatrix m2 = new BlockRealMatrix(testDataInv);
- assertClose(m.subtract(m2), m2.scalarMultiply(-1d).add(m), entryTolerance);
+ assertClose(m.subtract(m2), m2.scalarMultiply(-1d).add(m), entryTolerance);
try {
m.subtract(new BlockRealMatrix(testData2));
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// ignored
- }
+ }
}
-
+
/** test multiply */
public void testMultiply() {
BlockRealMatrix m = new BlockRealMatrix(testData);
@@ -192,13 +192,13 @@
assertClose(mInv.multiply(m), identity, entryTolerance);
assertClose(m.multiply(identity), m, entryTolerance);
assertClose(identity.multiply(mInv), mInv, entryTolerance);
- assertClose(m2.multiply(identity), m2, entryTolerance);
+ assertClose(m2.multiply(identity), m2, entryTolerance);
try {
m.multiply(new BlockRealMatrix(bigSingular));
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// expected
- }
+ }
}
public void testSeveralBlocks() {
@@ -290,14 +290,14 @@
private double[][] d3 = new double[][] {{1,2,3,4},{5,6,7,8}};
private double[][] d4 = new double[][] {{1},{2},{3},{4}};
private double[][] d5 = new double[][] {{30},{70}};
-
- public void testMultiply2() {
- RealMatrix m3 = new BlockRealMatrix(d3);
+
+ public void testMultiply2() {
+ RealMatrix m3 = new BlockRealMatrix(d3);
RealMatrix m4 = new BlockRealMatrix(d4);
RealMatrix m5 = new BlockRealMatrix(d5);
assertClose(m3.multiply(m4), m5, entryTolerance);
- }
-
+ }
+
/** test trace */
public void testTrace() {
RealMatrix m = new BlockRealMatrix(id);
@@ -308,15 +308,15 @@
fail("Expecting NonSquareMatrixException");
} catch (NonSquareMatrixException ex) {
// ignored
- }
+ }
}
-
+
/** test scalarAdd */
public void testScalarAdd() {
RealMatrix m = new BlockRealMatrix(testData);
assertClose(new BlockRealMatrix(testDataPlus2), m.scalarAdd(2d), entryTolerance);
}
-
+
/** test operate */
public void testOperate() {
RealMatrix m = new BlockRealMatrix(id);
@@ -328,7 +328,7 @@
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// ignored
- }
+ }
}
public void testOperateLarge() {
@@ -368,10 +368,10 @@
assertEquals( 7.0, b[1], 1.0e-12);
assertEquals(11.0, b[2], 1.0e-12);
}
-
+
/** test transpose */
public void testTranspose() {
- RealMatrix m = new BlockRealMatrix(testData);
+ RealMatrix m = new BlockRealMatrix(testData);
RealMatrix mIT = new LUDecompositionImpl(m).getSolver().getInverse().transpose();
RealMatrix mTI = new LUDecompositionImpl(m.transpose()).getSolver().getInverse();
assertClose(mIT, mTI, normTolerance);
@@ -379,7 +379,7 @@
RealMatrix mt = new BlockRealMatrix(testData2T);
assertClose(mt, m.transpose(), normTolerance);
}
-
+
/** test preMultiply by vector */
public void testPremultiplyVector() {
RealMatrix m = new BlockRealMatrix(testData);
@@ -394,13 +394,13 @@
// ignored
}
}
-
+
public void testPremultiply() {
- RealMatrix m3 = new BlockRealMatrix(d3);
+ RealMatrix m3 = new BlockRealMatrix(d3);
RealMatrix m4 = new BlockRealMatrix(d4);
RealMatrix m5 = new BlockRealMatrix(d5);
assertClose(m4.preMultiply(m3), m5, entryTolerance);
-
+
BlockRealMatrix m = new BlockRealMatrix(testData);
BlockRealMatrix mInv = new BlockRealMatrix(testDataInv);
BlockRealMatrix identity = new BlockRealMatrix(id);
@@ -413,9 +413,9 @@
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// ignored
- }
+ }
}
-
+
public void testGetVectors() {
RealMatrix m = new BlockRealMatrix(testData);
assertClose(m.getRow(0), testDataRow1, entryTolerance);
@@ -433,7 +433,7 @@
// ignored
}
}
-
+
public void testGetEntry() {
RealMatrix m = new BlockRealMatrix(testData);
assertEquals("get entry",m.getEntry(0,1),2d,entryTolerance);
@@ -444,7 +444,7 @@
// expected
}
}
-
+
/** test examples in user guide */
public void testExamples() {
// Create a real matrix with two rows and three columns
@@ -458,10 +458,10 @@
assertEquals(2, p.getRowDimension());
assertEquals(2, p.getColumnDimension());
// Invert p
- RealMatrix pInverse = new LUDecompositionImpl(p).getSolver().getInverse();
+ RealMatrix pInverse = new LUDecompositionImpl(p).getSolver().getInverse();
assertEquals(2, pInverse.getRowDimension());
assertEquals(2, pInverse.getColumnDimension());
-
+
// Solve example
double[][] coefficientsData = {{2, 3, -2}, {-1, 7, 6}, {4, -3, -5}};
RealMatrix coefficients = new BlockRealMatrix(coefficientsData);
@@ -469,22 +469,22 @@
double[] solution = new LUDecompositionImpl(coefficients).getSolver().solve(constants);
assertEquals(2 * solution[0] + 3 * solution[1] -2 * solution[2], constants[0], 1E-12);
assertEquals(-1 * solution[0] + 7 * solution[1] + 6 * solution[2], constants[1], 1E-12);
- assertEquals(4 * solution[0] - 3 * solution[1] -5 * solution[2], constants[2], 1E-12);
-
+ assertEquals(4 * solution[0] - 3 * solution[1] -5 * solution[2], constants[2], 1E-12);
+
}
-
+
// test submatrix accessors
public void testGetSubMatrix() {
RealMatrix m = new BlockRealMatrix(subTestData);
checkGetSubMatrix(m, subRows23Cols00, 2 , 3 , 0, 0);
checkGetSubMatrix(m, subRows00Cols33, 0 , 0 , 3, 3);
- checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3);
- checkGetSubMatrix(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 });
- checkGetSubMatrix(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 });
- checkGetSubMatrix(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 });
- checkGetSubMatrix(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 });
- checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
- checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
+ checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3);
+ checkGetSubMatrix(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 });
+ checkGetSubMatrix(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 });
+ checkGetSubMatrix(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 });
+ checkGetSubMatrix(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 });
+ checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
+ checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
checkGetSubMatrix(m, null, 1, 0, 2, 4);
checkGetSubMatrix(m, null, -1, 1, 2, 2);
checkGetSubMatrix(m, null, 1, 0, 2, 2);
@@ -508,7 +508,7 @@
}
}
}
-
+
private void checkGetSubMatrix(RealMatrix m, double[][] reference,
int[] selectedRows, int[] selectedColumns) {
try {
@@ -548,14 +548,14 @@
RealMatrix m = new BlockRealMatrix(subTestData);
checkCopy(m, subRows23Cols00, 2 , 3 , 0, 0);
checkCopy(m, subRows00Cols33, 0 , 0 , 3, 3);
- checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3);
- checkCopy(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 });
- checkCopy(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 });
- checkCopy(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 });
- checkCopy(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 });
- checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
- checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
-
+ checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3);
+ checkCopy(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 });
+ checkCopy(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 });
+ checkCopy(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 });
+ checkCopy(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 });
+ checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
+ checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
+
checkCopy(m, null, 1, 0, 2, 4);
checkCopy(m, null, -1, 1, 2, 2);
checkCopy(m, null, 1, 0, 2, 2);
@@ -582,7 +582,7 @@
}
}
}
-
+
private void checkCopy(RealMatrix m, double[][] reference,
int[] selectedRows, int[] selectedColumns) {
try {
@@ -641,7 +641,7 @@
// expected
}
}
-
+
public void testGetSetRowMatrixLarge() {
int n = 3 * BlockRealMatrix.BLOCK_SIZE;
RealMatrix m = new BlockRealMatrix(n, n);
@@ -660,7 +660,7 @@
assertEquals(sub, m.getRowMatrix(2));
}
-
+
public void testGetColumnMatrix() {
RealMatrix m = new BlockRealMatrix(subTestData);
RealMatrix mColumn1 = new BlockRealMatrix(subColumn1);
@@ -719,7 +719,7 @@
assertEquals(sub, m.getColumnMatrix(2));
}
-
+
public void testGetRowVector() {
RealMatrix m = new BlockRealMatrix(subTestData);
RealVector mRow0 = new ArrayRealVector(subRow0[0]);
@@ -778,7 +778,7 @@
assertEquals(sub, m.getRowVector(2));
}
-
+
public void testGetColumnVector() {
RealMatrix m = new BlockRealMatrix(subTestData);
RealVector mColumn1 = columnToVector(subColumn1);
@@ -837,7 +837,7 @@
assertEquals(sub, m.getColumnVector(2));
}
-
+
private RealVector columnToVector(double[][] column) {
double[] data = new double[column.length];
for (int i = 0; i < data.length; ++i) {
@@ -902,7 +902,7 @@
checkArrays(sub, m.getRow(2));
}
-
+
public void testGetColumn() {
RealMatrix m = new BlockRealMatrix(subTestData);
double[] mColumn1 = columnToArray(subColumn1);
@@ -962,7 +962,7 @@
checkArrays(sub, m.getColumn(2));
}
-
+
private double[] columnToArray(double[][] column) {
double[] data = new double[column.length];
for (int i = 0; i < data.length; ++i) {
@@ -974,10 +974,10 @@
private void checkArrays(double[] expected, double[] actual) {
assertEquals(expected.length, actual.length);
for (int i = 0; i < expected.length; ++i) {
- assertEquals(expected[i], actual[i]);
+ assertEquals(expected[i], actual[i]);
}
}
-
+
public void testEqualsAndHashCode() {
BlockRealMatrix m = new BlockRealMatrix(testData);
BlockRealMatrix m1 = (BlockRealMatrix) m.copy();
@@ -988,61 +988,61 @@
assertEquals(m, m1);
assertFalse(m.equals(null));
assertFalse(m.equals(mt));
- assertFalse(m.equals(new BlockRealMatrix(bigSingular)));
+ assertFalse(m.equals(new BlockRealMatrix(bigSingular)));
}
-
+
public void testToString() {
BlockRealMatrix m = new BlockRealMatrix(testData);
assertEquals("BlockRealMatrix{{1.0,2.0,3.0},{2.0,5.0,3.0},{1.0,0.0,8.0}}",
m.toString());
}
-
+
public void testSetSubMatrix() throws Exception {
BlockRealMatrix m = new BlockRealMatrix(testData);
m.setSubMatrix(detData2,1,1);
RealMatrix expected = new BlockRealMatrix
(new double[][] {{1.0,2.0,3.0},{2.0,1.0,3.0},{1.0,2.0,4.0}});
- assertEquals(expected, m);
-
+ assertEquals(expected, m);
+
m.setSubMatrix(detData2,0,0);
expected = new BlockRealMatrix
(new double[][] {{1.0,3.0,3.0},{2.0,4.0,3.0},{1.0,2.0,4.0}});
- assertEquals(expected, m);
-
- m.setSubMatrix(testDataPlus2,0,0);
+ assertEquals(expected, m);
+
+ m.setSubMatrix(testDataPlus2,0,0);
expected = new BlockRealMatrix
(new double[][] {{3.0,4.0,5.0},{4.0,7.0,5.0},{3.0,2.0,10.0}});
- assertEquals(expected, m);
-
+ assertEquals(expected, m);
+
// javadoc example
BlockRealMatrix matrix = new BlockRealMatrix
(new double[][] {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 0, 1 , 2}});
matrix.setSubMatrix(new double[][] {{3, 4}, {5, 6}}, 1, 1);
expected = new BlockRealMatrix
(new double[][] {{1, 2, 3, 4}, {5, 3, 4, 8}, {9, 5 ,6, 2}});
- assertEquals(expected, matrix);
+ assertEquals(expected, matrix);
// dimension overflow
- try {
+ try {
m.setSubMatrix(testData,1,1);
fail("expecting MatrixIndexException");
} catch (MatrixIndexException e) {
// expected
}
// dimension underflow
- try {
+ try {
m.setSubMatrix(testData,-1,1);
fail("expecting MatrixIndexException");
} catch (MatrixIndexException e) {
// expected
}
- try {
+ try {
m.setSubMatrix(testData,1,-1);
fail("expecting MatrixIndexException");
} catch (MatrixIndexException e) {
// expected
}
-
+
// null
try {
m.setSubMatrix(null,1,1);
@@ -1050,7 +1050,7 @@
} catch (NullPointerException e) {
// expected
}
-
+
// ragged
try {
m.setSubMatrix(new double[][] {{1}, {2, 3}}, 0, 0);
@@ -1058,7 +1058,7 @@
} catch (IllegalArgumentException e) {
// expected
}
-
+
// empty
try {
m.setSubMatrix(new double[][] {{}}, 0, 0);
@@ -1066,7 +1066,7 @@
} catch (IllegalArgumentException e) {
// expected
}
-
+
}
public void testWalk() {
@@ -1085,11 +1085,11 @@
m.walkInOptimizedOrder(getVisitor, 1, rows - 2, 1, columns - 2);
assertEquals((rows - 2) * (columns - 2), getVisitor.getCount());
for (int i = 0; i < rows; ++i) {
- assertEquals(0.0, m.getEntry(i, 0), 0);
+ assertEquals(0.0, m.getEntry(i, 0), 0);
assertEquals(0.0, m.getEntry(i, columns - 1), 0);
}
for (int j = 0; j < columns; ++j) {
- assertEquals(0.0, m.getEntry(0, j), 0);
+ assertEquals(0.0, m.getEntry(0, j), 0);
assertEquals(0.0, m.getEntry(rows - 1, j), 0);
}
@@ -1105,11 +1105,11 @@
m.walkInOptimizedOrder(getVisitor, 1, rows - 2, 1, columns - 2);
assertEquals((rows - 2) * (columns - 2), getVisitor.getCount());
for (int i = 0; i < rows; ++i) {
- assertEquals(0.0, m.getEntry(i, 0), 0);
+ assertEquals(0.0, m.getEntry(i, 0), 0);
assertEquals(0.0, m.getEntry(i, columns - 1), 0);
}
for (int j = 0; j < columns; ++j) {
- assertEquals(0.0, m.getEntry(0, j), 0);
+ assertEquals(0.0, m.getEntry(0, j), 0);
assertEquals(0.0, m.getEntry(rows - 1, j), 0);
}
@@ -1125,11 +1125,11 @@
m.walkInRowOrder(getVisitor, 1, rows - 2, 1, columns - 2);
assertEquals((rows - 2) * (columns - 2), getVisitor.getCount());
for (int i = 0; i < rows; ++i) {
- assertEquals(0.0, m.getEntry(i, 0), 0);
+ assertEquals(0.0, m.getEntry(i, 0), 0);
assertEquals(0.0, m.getEntry(i, columns - 1), 0);
}
for (int j = 0; j < columns; ++j) {
- assertEquals(0.0, m.getEntry(0, j), 0);
+ assertEquals(0.0, m.getEntry(0, j), 0);
assertEquals(0.0, m.getEntry(rows - 1, j), 0);
}
@@ -1145,16 +1145,16 @@
m.walkInColumnOrder(getVisitor, 1, rows - 2, 1, columns - 2);
assertEquals((rows - 2) * (columns - 2), getVisitor.getCount());
for (int i = 0; i < rows; ++i) {
- assertEquals(0.0, m.getEntry(i, 0), 0);
+ assertEquals(0.0, m.getEntry(i, 0), 0);
assertEquals(0.0, m.getEntry(i, columns - 1), 0);
}
for (int j = 0; j < columns; ++j) {
- assertEquals(0.0, m.getEntry(0, j), 0);
+ assertEquals(0.0, m.getEntry(0, j), 0);
assertEquals(0.0, m.getEntry(rows - 1, j), 0);
}
}
-
+
public void testSerial() {
BlockRealMatrix m = new BlockRealMatrix(testData);
assertEquals(m,TestUtils.serializeAndRecover(m));
@@ -1180,12 +1180,12 @@
}
//--------------- -----------------Protected methods
-
- /** verifies that two matrices are close (1-norm) */
+
+ /** verifies that two matrices are close (1-norm) */
protected void assertClose(RealMatrix m, RealMatrix n, double tolerance) {
assertTrue(m.subtract(n).getNorm() < tolerance);
}
-
+
/** verifies that two vectors are close (sup norm) */
protected void assertClose(double[] m, double[] n, double tolerance) {
if (m.length != n.length) {
@@ -1205,6 +1205,6 @@
}
return m;
}
-
+
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/CholeskyDecompositionImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/CholeskyDecompositionImplTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/CholeskyDecompositionImplTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/CholeskyDecompositionImplTest.java Sat Sep 5 17:36:48 2009
@@ -84,7 +84,7 @@
{-0.09376327, 0.10400408, 0.07137959, 0.04762857 },
{ 0.30328980, 0.07137959, 0.30458776, 0.04882449 },
{ 0.04909388, 0.04762857, 0.04882449, 0.07543265 }
-
+
}));
}
@@ -144,7 +144,7 @@
// check the same cached instance is returned the second time
assertTrue(l == llt.getL());
assertTrue(lt == llt.getLT());
-
+
}
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenDecompositionImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenDecompositionImplTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenDecompositionImplTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenDecompositionImplTest.java Sat Sep 5 17:36:48 2009
@@ -116,7 +116,7 @@
if (i < 5) {
ref[i] = 2 * r.nextDouble() - 1;
} else {
- ref[i] = 0.0001 * r.nextDouble() + 6;
+ ref[i] = 0.0001 * r.nextDouble() + 6;
}
}
Arrays.sort(ref);
@@ -131,7 +131,7 @@
for (int i = 0; i < ref.length; ++i) {
assertEquals(ref[ref.length - i - 1], eigenValues[i], 2.0e-14);
}
-
+
}
/** test dimensions */
@@ -221,19 +221,19 @@
{3, 2, 4},
{2, 0, 2},
{4, 2, 3}
- });
+ });
EigenDecomposition ed = new EigenDecompositionImpl(repeated, MathUtils.SAFE_MIN);
checkEigenValues((new double[] {8, -1, -1}), ed, 1E-12);
checkEigenVector((new double[] {2, 1, 2}), ed, 1E-12);
}
-
+
/**
* Matrix with eigenvalues {2, 0, 12}
*/
public void testDistinctEigenvalues() {
RealMatrix distinct = MatrixUtils.createRealMatrix(new double[][] {
- {3, 1, -4},
- {1, 3, -4},
+ {3, 1, -4},
+ {1, 3, -4},
{-4, -4, 8}
});
EigenDecomposition ed = new EigenDecompositionImpl(distinct, MathUtils.SAFE_MIN);
@@ -242,7 +242,7 @@
checkEigenVector((new double[] {1, 1, 1}), ed, 1E-12);
checkEigenVector((new double[] {-1, -1, 2}), ed, 1E-12);
}
-
+
/**
* Verifies that the given EigenDecomposition has eigenvalues equivalent to
* the targetValues, ignoring the order of the values and allowing
@@ -256,7 +256,7 @@
assertTrue(isIncludedValue(targetValues[i], observed, tolerance));
}
}
-
+
/**
* Returns true iff there is an entry within tolerance of value in
* searchArray.
@@ -273,7 +273,7 @@
}
return found;
}
-
+
/**
* Returns true iff eigenVector is a scalar multiple of one of the columns
* of ed.getV(). Does not try linear combinations - i.e., should only be
@@ -283,7 +283,7 @@
EigenDecomposition ed, double tolerance) {
assertTrue(isIncludedColumn(eigenVector, ed.getV(), tolerance));
}
-
+
/**
* Returns true iff there is a column that is a scalar multiple of column
* in searchMatrix (modulo tolerance)
@@ -302,7 +302,7 @@
if (Math.abs(multiplier - 1.0) <= Math.ulp(1.0) && Math.abs(colEntry) > 1E-14
&& Math.abs(column[j]) > 1e-14) {
multiplier = colEntry / column[j];
- }
+ }
if (Math.abs(column[j] * multiplier - colEntry) > tolerance) {
matching = false;
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldLUDecompositionImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldLUDecompositionImplTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldLUDecompositionImplTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldLUDecompositionImplTest.java Sat Sep 5 17:36:48 2009
@@ -46,7 +46,7 @@
{ new Fraction(2), new Fraction(3), new Fraction(7) },
{ new Fraction(6), new Fraction(6), new Fraction(8) }
};
-
+
// singular matrices
private Fraction[][] singular = {
{ new Fraction(2), new Fraction(3) },
@@ -265,7 +265,7 @@
assertTrue(l == lu.getL());
assertTrue(u == lu.getU());
assertTrue(p == lu.getP());
-
+
}
/** test matrices values */
@@ -305,7 +305,7 @@
assertTrue(l == lu.getL());
assertTrue(u == lu.getU());
assertTrue(p == lu.getP());
-
+
}
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldMatrixImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldMatrixImplTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldMatrixImplTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldMatrixImplTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,45 +31,45 @@
*/
public final class FieldMatrixImplTest extends TestCase {
-
+
// 3 x 3 identity matrix
protected Fraction[][] id = { {new Fraction(1),new Fraction(0),new Fraction(0)}, {new Fraction(0),new Fraction(1),new Fraction(0)}, {new Fraction(0),new Fraction(0),new Fraction(1)} };
-
+
// Test data for group operations
protected Fraction[][] testData = { {new Fraction(1),new Fraction(2),new Fraction(3)}, {new Fraction(2),new Fraction(5),new Fraction(3)}, {new Fraction(1),new Fraction(0),new Fraction(8)} };
protected Fraction[][] testDataLU = {{new Fraction(2), new Fraction(5), new Fraction(3)}, {new Fraction(1, 2), new Fraction(-5, 2), new Fraction(13, 2)}, {new Fraction(1, 2), new Fraction(1, 5), new Fraction(1, 5)}};
protected Fraction[][] testDataPlus2 = { {new Fraction(3),new Fraction(4),new Fraction(5)}, {new Fraction(4),new Fraction(7),new Fraction(5)}, {new Fraction(3),new Fraction(2),new Fraction(10)} };
- protected Fraction[][] testDataMinus = { {new Fraction(-1),new Fraction(-2),new Fraction(-3)}, {new Fraction(-2),new Fraction(-5),new Fraction(-3)},
+ protected Fraction[][] testDataMinus = { {new Fraction(-1),new Fraction(-2),new Fraction(-3)}, {new Fraction(-2),new Fraction(-5),new Fraction(-3)},
{new Fraction(-1),new Fraction(0),new Fraction(-8)} };
protected Fraction[] testDataRow1 = {new Fraction(1),new Fraction(2),new Fraction(3)};
protected Fraction[] testDataCol3 = {new Fraction(3),new Fraction(3),new Fraction(8)};
- protected Fraction[][] testDataInv =
+ protected Fraction[][] testDataInv =
{ {new Fraction(-40),new Fraction(16),new Fraction(9)}, {new Fraction(13),new Fraction(-5),new Fraction(-3)}, {new Fraction(5),new Fraction(-2),new Fraction(-1)} };
protected Fraction[] preMultTest = {new Fraction(8),new Fraction(12),new Fraction(33)};
protected Fraction[][] testData2 ={ {new Fraction(1),new Fraction(2),new Fraction(3)}, {new Fraction(2),new Fraction(5),new Fraction(3)}};
protected Fraction[][] testData2T = { {new Fraction(1),new Fraction(2)}, {new Fraction(2),new Fraction(5)}, {new Fraction(3),new Fraction(3)}};
- protected Fraction[][] testDataPlusInv =
+ protected Fraction[][] testDataPlusInv =
{ {new Fraction(-39),new Fraction(18),new Fraction(12)}, {new Fraction(15),new Fraction(0),new Fraction(0)}, {new Fraction(6),new Fraction(-2),new Fraction(7)} };
-
+
// lu decomposition tests
protected Fraction[][] luData = { {new Fraction(2),new Fraction(3),new Fraction(3)}, {new Fraction(0),new Fraction(5),new Fraction(7)}, {new Fraction(6),new Fraction(9),new Fraction(8)} };
protected Fraction[][] luDataLUDecomposition = { {new Fraction(6),new Fraction(9),new Fraction(8)}, {new Fraction(0),new Fraction(5),new Fraction(7)},
{new Fraction(1, 3),new Fraction(0),new Fraction(1, 3)} };
-
+
// singular matrices
protected Fraction[][] singular = { {new Fraction(2),new Fraction(3)}, {new Fraction(2),new Fraction(3)} };
protected Fraction[][] bigSingular = {{new Fraction(1),new Fraction(2),new Fraction(3),new Fraction(4)}, {new Fraction(2),new Fraction(5),new Fraction(3),new Fraction(4)},
{new Fraction(7),new Fraction(3),new Fraction(256),new Fraction(1930)}, {new Fraction(3),new Fraction(7),new Fraction(6),new Fraction(8)}}; // 4th row = 1st + 2nd
protected Fraction[][] detData = { {new Fraction(1),new Fraction(2),new Fraction(3)}, {new Fraction(4),new Fraction(5),new Fraction(6)}, {new Fraction(7),new Fraction(8),new Fraction(10)} };
protected Fraction[][] detData2 = { {new Fraction(1), new Fraction(3)}, {new Fraction(2), new Fraction(4)}};
-
+
// vectors
protected Fraction[] testVector = {new Fraction(1),new Fraction(2),new Fraction(3)};
protected Fraction[] testVector2 = {new Fraction(1),new Fraction(2),new Fraction(3),new Fraction(4)};
-
+
// submatrix accessor tests
protected Fraction[][] subTestData = {{new Fraction(1), new Fraction(2), new Fraction(3), new Fraction(4)}, {new Fraction(3, 2), new Fraction(5, 2), new Fraction(7, 2), new Fraction(9, 2)},
- {new Fraction(2), new Fraction(4), new Fraction(6), new Fraction(8)}, {new Fraction(4), new Fraction(5), new Fraction(6), new Fraction(7)}};
+ {new Fraction(2), new Fraction(4), new Fraction(6), new Fraction(8)}, {new Fraction(4), new Fraction(5), new Fraction(6), new Fraction(7)}};
// array selections
protected Fraction[][] subRows02Cols13 = { {new Fraction(2), new Fraction(4)}, {new Fraction(4), new Fraction(8)}};
protected Fraction[][] subRows03Cols12 = { {new Fraction(2), new Fraction(3)}, {new Fraction(5), new Fraction(6)}};
@@ -87,21 +87,21 @@
// column matrices
protected Fraction[][] subColumn1 = {{new Fraction(2)}, {new Fraction(5, 2)}, {new Fraction(4)}, {new Fraction(5)}};
protected Fraction[][] subColumn3 = {{new Fraction(4)}, {new Fraction(9, 2)}, {new Fraction(8)}, {new Fraction(7)}};
-
+
// tolerances
protected double entryTolerance = 10E-16;
protected double normTolerance = 10E-14;
-
+
public FieldMatrixImplTest(String name) {
super(name);
}
-
+
public static Test suite() {
TestSuite suite = new TestSuite(FieldMatrixImplTest.class);
suite.setName("Array2DRowFieldMatrix<Fraction> Tests");
return suite;
}
-
+
/** test dimensions */
public void testDimensions() {
Array2DRowFieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
@@ -112,8 +112,8 @@
assertEquals("testData2 row dimension",m2.getRowDimension(),2);
assertEquals("testData2 column dimension",m2.getColumnDimension(),3);
assertTrue("testData2 is not square",!m2.isSquare());
- }
-
+ }
+
/** test copy functions */
public void testCopyFunctions() {
Array2DRowFieldMatrix<Fraction> m1 = new Array2DRowFieldMatrix<Fraction>(testData);
@@ -122,8 +122,8 @@
Array2DRowFieldMatrix<Fraction> m3 = new Array2DRowFieldMatrix<Fraction>(testData);
Array2DRowFieldMatrix<Fraction> m4 = new Array2DRowFieldMatrix<Fraction>(m3.getData(), false);
assertEquals(m4,m3);
- }
-
+ }
+
/** test add */
public void testAdd() {
Array2DRowFieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
@@ -134,9 +134,9 @@
for (int col = 0; col < m.getColumnDimension(); col++) {
assertEquals(testDataPlusInv[row][col],sumEntries[row][col]);
}
- }
+ }
}
-
+
/** test add failure */
public void testAddFail() {
Array2DRowFieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
@@ -148,20 +148,20 @@
// ignored
}
}
-
+
/** test m-n = m + -n */
public void testPlusMinus() {
Array2DRowFieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
Array2DRowFieldMatrix<Fraction> m2 = new Array2DRowFieldMatrix<Fraction>(testDataInv);
- TestUtils.assertEquals(m.subtract(m2),m2.scalarMultiply(new Fraction(-1)).add(m));
+ TestUtils.assertEquals(m.subtract(m2),m2.scalarMultiply(new Fraction(-1)).add(m));
try {
m.subtract(new Array2DRowFieldMatrix<Fraction>(testData2));
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// ignored
- }
+ }
}
-
+
/** test multiply */
public void testMultiply() {
Array2DRowFieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
@@ -172,28 +172,28 @@
TestUtils.assertEquals(mInv.multiply(m), identity);
TestUtils.assertEquals(m.multiply(identity), m);
TestUtils.assertEquals(identity.multiply(mInv), mInv);
- TestUtils.assertEquals(m2.multiply(identity), m2);
+ TestUtils.assertEquals(m2.multiply(identity), m2);
try {
m.multiply(new Array2DRowFieldMatrix<Fraction>(bigSingular));
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// ignored
- }
- }
-
+ }
+ }
+
//Additional Test for Array2DRowFieldMatrix<Fraction>Test.testMultiply
private Fraction[][] d3 = new Fraction[][] {{new Fraction(1),new Fraction(2),new Fraction(3),new Fraction(4)},{new Fraction(5),new Fraction(6),new Fraction(7),new Fraction(8)}};
private Fraction[][] d4 = new Fraction[][] {{new Fraction(1)},{new Fraction(2)},{new Fraction(3)},{new Fraction(4)}};
private Fraction[][] d5 = new Fraction[][] {{new Fraction(30)},{new Fraction(70)}};
-
- public void testMultiply2() {
- FieldMatrix<Fraction> m3 = new Array2DRowFieldMatrix<Fraction>(d3);
+
+ public void testMultiply2() {
+ FieldMatrix<Fraction> m3 = new Array2DRowFieldMatrix<Fraction>(d3);
FieldMatrix<Fraction> m4 = new Array2DRowFieldMatrix<Fraction>(d4);
FieldMatrix<Fraction> m5 = new Array2DRowFieldMatrix<Fraction>(d5);
TestUtils.assertEquals(m3.multiply(m4), m5);
- }
-
+ }
+
/** test trace */
public void testTrace() {
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(id);
@@ -204,15 +204,15 @@
fail("Expecting NonSquareMatrixException");
} catch (NonSquareMatrixException ex) {
// ignored
- }
+ }
}
-
+
/** test sclarAdd */
public void testScalarAdd() {
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
TestUtils.assertEquals(new Array2DRowFieldMatrix<Fraction>(testDataPlus2), m.scalarAdd(new Fraction(2)));
}
-
+
/** test operate */
public void testOperate() {
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(id);
@@ -224,7 +224,7 @@
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// ignored
- }
+ }
}
/** test issue MATH-209 */
@@ -238,10 +238,10 @@
assertEquals( new Fraction(7), b[1]);
assertEquals(new Fraction(11), b[2]);
}
-
+
/** test transpose */
public void testTranspose() {
- FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
+ FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
FieldMatrix<Fraction> mIT = new FieldLUDecompositionImpl<Fraction>(m).getSolver().getInverse().transpose();
FieldMatrix<Fraction> mTI = new FieldLUDecompositionImpl<Fraction>(m.transpose()).getSolver().getInverse();
TestUtils.assertEquals(mIT, mTI);
@@ -249,7 +249,7 @@
FieldMatrix<Fraction> mt = new Array2DRowFieldMatrix<Fraction>(testData2T);
TestUtils.assertEquals(mt, m.transpose());
}
-
+
/** test preMultiply by vector */
public void testPremultiplyVector() {
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
@@ -264,13 +264,13 @@
// ignored
}
}
-
+
public void testPremultiply() {
- FieldMatrix<Fraction> m3 = new Array2DRowFieldMatrix<Fraction>(d3);
+ FieldMatrix<Fraction> m3 = new Array2DRowFieldMatrix<Fraction>(d3);
FieldMatrix<Fraction> m4 = new Array2DRowFieldMatrix<Fraction>(d4);
FieldMatrix<Fraction> m5 = new Array2DRowFieldMatrix<Fraction>(d5);
TestUtils.assertEquals(m4.preMultiply(m3), m5);
-
+
Array2DRowFieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
Array2DRowFieldMatrix<Fraction> mInv = new Array2DRowFieldMatrix<Fraction>(testDataInv);
Array2DRowFieldMatrix<Fraction> identity = new Array2DRowFieldMatrix<Fraction>(id);
@@ -283,9 +283,9 @@
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// ignored
- }
+ }
}
-
+
public void testGetVectors() {
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
TestUtils.assertEquals(m.getRow(0), testDataRow1);
@@ -303,7 +303,7 @@
// ignored
}
}
-
+
public void testGetEntry() {
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
assertEquals("get entry",m.getEntry(0,1),new Fraction(2));
@@ -314,7 +314,7 @@
// expected
}
}
-
+
/** test examples in user guide */
public void testExamples() {
// Create a real matrix with two rows and three columns
@@ -335,10 +335,10 @@
assertEquals(2, p.getRowDimension());
assertEquals(2, p.getColumnDimension());
// Invert p
- FieldMatrix<Fraction> pInverse = new FieldLUDecompositionImpl<Fraction>(p).getSolver().getInverse();
+ FieldMatrix<Fraction> pInverse = new FieldLUDecompositionImpl<Fraction>(p).getSolver().getInverse();
assertEquals(2, pInverse.getRowDimension());
assertEquals(2, pInverse.getColumnDimension());
-
+
// Solve example
Fraction[][] coefficientsData = {
{new Fraction(2), new Fraction(3), new Fraction(-2)},
@@ -356,22 +356,22 @@
add(new Fraction(6).multiply(solution[2])), constants[1]);
assertEquals(new Fraction(4).multiply(solution[0]).
subtract(new Fraction(3).multiply(solution[1])).
- subtract(new Fraction(5).multiply(solution[2])), constants[2]);
-
+ subtract(new Fraction(5).multiply(solution[2])), constants[2]);
+
}
-
+
// test submatrix accessors
public void testGetSubMatrix() {
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(subTestData);
checkGetSubMatrix(m, subRows23Cols00, 2 , 3 , 0, 0);
checkGetSubMatrix(m, subRows00Cols33, 0 , 0 , 3, 3);
- checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3);
- checkGetSubMatrix(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 });
- checkGetSubMatrix(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 });
- checkGetSubMatrix(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 });
- checkGetSubMatrix(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 });
- checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
- checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
+ checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3);
+ checkGetSubMatrix(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 });
+ checkGetSubMatrix(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 });
+ checkGetSubMatrix(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 });
+ checkGetSubMatrix(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 });
+ checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
+ checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
checkGetSubMatrix(m, null, 1, 0, 2, 4);
checkGetSubMatrix(m, null, -1, 1, 2, 2);
checkGetSubMatrix(m, null, 1, 0, 2, 2);
@@ -395,7 +395,7 @@
}
}
}
-
+
private void checkGetSubMatrix(FieldMatrix<Fraction> m, Fraction[][] reference,
int[] selectedRows, int[] selectedColumns) {
try {
@@ -416,14 +416,14 @@
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(subTestData);
checkCopy(m, subRows23Cols00, 2 , 3 , 0, 0);
checkCopy(m, subRows00Cols33, 0 , 0 , 3, 3);
- checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3);
- checkCopy(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 });
- checkCopy(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 });
- checkCopy(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 });
- checkCopy(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 });
- checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
- checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
-
+ checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3);
+ checkCopy(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 });
+ checkCopy(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 });
+ checkCopy(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 });
+ checkCopy(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 });
+ checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
+ checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 });
+
checkCopy(m, null, 1, 0, 2, 4);
checkCopy(m, null, -1, 1, 2, 2);
checkCopy(m, null, 1, 0, 2, 2);
@@ -450,7 +450,7 @@
}
}
}
-
+
private void checkCopy(FieldMatrix<Fraction> m, Fraction[][] reference,
int[] selectedRows, int[] selectedColumns) {
try {
@@ -474,9 +474,9 @@
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(subTestData);
FieldMatrix<Fraction> mRow0 = new Array2DRowFieldMatrix<Fraction>(subRow0);
FieldMatrix<Fraction> mRow3 = new Array2DRowFieldMatrix<Fraction>(subRow3);
- assertEquals("Row0", mRow0,
+ assertEquals("Row0", mRow0,
m.getRowMatrix(0));
- assertEquals("Row3", mRow3,
+ assertEquals("Row3", mRow3,
m.getRowMatrix(3));
try {
m.getRowMatrix(-1);
@@ -491,7 +491,7 @@
// expected
}
}
-
+
public void testSetRowMatrix() {
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(subTestData);
FieldMatrix<Fraction> mRow3 = new Array2DRowFieldMatrix<Fraction>(subRow3);
@@ -511,14 +511,14 @@
// expected
}
}
-
+
public void testGetColumnMatrix() {
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(subTestData);
FieldMatrix<Fraction> mColumn1 = new Array2DRowFieldMatrix<Fraction>(subColumn1);
FieldMatrix<Fraction> mColumn3 = new Array2DRowFieldMatrix<Fraction>(subColumn3);
- assertEquals("Column1", mColumn1,
+ assertEquals("Column1", mColumn1,
m.getColumnMatrix(1));
- assertEquals("Column3", mColumn3,
+ assertEquals("Column3", mColumn3,
m.getColumnMatrix(3));
try {
m.getColumnMatrix(-1);
@@ -593,7 +593,7 @@
// expected
}
}
-
+
public void testGetColumnVector() {
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(subTestData);
FieldVector<Fraction> mColumn1 = columnToVector(subColumn1);
@@ -678,7 +678,7 @@
// expected
}
}
-
+
public void testGetColumn() {
FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(subTestData);
Fraction[] mColumn1 = columnToArray(subColumn1);
@@ -730,10 +730,10 @@
private void checkArrays(Fraction[] expected, Fraction[] actual) {
assertEquals(expected.length, actual.length);
for (int i = 0; i < expected.length; ++i) {
- assertEquals(expected[i], actual[i]);
+ assertEquals(expected[i], actual[i]);
}
}
-
+
public void testEqualsAndHashCode() {
Array2DRowFieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
Array2DRowFieldMatrix<Fraction> m1 = (Array2DRowFieldMatrix<Fraction>) m.copy();
@@ -744,16 +744,16 @@
assertEquals(m, m1);
assertFalse(m.equals(null));
assertFalse(m.equals(mt));
- assertFalse(m.equals(new Array2DRowFieldMatrix<Fraction>(bigSingular)));
+ assertFalse(m.equals(new Array2DRowFieldMatrix<Fraction>(bigSingular)));
}
-
+
public void testToString() {
Array2DRowFieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
assertEquals("Array2DRowFieldMatrix{{1,2,3},{2,5,3},{1,0,8}}", m.toString());
m = new Array2DRowFieldMatrix<Fraction>(FractionField.getInstance());
assertEquals("Array2DRowFieldMatrix{}", m.toString());
}
-
+
public void testSetSubMatrix() throws Exception {
Array2DRowFieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
m.setSubMatrix(detData2,1,1);
@@ -763,8 +763,8 @@
{new Fraction(2),new Fraction(1),new Fraction(3)},
{new Fraction(1),new Fraction(2),new Fraction(4)}
});
- assertEquals(expected, m);
-
+ assertEquals(expected, m);
+
m.setSubMatrix(detData2,0,0);
expected = new Array2DRowFieldMatrix<Fraction>
(new Fraction[][] {
@@ -772,38 +772,38 @@
{new Fraction(2),new Fraction(4),new Fraction(3)},
{new Fraction(1),new Fraction(2),new Fraction(4)}
});
- assertEquals(expected, m);
-
- m.setSubMatrix(testDataPlus2,0,0);
+ assertEquals(expected, m);
+
+ m.setSubMatrix(testDataPlus2,0,0);
expected = new Array2DRowFieldMatrix<Fraction>
(new Fraction[][] {
{new Fraction(3),new Fraction(4),new Fraction(5)},
{new Fraction(4),new Fraction(7),new Fraction(5)},
{new Fraction(3),new Fraction(2),new Fraction(10)}
});
- assertEquals(expected, m);
-
+ assertEquals(expected, m);
+
// dimension overflow
- try {
+ try {
m.setSubMatrix(testData,1,1);
fail("expecting MatrixIndexException");
} catch (MatrixIndexException e) {
// expected
}
// dimension underflow
- try {
+ try {
m.setSubMatrix(testData,-1,1);
fail("expecting MatrixIndexException");
} catch (MatrixIndexException e) {
// expected
}
- try {
+ try {
m.setSubMatrix(testData,1,-1);
fail("expecting MatrixIndexException");
} catch (MatrixIndexException e) {
// expected
}
-
+
// null
try {
m.setSubMatrix(null,1,1);
@@ -824,7 +824,7 @@
} catch (IllegalStateException e) {
// expected
}
-
+
// ragged
try {
m.setSubMatrix(new Fraction[][] {{new Fraction(1)}, {new Fraction(2), new Fraction(3)}}, 0, 0);
@@ -832,7 +832,7 @@
} catch (IllegalArgumentException e) {
// expected
}
-
+
// empty
try {
m.setSubMatrix(new Fraction[][] {{}}, 0, 0);
@@ -840,7 +840,7 @@
} catch (IllegalArgumentException e) {
// expected
}
-
+
}
public void testWalk() {
@@ -860,11 +860,11 @@
m.walkInOptimizedOrder(getVisitor, 1, rows - 2, 1, columns - 2);
assertEquals((rows - 2) * (columns - 2), getVisitor.getCount());
for (int i = 0; i < rows; ++i) {
- assertEquals(new Fraction(0), m.getEntry(i, 0));
+ assertEquals(new Fraction(0), m.getEntry(i, 0));
assertEquals(new Fraction(0), m.getEntry(i, columns - 1));
}
for (int j = 0; j < columns; ++j) {
- assertEquals(new Fraction(0), m.getEntry(0, j));
+ assertEquals(new Fraction(0), m.getEntry(0, j));
assertEquals(new Fraction(0), m.getEntry(rows - 1, j));
}
@@ -880,11 +880,11 @@
m.walkInOptimizedOrder(getVisitor, 1, rows - 2, 1, columns - 2);
assertEquals((rows - 2) * (columns - 2), getVisitor.getCount());
for (int i = 0; i < rows; ++i) {
- assertEquals(new Fraction(0), m.getEntry(i, 0));
+ assertEquals(new Fraction(0), m.getEntry(i, 0));
assertEquals(new Fraction(0), m.getEntry(i, columns - 1));
}
for (int j = 0; j < columns; ++j) {
- assertEquals(new Fraction(0), m.getEntry(0, j));
+ assertEquals(new Fraction(0), m.getEntry(0, j));
assertEquals(new Fraction(0), m.getEntry(rows - 1, j));
}
@@ -900,11 +900,11 @@
m.walkInRowOrder(getVisitor, 1, rows - 2, 1, columns - 2);
assertEquals((rows - 2) * (columns - 2), getVisitor.getCount());
for (int i = 0; i < rows; ++i) {
- assertEquals(new Fraction(0), m.getEntry(i, 0));
+ assertEquals(new Fraction(0), m.getEntry(i, 0));
assertEquals(new Fraction(0), m.getEntry(i, columns - 1));
}
for (int j = 0; j < columns; ++j) {
- assertEquals(new Fraction(0), m.getEntry(0, j));
+ assertEquals(new Fraction(0), m.getEntry(0, j));
assertEquals(new Fraction(0), m.getEntry(rows - 1, j));
}
@@ -920,11 +920,11 @@
m.walkInColumnOrder(getVisitor, 1, rows - 2, 1, columns - 2);
assertEquals((rows - 2) * (columns - 2), getVisitor.getCount());
for (int i = 0; i < rows; ++i) {
- assertEquals(new Fraction(0), m.getEntry(i, 0));
+ assertEquals(new Fraction(0), m.getEntry(i, 0));
assertEquals(new Fraction(0), m.getEntry(i, columns - 1));
}
for (int j = 0; j < columns; ++j) {
- assertEquals(new Fraction(0), m.getEntry(0, j));
+ assertEquals(new Fraction(0), m.getEntry(0, j));
assertEquals(new Fraction(0), m.getEntry(rows - 1, j));
}
@@ -934,7 +934,7 @@
Array2DRowFieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
assertEquals(m,TestUtils.serializeAndRecover(m));
}
-
+
private static class SetVisitor extends DefaultFieldMatrixChangingVisitor<Fraction> {
public SetVisitor() {
super(Fraction.ZERO);
@@ -962,19 +962,19 @@
}
//--------------- -----------------Protected methods
-
+
/** extracts the l and u matrices from compact lu representation */
protected void splitLU(FieldMatrix<Fraction> lu,
Fraction[][] lowerData,
Fraction[][] upperData)
- throws InvalidMatrixException {
+ throws InvalidMatrixException {
if (!lu.isSquare() ||
lowerData.length != lowerData[0].length ||
upperData.length != upperData[0].length ||
lowerData.length != upperData.length ||
lowerData.length != lu.getRowDimension()) {
throw new InvalidMatrixException("incorrect dimensions");
- }
+ }
int n = lu.getRowDimension();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
@@ -987,11 +987,11 @@
} else {
lowerData[i][j] = Fraction.ZERO;
upperData[i][j] = lu.getEntry(i, j);
- }
+ }
}
}
}
-
+
/** Returns the result of applying the given row permutation to the matrix */
protected FieldMatrix<Fraction> permuteRows(FieldMatrix<Fraction> matrix, int[] permutation) {
if (!matrix.isSquare() || matrix.getRowDimension() != permutation.length) {
@@ -1007,6 +1007,6 @@
}
return new Array2DRowFieldMatrix<Fraction>(out);
}
-
+
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FrenchRealVectorFormatTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FrenchRealVectorFormatTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FrenchRealVectorFormatTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FrenchRealVectorFormatTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/InvalidMatrixExceptionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/InvalidMatrixExceptionTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/InvalidMatrixExceptionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/InvalidMatrixExceptionTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,7 @@
* @version $Revision$ $Date$
*/
public class InvalidMatrixExceptionTest extends TestCase {
-
+
public void testConstructorMessage(){
String msg = "message";
InvalidMatrixException ex = new InvalidMatrixException(msg);
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/LUDecompositionImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/LUDecompositionImplTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/LUDecompositionImplTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/LUDecompositionImplTest.java Sat Sep 5 17:36:48 2009
@@ -43,7 +43,7 @@
{ 0.0, 5.0, 7.0 },
{ 6.0, 9.0, 8.0 }
};
-
+
// singular matrices
private double[][] singular = {
{ 2.0, 3.0 },
@@ -257,7 +257,7 @@
assertTrue(l == lu.getL());
assertTrue(u == lu.getU());
assertTrue(p == lu.getP());
-
+
}
/** test matrices values */
@@ -297,7 +297,7 @@
assertTrue(l == lu.getL());
assertTrue(u == lu.getU());
assertTrue(p == lu.getP());
-
+
}
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/LUSolverTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/LUSolverTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/LUSolverTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/LUSolverTest.java Sat Sep 5 17:36:48 2009
@@ -39,7 +39,7 @@
{ 0.0, 5.0, 7.0 },
{ 6.0, 9.0, 8.0 }
};
-
+
// singular matrices
private double[][] singular = {
{ 2.0, 3.0 },
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixIndexExceptionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixIndexExceptionTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixIndexExceptionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixIndexExceptionTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,9 +23,9 @@
* @version $Revision$ $Date$
*/
public class MatrixIndexExceptionTest extends TestCase {
-
+
/**
- *
+ *
*/
public void testConstructorMessage(){
String msg = "message";
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixUtilsTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixUtilsTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixUtilsTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -33,55 +33,55 @@
*/
public final class MatrixUtilsTest extends TestCase {
-
+
protected double[][] testData = { {1d,2d,3d}, {2d,5d,3d}, {1d,0d,8d} };
protected double[][] nullMatrix = null;
protected double[] row = {1,2,3};
- protected BigDecimal[] bigRow =
+ protected BigDecimal[] bigRow =
{new BigDecimal(1),new BigDecimal(2),new BigDecimal(3)};
protected String[] stringRow = {"1", "2", "3"};
- protected Fraction[] fractionRow =
+ protected Fraction[] fractionRow =
{new Fraction(1),new Fraction(2),new Fraction(3)};
protected double[][] rowMatrix = {{1,2,3}};
- protected BigDecimal[][] bigRowMatrix =
+ protected BigDecimal[][] bigRowMatrix =
{{new BigDecimal(1), new BigDecimal(2), new BigDecimal(3)}};
protected String[][] stringRowMatrix = {{"1", "2", "3"}};
- protected Fraction[][] fractionRowMatrix =
+ protected Fraction[][] fractionRowMatrix =
{{new Fraction(1), new Fraction(2), new Fraction(3)}};
protected double[] col = {0,4,6};
- protected BigDecimal[] bigCol =
+ protected BigDecimal[] bigCol =
{new BigDecimal(0),new BigDecimal(4),new BigDecimal(6)};
protected String[] stringCol = {"0","4","6"};
- protected Fraction[] fractionCol =
+ protected Fraction[] fractionCol =
{new Fraction(0),new Fraction(4),new Fraction(6)};
protected double[] nullDoubleArray = null;
protected double[][] colMatrix = {{0},{4},{6}};
- protected BigDecimal[][] bigColMatrix =
+ protected BigDecimal[][] bigColMatrix =
{{new BigDecimal(0)},{new BigDecimal(4)},{new BigDecimal(6)}};
protected String[][] stringColMatrix = {{"0"}, {"4"}, {"6"}};
- protected Fraction[][] fractionColMatrix =
+ protected Fraction[][] fractionColMatrix =
{{new Fraction(0)},{new Fraction(4)},{new Fraction(6)}};
-
+
public MatrixUtilsTest(String name) {
super(name);
}
-
+
public static Test suite() {
TestSuite suite = new TestSuite(MatrixUtilsTest.class);
suite.setName("MatrixUtils Tests");
return suite;
}
-
+
public void testCreateRealMatrix() {
- assertEquals(new BlockRealMatrix(testData),
+ assertEquals(new BlockRealMatrix(testData),
MatrixUtils.createRealMatrix(testData));
try {
MatrixUtils.createRealMatrix(new double[][] {{1}, {1,2}}); // ragged
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
// expected
- }
+ }
try {
MatrixUtils.createRealMatrix(new double[][] {{}, {}}); // no columns
fail("Expecting IllegalArgumentException");
@@ -93,20 +93,20 @@
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
// expected
- }
+ }
}
public void testcreateFieldMatrix() {
- assertEquals(new Array2DRowFieldMatrix<Fraction>(asFraction(testData)),
+ assertEquals(new Array2DRowFieldMatrix<Fraction>(asFraction(testData)),
MatrixUtils.createFieldMatrix(asFraction(testData)));
- assertEquals(new Array2DRowFieldMatrix<Fraction>(fractionColMatrix),
+ assertEquals(new Array2DRowFieldMatrix<Fraction>(fractionColMatrix),
MatrixUtils.createFieldMatrix(fractionColMatrix));
try {
MatrixUtils.createFieldMatrix(asFraction(new double[][] {{1}, {1,2}})); // ragged
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
// expected
- }
+ }
try {
MatrixUtils.createFieldMatrix(asFraction(new double[][] {{}, {}})); // no columns
fail("Expecting IllegalArgumentException");
@@ -118,27 +118,27 @@
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
// expected
- }
+ }
}
@Deprecated
public void testCreateBigMatrix() {
- assertEquals(new BigMatrixImpl(testData),
+ assertEquals(new BigMatrixImpl(testData),
MatrixUtils.createBigMatrix(testData));
- assertEquals(new BigMatrixImpl(BigMatrixImplTest.asBigDecimal(testData), true),
+ assertEquals(new BigMatrixImpl(BigMatrixImplTest.asBigDecimal(testData), true),
MatrixUtils.createBigMatrix(BigMatrixImplTest.asBigDecimal(testData), false));
- assertEquals(new BigMatrixImpl(BigMatrixImplTest.asBigDecimal(testData), false),
+ assertEquals(new BigMatrixImpl(BigMatrixImplTest.asBigDecimal(testData), false),
MatrixUtils.createBigMatrix(BigMatrixImplTest.asBigDecimal(testData), true));
- assertEquals(new BigMatrixImpl(bigColMatrix),
+ assertEquals(new BigMatrixImpl(bigColMatrix),
MatrixUtils.createBigMatrix(bigColMatrix));
- assertEquals(new BigMatrixImpl(stringColMatrix),
+ assertEquals(new BigMatrixImpl(stringColMatrix),
MatrixUtils.createBigMatrix(stringColMatrix));
try {
MatrixUtils.createBigMatrix(new double[][] {{1}, {1,2}}); // ragged
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
// expected
- }
+ }
try {
MatrixUtils.createBigMatrix(new double[][] {{}, {}}); // no columns
fail("Expecting IllegalArgumentException");
@@ -150,9 +150,9 @@
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
// expected
- }
+ }
}
-
+
public void testCreateRowRealMatrix() {
assertEquals(MatrixUtils.createRowRealMatrix(row),
new BlockRealMatrix(rowMatrix));
@@ -167,9 +167,9 @@
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
// expected
- }
+ }
}
-
+
public void testCreateRowFieldMatrix() {
assertEquals(MatrixUtils.createRowFieldMatrix(asFraction(row)),
new Array2DRowFieldMatrix<Fraction>(asFraction(rowMatrix)));
@@ -186,7 +186,7 @@
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
// expected
- }
+ }
}
@Deprecated
@@ -208,7 +208,7 @@
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
// expected
- }
+ }
}
public void testCreateColumnRealMatrix() {
@@ -225,9 +225,9 @@
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
// expected
- }
+ }
}
-
+
public void testCreateColumnFieldMatrix() {
assertEquals(MatrixUtils.createColumnFieldMatrix(asFraction(col)),
new Array2DRowFieldMatrix<Fraction>(asFraction(colMatrix)));
@@ -245,7 +245,7 @@
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
// expected
- }
+ }
}
@Deprecated
@@ -255,8 +255,8 @@
assertEquals(MatrixUtils.createColumnBigMatrix(bigCol),
new BigMatrixImpl(bigColMatrix));
assertEquals(MatrixUtils.createColumnBigMatrix(stringCol),
- new BigMatrixImpl(stringColMatrix));
-
+ new BigMatrixImpl(stringColMatrix));
+
try {
MatrixUtils.createColumnBigMatrix(new double[] {}); // empty
fail("Expecting IllegalArgumentException");
@@ -268,7 +268,7 @@
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
// expected
- }
+ }
}
/**
@@ -283,9 +283,9 @@
assertEquals(m.getEntry(i, j), 0d, 0);
}
}
- }
+ }
}
-
+
public void testCreateIdentityMatrix() {
checkIdentityMatrix(MatrixUtils.createRealIdentityMatrix(3));
checkIdentityMatrix(MatrixUtils.createRealIdentityMatrix(2));
@@ -296,7 +296,7 @@
// expected
}
}
-
+
/**
* Verifies that the matrix is an identity matrix
*/
@@ -309,9 +309,9 @@
assertEquals(m.getEntry(i, j), Fraction.ZERO);
}
}
- }
+ }
}
-
+
public void testcreateFieldIdentityMatrix() {
checkIdentityFieldMatrix(MatrixUtils.createFieldIdentityMatrix(FractionField.getInstance(), 3));
checkIdentityFieldMatrix(MatrixUtils.createFieldIdentityMatrix(FractionField.getInstance(), 2));
@@ -389,7 +389,7 @@
assertEquals(m.getEntry(i, j), BigMatrixImpl.ZERO);
}
}
- }
+ }
}
@Deprecated
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRDecompositionImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRDecompositionImplTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRDecompositionImplTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRDecompositionImplTest.java Sat Sep 5 17:36:48 2009
@@ -33,25 +33,25 @@
import junit.framework.TestSuite;
public class QRDecompositionImplTest extends TestCase {
- double[][] testData3x3NonSingular = {
- { 12, -51, 4 },
+ double[][] testData3x3NonSingular = {
+ { 12, -51, 4 },
{ 6, 167, -68 },
{ -4, 24, -41 }, };
- double[][] testData3x3Singular = {
- { 1, 4, 7, },
+ double[][] testData3x3Singular = {
+ { 1, 4, 7, },
{ 2, 5, 8, },
{ 3, 6, 9, }, };
- double[][] testData3x4 = {
- { 12, -51, 4, 1 },
+ double[][] testData3x4 = {
+ { 12, -51, 4, 1 },
{ 6, 167, -68, 2 },
{ -4, 24, -41, 3 }, };
- double[][] testData4x3 = {
- { 12, -51, 4, },
+ double[][] testData4x3 = {
+ { 12, -51, 4, },
{ 6, 167, -68, },
- { -4, 24, -41, },
+ { -4, 24, -41, },
{ -5, 34, 7, }, };
private static final double entryTolerance = 10e-16;
@@ -91,7 +91,7 @@
assertEquals(rows, qr.getQ().getRowDimension());
assertEquals(rows, qr.getQ().getColumnDimension());
assertEquals(rows, qr.getR().getRowDimension());
- assertEquals(columns, qr.getR().getColumnDimension());
+ assertEquals(columns, qr.getR().getColumnDimension());
}
/** test A = QR */
@@ -250,7 +250,7 @@
assertTrue(q == qr.getQ());
assertTrue(r == qr.getR());
assertTrue(h == qr.getH());
-
+
}
private RealMatrix createTestMatrix(final Random r, final int rows, final int columns) {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRSolverTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRSolverTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRSolverTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRSolverTest.java Sat Sep 5 17:36:48 2009
@@ -36,28 +36,28 @@
import org.apache.commons.math.linear.ArrayRealVector;
public class QRSolverTest extends TestCase {
- double[][] testData3x3NonSingular = {
- { 12, -51, 4 },
+ double[][] testData3x3NonSingular = {
+ { 12, -51, 4 },
{ 6, 167, -68 },
{ -4, 24, -41 }
};
- double[][] testData3x3Singular = {
- { 1, 2, 2 },
+ double[][] testData3x3Singular = {
+ { 1, 2, 2 },
{ 2, 4, 6 },
{ 4, 8, 12 }
};
- double[][] testData3x4 = {
- { 12, -51, 4, 1 },
+ double[][] testData3x4 = {
+ { 12, -51, 4, 1 },
{ 6, 167, -68, 2 },
{ -4, 24, -41, 3 }
};
- double[][] testData4x3 = {
- { 12, -51, 4 },
+ double[][] testData4x3 = {
+ { 12, -51, 4 },
{ 6, 167, -68 },
- { -4, 24, -41 },
+ { -4, 24, -41 },
{ -5, 34, 7 }
};