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 [20/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/RealMatrixImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/RealMatrixImplTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/RealMatrixImplTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/RealMatrixImplTest.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.
@@ -29,45 +29,45 @@
*/
@Deprecated
public final class RealMatrixImplTest 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}};
@@ -85,21 +85,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 RealMatrixImplTest(String name) {
super(name);
}
-
+
public static Test suite() {
TestSuite suite = new TestSuite(RealMatrixImplTest.class);
suite.setName("RealMatrixImpl Tests");
return suite;
}
-
+
/** test dimensions */
public void testDimensions() {
RealMatrixImpl m = new RealMatrixImpl(testData);
@@ -110,8 +110,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() {
RealMatrixImpl m1 = new RealMatrixImpl(testData);
@@ -120,8 +120,8 @@
RealMatrixImpl m3 = new RealMatrixImpl(testData);
RealMatrixImpl m4 = new RealMatrixImpl(m3.getData(), false);
assertEquals(m4,m3);
- }
-
+ }
+
/** test add */
public void testAdd() {
RealMatrixImpl m = new RealMatrixImpl(testData);
@@ -134,9 +134,9 @@
testDataPlusInv[row][col],sumEntries[row][col],
entryTolerance);
}
- }
+ }
}
-
+
/** test add failure */
public void testAddFail() {
RealMatrixImpl m = new RealMatrixImpl(testData);
@@ -148,7 +148,7 @@
// ignored
}
}
-
+
/** test norm */
public void testNorm() {
RealMatrixImpl m = new RealMatrixImpl(testData);
@@ -156,7 +156,7 @@
assertEquals("testData norm",14d,m.getNorm(),entryTolerance);
assertEquals("testData2 norm",7d,m2.getNorm(),entryTolerance);
}
-
+
/** test Frobenius norm */
public void testFrobeniusNorm() {
RealMatrixImpl m = new RealMatrixImpl(testData);
@@ -164,21 +164,21 @@
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() {
RealMatrixImpl m = new RealMatrixImpl(testData);
RealMatrixImpl m2 = new RealMatrixImpl(testDataInv);
TestUtils.assertEquals("m-n = m + -n",m.subtract(m2),
- m2.scalarMultiply(-1d).add(m),entryTolerance);
+ m2.scalarMultiply(-1d).add(m),entryTolerance);
try {
m.subtract(new RealMatrixImpl(testData2));
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// ignored
- }
+ }
}
-
+
/** test multiply */
public void testMultiply() {
RealMatrixImpl m = new RealMatrixImpl(testData);
@@ -194,28 +194,28 @@
TestUtils.assertEquals("identity multiply",identity.multiply(mInv),
mInv,entryTolerance);
TestUtils.assertEquals("identity multiply",m2.multiply(identity),
- m2,entryTolerance);
+ m2,entryTolerance);
try {
m.multiply(new RealMatrixImpl(bigSingular));
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// ignored
- }
- }
-
+ }
+ }
+
//Additional Test for RealMatrixImplTest.testMultiply
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 RealMatrixImpl(d3);
+
+ public void testMultiply2() {
+ RealMatrix m3 = new RealMatrixImpl(d3);
RealMatrix m4 = new RealMatrixImpl(d4);
RealMatrix m5 = new RealMatrixImpl(d5);
TestUtils.assertEquals("m3*m4=m5", m3.multiply(m4), m5, entryTolerance);
- }
-
+ }
+
/** test trace */
public void testTrace() {
RealMatrix m = new RealMatrixImpl(id);
@@ -226,16 +226,16 @@
fail("Expecting NonSquareMatrixException");
} catch (NonSquareMatrixException ex) {
// ignored
- }
+ }
}
-
+
/** test sclarAdd */
public void testScalarAdd() {
RealMatrix m = new RealMatrixImpl(testData);
TestUtils.assertEquals("scalar add",new RealMatrixImpl(testDataPlus2),
m.scalarAdd(2d),entryTolerance);
}
-
+
/** test operate */
public void testOperate() {
RealMatrix m = new RealMatrixImpl(id);
@@ -249,7 +249,7 @@
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// ignored
- }
+ }
}
/** test issue MATH-209 */
@@ -263,10 +263,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 RealMatrixImpl(testData);
+ RealMatrix m = new RealMatrixImpl(testData);
RealMatrix mIT = new LUDecompositionImpl(m).getSolver().getInverse().transpose();
RealMatrix mTI = new LUDecompositionImpl(m.transpose()).getSolver().getInverse();
TestUtils.assertEquals("inverse-transpose", mIT, mTI, normTolerance);
@@ -274,7 +274,7 @@
RealMatrix mt = new RealMatrixImpl(testData2T);
TestUtils.assertEquals("transpose",mt,m.transpose(),normTolerance);
}
-
+
/** test preMultiply by vector */
public void testPremultiplyVector() {
RealMatrix m = new RealMatrixImpl(testData);
@@ -290,13 +290,13 @@
// ignored
}
}
-
+
public void testPremultiply() {
- RealMatrix m3 = new RealMatrixImpl(d3);
+ RealMatrix m3 = new RealMatrixImpl(d3);
RealMatrix m4 = new RealMatrixImpl(d4);
RealMatrix m5 = new RealMatrixImpl(d5);
TestUtils.assertEquals("m3*m4=m5", m4.preMultiply(m3), m5, entryTolerance);
-
+
RealMatrixImpl m = new RealMatrixImpl(testData);
RealMatrixImpl mInv = new RealMatrixImpl(testDataInv);
RealMatrixImpl identity = new RealMatrixImpl(id);
@@ -313,9 +313,9 @@
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// ignored
- }
+ }
}
-
+
public void testGetVectors() {
RealMatrix m = new RealMatrixImpl(testData);
TestUtils.assertEquals("get row",m.getRow(0),testDataRow1,entryTolerance);
@@ -333,7 +333,7 @@
// ignored
}
}
-
+
public void testGetEntry() {
RealMatrix m = new RealMatrixImpl(testData);
assertEquals("get entry",m.getEntry(0,1),2d,entryTolerance);
@@ -344,7 +344,7 @@
// expected
}
}
-
+
/** test examples in user guide */
public void testExamples() {
// Create a real matrix with two rows and three columns
@@ -358,10 +358,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 RealMatrixImpl(coefficientsData);
@@ -369,22 +369,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 RealMatrixImpl(subTestData);
checkGetSubMatrix(m, subRows23Cols00, 2 , 3 , 0, 0, false);
checkGetSubMatrix(m, subRows00Cols33, 0 , 0 , 3, 3, false);
- checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3, false);
- checkGetSubMatrix(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 }, false);
- checkGetSubMatrix(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 }, false);
- checkGetSubMatrix(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 }, false);
- checkGetSubMatrix(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 }, false);
- checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
- checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
+ checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3, false);
+ checkGetSubMatrix(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 }, false);
+ checkGetSubMatrix(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 }, false);
+ checkGetSubMatrix(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 }, false);
+ checkGetSubMatrix(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 }, false);
+ checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
+ checkGetSubMatrix(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
checkGetSubMatrix(m, null, 1, 0, 2, 4, true);
checkGetSubMatrix(m, null, -1, 1, 2, 2, true);
checkGetSubMatrix(m, null, 1, 0, 2, 2, true);
@@ -408,7 +408,7 @@
}
}
}
-
+
private void checkGetSubMatrix(RealMatrix m, double[][] reference,
int[] selectedRows, int[] selectedColumns,
boolean mustFail) {
@@ -429,14 +429,14 @@
RealMatrix m = new RealMatrixImpl(subTestData);
checkCopy(m, subRows23Cols00, 2 , 3 , 0, 0, false);
checkCopy(m, subRows00Cols33, 0 , 0 , 3, 3, false);
- checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3, false);
- checkCopy(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 }, false);
- checkCopy(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 }, false);
- checkCopy(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 }, false);
- checkCopy(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 }, false);
- checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
- checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
-
+ checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3, false);
+ checkCopy(m, subRows02Cols13, new int[] { 0, 2 }, new int[] { 1, 3 }, false);
+ checkCopy(m, subRows03Cols12, new int[] { 0, 3 }, new int[] { 1, 2 }, false);
+ checkCopy(m, subRows03Cols123, new int[] { 0, 3 }, new int[] { 1, 2, 3 }, false);
+ checkCopy(m, subRows20Cols123, new int[] { 2, 0 }, new int[] { 1, 2, 3 }, false);
+ checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
+ checkCopy(m, subRows31Cols31, new int[] { 3, 1 }, new int[] { 3, 1 }, false);
+
checkCopy(m, null, 1, 0, 2, 4, true);
checkCopy(m, null, -1, 1, 2, 2, true);
checkCopy(m, null, 1, 0, 2, 2, true);
@@ -463,7 +463,7 @@
}
}
}
-
+
private void checkCopy(RealMatrix m, double[][] reference,
int[] selectedRows, int[] selectedColumns,
boolean mustFail) {
@@ -487,9 +487,9 @@
RealMatrix m = new RealMatrixImpl(subTestData);
RealMatrix mRow0 = new RealMatrixImpl(subRow0);
RealMatrix mRow3 = new RealMatrixImpl(subRow3);
- assertEquals("Row0", mRow0,
+ assertEquals("Row0", mRow0,
m.getRowMatrix(0));
- assertEquals("Row3", mRow3,
+ assertEquals("Row3", mRow3,
m.getRowMatrix(3));
try {
m.getRowMatrix(-1);
@@ -504,7 +504,7 @@
// expected
}
}
-
+
public void testSetRowMatrix() {
RealMatrix m = new RealMatrixImpl(subTestData);
RealMatrix mRow3 = new RealMatrixImpl(subRow3);
@@ -524,14 +524,14 @@
// expected
}
}
-
+
public void testGetColumnMatrix() {
RealMatrix m = new RealMatrixImpl(subTestData);
RealMatrix mColumn1 = new RealMatrixImpl(subColumn1);
RealMatrix mColumn3 = new RealMatrixImpl(subColumn3);
- assertEquals("Column1", mColumn1,
+ assertEquals("Column1", mColumn1,
m.getColumnMatrix(1));
- assertEquals("Column3", mColumn3,
+ assertEquals("Column3", mColumn3,
m.getColumnMatrix(3));
try {
m.getColumnMatrix(-1);
@@ -606,7 +606,7 @@
// expected
}
}
-
+
public void testGetColumnVector() {
RealMatrix m = new RealMatrixImpl(subTestData);
RealVector mColumn1 = columnToVector(subColumn1);
@@ -691,7 +691,7 @@
// expected
}
}
-
+
public void testGetColumn() {
RealMatrix m = new RealMatrixImpl(subTestData);
double[] mColumn1 = columnToArray(subColumn1);
@@ -743,10 +743,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() {
RealMatrixImpl m = new RealMatrixImpl(testData);
RealMatrixImpl m1 = (RealMatrixImpl) m.copy();
@@ -757,9 +757,9 @@
assertEquals(m, m1);
assertFalse(m.equals(null));
assertFalse(m.equals(mt));
- assertFalse(m.equals(new RealMatrixImpl(bigSingular)));
+ assertFalse(m.equals(new RealMatrixImpl(bigSingular)));
}
-
+
public void testToString() {
RealMatrixImpl m = new RealMatrixImpl(testData);
assertEquals("RealMatrixImpl{{1.0,2.0,3.0},{2.0,5.0,3.0},{1.0,0.0,8.0}}",
@@ -768,45 +768,45 @@
assertEquals("RealMatrixImpl{}",
m.toString());
}
-
+
public void testSetSubMatrix() throws Exception {
RealMatrixImpl m = new RealMatrixImpl(testData);
m.setSubMatrix(detData2,1,1);
RealMatrix expected = MatrixUtils.createRealMatrix
(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 = MatrixUtils.createRealMatrix
(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 = MatrixUtils.createRealMatrix
(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);
+
// 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);
@@ -827,7 +827,7 @@
} catch (IllegalStateException e) {
// expected
}
-
+
// ragged
try {
m.setSubMatrix(new double[][] {{1}, {2, 3}}, 0, 0);
@@ -835,7 +835,7 @@
} catch (IllegalArgumentException e) {
// expected
}
-
+
// empty
try {
m.setSubMatrix(new double[][] {{}}, 0, 0);
@@ -843,7 +843,7 @@
} catch (IllegalArgumentException e) {
// expected
}
-
+
}
public void testWalk() {
@@ -862,11 +862,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);
}
@@ -882,11 +882,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);
}
@@ -902,11 +902,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);
}
@@ -922,11 +922,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(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);
}
@@ -936,8 +936,8 @@
RealMatrixImpl m = new RealMatrixImpl(testData);
assertEquals(m,TestUtils.serializeAndRecover(m));
}
-
-
+
+
private static class SetVisitor extends DefaultRealMatrixChangingVisitor {
@Override
public double visit(int i, int j, double value) {
@@ -958,14 +958,14 @@
}
//--------------- -----------------Protected methods
-
+
/** extracts the l and u matrices from compact lu representation */
- protected void splitLU(RealMatrix lu, double[][] lowerData, double[][] upperData) throws InvalidMatrixException {
+ protected void splitLU(RealMatrix lu, double[][] lowerData, double[][] upperData) 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++) {
@@ -978,11 +978,11 @@
} else {
lowerData[i][j] = 0d;
upperData[i][j] = lu.getEntry(i, j);
- }
+ }
}
}
}
-
+
/** Returns the result of applying the given row permutation to the matrix */
protected RealMatrix permuteRows(RealMatrix matrix, int[] permutation) {
if (!matrix.isSquare() || matrix.getRowDimension() != permutation.length) {
@@ -998,7 +998,7 @@
}
return new RealMatrixImpl(out);
}
-
+
// /** Useful for debugging */
// private void dumpMatrix(RealMatrix m) {
// for (int i = 0; i < m.getRowDimension(); i++) {
@@ -1009,6 +1009,6 @@
// System.out.println(os);
// }
// }
-
+
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/RealVectorFormatAbstractTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/RealVectorFormatAbstractTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/RealVectorFormatAbstractTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/RealVectorFormatAbstractTest.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.
@@ -27,7 +27,7 @@
import org.apache.commons.math.util.CompositeFormat;
public abstract class RealVectorFormatAbstractTest extends TestCase {
-
+
RealVectorFormat realVectorFormat = null;
RealVectorFormat realVectorFormatSquare = null;
@@ -42,11 +42,11 @@
nf.setMaximumFractionDigits(2);
realVectorFormatSquare = new RealVectorFormat("[", "]", " : ", nf);
}
-
+
public void testSimpleNoDecimals() {
ArrayRealVector c = new ArrayRealVector(new double[] {1, 1, 1});
String expected = "{1; 1; 1}";
- String actual = realVectorFormat.format(c);
+ String actual = realVectorFormat.format(c);
assertEquals(expected, actual);
}
@@ -57,7 +57,7 @@
"23; 1" + getDecimalCharacter() +
"43; 1" + getDecimalCharacter() +
"63}";
- String actual = realVectorFormat.format(c);
+ String actual = realVectorFormat.format(c);
assertEquals(expected, actual);
}
@@ -68,7 +68,7 @@
"23; 1" + getDecimalCharacter() +
"43; 1" + getDecimalCharacter() +
"63}";
- String actual = realVectorFormat.format(c);
+ String actual = realVectorFormat.format(c);
assertEquals(expected, actual);
}
@@ -79,7 +79,7 @@
"23; 1" + getDecimalCharacter() +
"43; 1" + getDecimalCharacter() +
"63}";
- String actual = realVectorFormat.format(c);
+ String actual = realVectorFormat.format(c);
assertEquals(expected, actual);
}
@@ -90,7 +90,7 @@
"23; -1" + getDecimalCharacter() +
"43; 1" + getDecimalCharacter() +
"63}";
- String actual = realVectorFormat.format(c);
+ String actual = realVectorFormat.format(c);
assertEquals(expected, actual);
}
@@ -101,37 +101,37 @@
"23; 1" + getDecimalCharacter() +
"43; -1" + getDecimalCharacter() +
"63}";
- String actual = realVectorFormat.format(c);
+ String actual = realVectorFormat.format(c);
assertEquals(expected, actual);
}
public void testNonDefaultSetting() {
ArrayRealVector c = new ArrayRealVector(new double[] {1, 1, 1});
String expected = "[1 : 1 : 1]";
- String actual = realVectorFormatSquare.format(c);
+ String actual = realVectorFormatSquare.format(c);
assertEquals(expected, actual);
}
-
+
public void testStaticFormatRealVectorImpl() {
Locale defaultLocal = Locale.getDefault();
Locale.setDefault(getLocale());
-
+
ArrayRealVector c = new ArrayRealVector(new double[] {232.222, -342.33, 432.444});
String expected =
"{232" + getDecimalCharacter() +
"22; -342" + getDecimalCharacter() +
"33; 432" + getDecimalCharacter() +
"44}";
- String actual = RealVectorFormat.formatRealVector(c);
+ String actual = RealVectorFormat.formatRealVector(c);
assertEquals(expected, actual);
-
+
Locale.setDefault(defaultLocal);
}
public void testNan() {
ArrayRealVector c = new ArrayRealVector(new double[] {Double.NaN, Double.NaN, Double.NaN});
String expected = "{(NaN); (NaN); (NaN)}";
- String actual = realVectorFormat.format(c);
+ String actual = realVectorFormat.format(c);
assertEquals(expected, actual);
}
@@ -140,7 +140,7 @@
Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY
});
String expected = "{(Infinity); (Infinity); (Infinity)}";
- String actual = realVectorFormat.format(c);
+ String actual = realVectorFormat.format(c);
assertEquals(expected, actual);
}
@@ -149,7 +149,7 @@
Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY
});
String expected = "{(-Infinity); (-Infinity); (-Infinity)}";
- String actual = realVectorFormat.format(c);
+ String actual = realVectorFormat.format(c);
assertEquals(expected, actual);
}
@@ -157,7 +157,7 @@
String source = "{1; 1; 1}";
ArrayRealVector expected = new ArrayRealVector(new double[] {1, 1, 1});
try {
- ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
+ ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
assertEquals(expected, actual);
} catch (ParseException ex) {
fail(ex.getMessage());
@@ -184,7 +184,7 @@
"63}";
ArrayRealVector expected = new ArrayRealVector(new double[] {1.23, 1.43, 1.63});
try {
- ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
+ ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
assertEquals(expected, actual);
} catch (ParseException ex) {
fail(ex.getMessage());
@@ -199,7 +199,7 @@
"6333}";
ArrayRealVector expected = new ArrayRealVector(new double[] {1.2323, 1.4343, 1.6333});
try {
- ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
+ ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
assertEquals(expected, actual);
} catch (ParseException ex) {
fail(ex.getMessage());
@@ -214,7 +214,7 @@
"6333}";
ArrayRealVector expected = new ArrayRealVector(new double[] {-1.2323, 1.4343, 1.6333});
try {
- ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
+ ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
assertEquals(expected, actual);
} catch (ParseException ex) {
fail(ex.getMessage());
@@ -229,7 +229,7 @@
"6333}";
ArrayRealVector expected = new ArrayRealVector(new double[] {1.2323, -1.4343, 1.6333});
try {
- ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
+ ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
assertEquals(expected, actual);
} catch (ParseException ex) {
fail(ex.getMessage());
@@ -244,7 +244,7 @@
"6333}";
ArrayRealVector expected = new ArrayRealVector(new double[] {1.2323, 1.4343, -1.6333});
try {
- ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
+ ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
assertEquals(expected, actual);
} catch (ParseException ex) {
fail(ex.getMessage());
@@ -259,7 +259,7 @@
"6333}";
ArrayRealVector expected = new ArrayRealVector(new double[] {-1.2323, -1.4343, -1.6333});
try {
- ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
+ ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
assertEquals(expected, actual);
} catch (ParseException ex) {
fail(ex.getMessage());
@@ -274,7 +274,7 @@
"6333}";
ArrayRealVector expected = new ArrayRealVector(new double[] {0.0, -1.4343, 1.6333});
try {
- ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
+ ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
assertEquals(expected, actual);
} catch (ParseException ex) {
fail(ex.getMessage());
@@ -289,17 +289,17 @@
"6333]";
ArrayRealVector expected = new ArrayRealVector(new double[] {1.2323, 1.4343, 1.6333});
try {
- ArrayRealVector actual = (ArrayRealVector) realVectorFormatSquare.parseObject(source);
+ ArrayRealVector actual = (ArrayRealVector) realVectorFormatSquare.parseObject(source);
assertEquals(expected, actual);
} catch (ParseException ex) {
fail(ex.getMessage());
}
}
-
+
public void testParseNan() {
String source = "{(NaN); (NaN); (NaN)}";
try {
- ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
+ ArrayRealVector actual = (ArrayRealVector) realVectorFormat.parseObject(source);
assertEquals(new ArrayRealVector(new double[] {Double.NaN, Double.NaN, Double.NaN}), actual);
} catch (ParseException ex) {
fail(ex.getMessage());
@@ -309,7 +309,7 @@
public void testParsePositiveInfinity() {
String source = "{(Infinity); (Infinity); (Infinity)}";
try {
- ArrayRealVector actual = (ArrayRealVector)realVectorFormat.parseObject(source);
+ ArrayRealVector actual = (ArrayRealVector)realVectorFormat.parseObject(source);
assertEquals(new ArrayRealVector(new double[] {
Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY
}), actual);
@@ -321,7 +321,7 @@
public void testParseNegativeInfinity() {
String source = "{(-Infinity); (-Infinity); (-Infinity)}";
try {
- ArrayRealVector actual = (ArrayRealVector)realVectorFormat.parseObject(source);
+ ArrayRealVector actual = (ArrayRealVector)realVectorFormat.parseObject(source);
assertEquals(new ArrayRealVector(new double[] {
Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY
}), actual);
@@ -352,7 +352,7 @@
assertNotNull(cf);
assertEquals(nf, cf.getFormat());
}
-
+
public void testFormatObject() {
try {
CompositeFormat cf = new RealVectorFormat();
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/RealVectorFormatTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/RealVectorFormatTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/RealVectorFormatTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/RealVectorFormatTest.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/SingularValueDecompositionImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SingularValueDecompositionImplTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SingularValueDecompositionImplTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SingularValueDecompositionImplTest.java Sat Sep 5 17:36:48 2009
@@ -199,7 +199,7 @@
assertTrue(u == svd.getU());
assertTrue(s == svd.getS());
assertTrue(v == svd.getV());
-
+
}
/** test matrices values */
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.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.
@@ -123,8 +123,8 @@
} catch (FractionConversionException e) {
// ignore, can't happen
}
-
-
+
+
}
public static Test suite() {
@@ -165,8 +165,8 @@
FieldMatrix<Fraction> mPlusMInv = m.add(mInv);
for (int row = 0; row < m.getRowDimension(); row++) {
for (int col = 0; col < m.getColumnDimension(); col++) {
- assertEquals("sum entry entry",
- mDataPlusInv.getEntry(row, col).doubleValue(), mPlusMInv.getEntry(row, col).doubleValue(),
+ assertEquals("sum entry entry",
+ mDataPlusInv.getEntry(row, col).doubleValue(), mPlusMInv.getEntry(row, col).doubleValue(),
entryTolerance);
}
}
@@ -184,7 +184,7 @@
}
}
-
+
/** test m-n = m + -n */
public void testPlusMinus() {
SparseFieldMatrix<Fraction> m = createSparseMatrix(testData);
@@ -254,7 +254,7 @@
/** test sclarAdd */
public void testScalarAdd() {
FieldMatrix<Fraction> m = createSparseMatrix(testData);
- assertClose("scalar add", createSparseMatrix(testDataPlus2),
+ assertClose("scalar add", createSparseMatrix(testDataPlus2),
m.scalarAdd(new Fraction(2)), entryTolerance);
}
@@ -287,8 +287,8 @@
/** test transpose */
public void testTranspose() {
-
- FieldMatrix<Fraction> m = createSparseMatrix(testData);
+
+ FieldMatrix<Fraction> m = createSparseMatrix(testData);
FieldMatrix<Fraction> mIT = new FieldLUDecompositionImpl<Fraction>(m).getSolver().getInverse().transpose();
FieldMatrix<Fraction> mTI = new FieldLUDecompositionImpl<Fraction>(m.transpose()).getSolver().getInverse();
assertClose("inverse-transpose", mIT, mTI, normTolerance);
@@ -380,7 +380,7 @@
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());
@@ -413,17 +413,17 @@
assertEquals("Rows23Cols00", mRows23Cols00, m.getSubMatrix(2, 3, 0, 0));
assertEquals("Rows00Cols33", mRows00Cols33, m.getSubMatrix(0, 0, 3, 3));
assertEquals("Rows01Cols23", mRows01Cols23, m.getSubMatrix(0, 1, 2, 3));
- assertEquals("Rows02Cols13", mRows02Cols13,
+ assertEquals("Rows02Cols13", mRows02Cols13,
m.getSubMatrix(new int[] { 0, 2 }, new int[] { 1, 3 }));
- assertEquals("Rows03Cols12", mRows03Cols12,
+ assertEquals("Rows03Cols12", mRows03Cols12,
m.getSubMatrix(new int[] { 0, 3 }, new int[] { 1, 2 }));
- assertEquals("Rows03Cols123", mRows03Cols123,
+ assertEquals("Rows03Cols123", mRows03Cols123,
m.getSubMatrix(new int[] { 0, 3 }, new int[] { 1, 2, 3 }));
- assertEquals("Rows20Cols123", mRows20Cols123,
+ assertEquals("Rows20Cols123", mRows20Cols123,
m.getSubMatrix(new int[] { 2, 0 }, new int[] { 1, 2, 3 }));
- assertEquals("Rows31Cols31", mRows31Cols31,
+ assertEquals("Rows31Cols31", mRows31Cols31,
m.getSubMatrix(new int[] { 3, 1 }, new int[] { 3, 1 }));
- assertEquals("Rows31Cols31", mRows31Cols31,
+ assertEquals("Rows31Cols31", mRows31Cols31,
m.getSubMatrix(new int[] { 3, 1 }, new int[] { 3, 1 }));
try {
@@ -568,7 +568,7 @@
/* Disable for now
public void testToString() {
SparseFieldMatrix<Fraction> m = createSparseMatrix(testData);
- assertEquals("SparseFieldMatrix<Fraction>{{1.0,2.0,3.0},{2.0,5.0,3.0},{1.0,0.0,8.0}}",
+ assertEquals("SparseFieldMatrix<Fraction>{{1.0,2.0,3.0},{2.0,5.0,3.0},{1.0,0.0,8.0}}",
m.toString());
m = new SparseFieldMatrix<Fraction>(field, 1, 1);
assertEquals("SparseFieldMatrix<Fraction>{{0.0}}", m.toString());
@@ -593,8 +593,8 @@
assertEquals(expected, m);
// javadoc example
- SparseFieldMatrix<Fraction> matrix =
- createSparseMatrix(new Fraction[][] {
+ SparseFieldMatrix<Fraction> matrix =
+ createSparseMatrix(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) }, { new Fraction(9), new Fraction(0), new Fraction(1), new Fraction(2) } });
matrix.setSubMatrix(new Fraction[][] { { new Fraction(3), new Fraction(4) }, { new Fraction(5), new Fraction(6) } }, 1, 1);
expected = createSparseMatrix(new Fraction[][] {
@@ -663,7 +663,7 @@
for(int j=0; j < m.getColumnDimension(); j++){
assertEquals(msg, m.getEntry(i,j).doubleValue(), n.getEntry(i,j).doubleValue(), tolerance);
}
-
+
}
}
@@ -678,7 +678,7 @@
tolerance);
}
}
-
+
private SparseFieldMatrix<Fraction> createSparseMatrix(Fraction[][] data) {
SparseFieldMatrix<Fraction> matrix = new SparseFieldMatrix<Fraction>(field, data.length, data[0].length);
for (int row = 0; row < data.length; row++) {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldVectorTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldVectorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldVectorTest.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,7 +31,7 @@
*/
public class SparseFieldVectorTest extends TestCase {
- //
+ //
protected Fraction[][] ma1 = {{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(9)}};
protected Fraction[] vec1 = {new Fraction(1), new Fraction(2), new Fraction(3)};
protected Fraction[] vec2 = {new Fraction(4), new Fraction(5), new Fraction(6)};
@@ -47,7 +47,7 @@
protected FractionField field = FractionField.getInstance();
- public void testMapFunctions() throws FractionConversionException {
+ public void testMapFunctions() throws FractionConversionException {
SparseFieldVector<Fraction> v1 = new SparseFieldVector<Fraction>(field,vec1);
//octave = v1 .+ 2.0
@@ -108,11 +108,11 @@
}
- public void testBasicFunctions() throws FractionConversionException {
+ public void testBasicFunctions() throws FractionConversionException {
SparseFieldVector<Fraction> v1 = new SparseFieldVector<Fraction>(field,vec1);
SparseFieldVector<Fraction> v2 = new SparseFieldVector<Fraction>(field,vec2);
- SparseFieldVector<Fraction> v2_t = new SparseFieldVector<Fraction>(field,vec2);
+ SparseFieldVector<Fraction> v2_t = new SparseFieldVector<Fraction>(field,vec2);
//octave = v1 + v2
FieldVector<Fraction> v_add = v1.add(v2);
@@ -168,19 +168,19 @@
}
- public void testMisc() {
+ public void testMisc() {
SparseFieldVector<Fraction> v1 = new SparseFieldVector<Fraction>(field,vec1);
String out1 = v1.toString();
assertTrue("some output ", out1.length()!=0);
try {
- v1.checkVectorDimensions(2);
+ v1.checkVectorDimensions(2);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// expected behavior
} catch (Exception e) {
fail("wrong exception caught");
- }
+ }
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealMatrixTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealMatrixTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealMatrixTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealMatrixTest.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.
@@ -24,7 +24,7 @@
/**
* Test cases for the {@link OpenMapRealMatrix} class.
- *
+ *
* @version $Revision$ $Date: 2008-11-07 06:48:13 -0800 (Fri, 07 Nov
* 2008) $
*/
@@ -146,8 +146,8 @@
RealMatrix mPlusMInv = m.add(mInv);
for (int row = 0; row < m.getRowDimension(); row++) {
for (int col = 0; col < m.getColumnDimension(); col++) {
- assertEquals("sum entry entry",
- mDataPlusInv.getEntry(row, col), mPlusMInv.getEntry(row, col),
+ assertEquals("sum entry entry",
+ mDataPlusInv.getEntry(row, col), mPlusMInv.getEntry(row, col),
entryTolerance);
}
}
@@ -242,7 +242,7 @@
/** test sclarAdd */
public void testScalarAdd() {
RealMatrix m = createSparseMatrix(testData);
- assertClose("scalar add", createSparseMatrix(testDataPlus2),
+ assertClose("scalar add", createSparseMatrix(testDataPlus2),
m.scalarAdd(2d), entryTolerance);
}
@@ -275,8 +275,8 @@
/** test transpose */
public void testTranspose() {
-
- RealMatrix m = createSparseMatrix(testData);
+
+ RealMatrix m = createSparseMatrix(testData);
RealMatrix mIT = new LUDecompositionImpl(m).getSolver().getInverse().transpose();
RealMatrix mTI = new LUDecompositionImpl(m.transpose()).getSolver().getInverse();
assertClose("inverse-transpose", mIT, mTI, normTolerance);
@@ -368,7 +368,7 @@
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());
@@ -401,17 +401,17 @@
assertEquals("Rows23Cols00", mRows23Cols00, m.getSubMatrix(2, 3, 0, 0));
assertEquals("Rows00Cols33", mRows00Cols33, m.getSubMatrix(0, 0, 3, 3));
assertEquals("Rows01Cols23", mRows01Cols23, m.getSubMatrix(0, 1, 2, 3));
- assertEquals("Rows02Cols13", mRows02Cols13,
+ assertEquals("Rows02Cols13", mRows02Cols13,
m.getSubMatrix(new int[] { 0, 2 }, new int[] { 1, 3 }));
- assertEquals("Rows03Cols12", mRows03Cols12,
+ assertEquals("Rows03Cols12", mRows03Cols12,
m.getSubMatrix(new int[] { 0, 3 }, new int[] { 1, 2 }));
- assertEquals("Rows03Cols123", mRows03Cols123,
+ assertEquals("Rows03Cols123", mRows03Cols123,
m.getSubMatrix(new int[] { 0, 3 }, new int[] { 1, 2, 3 }));
- assertEquals("Rows20Cols123", mRows20Cols123,
+ assertEquals("Rows20Cols123", mRows20Cols123,
m.getSubMatrix(new int[] { 2, 0 }, new int[] { 1, 2, 3 }));
- assertEquals("Rows31Cols31", mRows31Cols31,
+ assertEquals("Rows31Cols31", mRows31Cols31,
m.getSubMatrix(new int[] { 3, 1 }, new int[] { 3, 1 }));
- assertEquals("Rows31Cols31", mRows31Cols31,
+ assertEquals("Rows31Cols31", mRows31Cols31,
m.getSubMatrix(new int[] { 3, 1 }, new int[] { 3, 1 }));
try {
@@ -555,7 +555,7 @@
public void testToString() {
OpenMapRealMatrix m = createSparseMatrix(testData);
- assertEquals("OpenMapRealMatrix{{1.0,2.0,3.0},{2.0,5.0,3.0},{1.0,0.0,8.0}}",
+ assertEquals("OpenMapRealMatrix{{1.0,2.0,3.0},{2.0,5.0,3.0},{1.0,0.0,8.0}}",
m.toString());
m = new OpenMapRealMatrix(1, 1);
assertEquals("OpenMapRealMatrix{{0.0}}", m.toString());
@@ -579,8 +579,8 @@
assertEquals(expected, m);
// javadoc example
- OpenMapRealMatrix matrix =
- createSparseMatrix(new double[][] {
+ OpenMapRealMatrix matrix =
+ createSparseMatrix(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 = createSparseMatrix(new double[][] {
@@ -664,7 +664,7 @@
tolerance);
}
}
-
+
private OpenMapRealMatrix createSparseMatrix(double[][] data) {
OpenMapRealMatrix matrix = new OpenMapRealMatrix(data.length, data[0].length);
for (int row = 0; row < data.length; row++) {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealVectorTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealVectorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealVectorTest.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,7 +31,7 @@
*/
public class SparseRealVectorTest extends TestCase {
- //
+ //
protected double[][] ma1 = {{1d, 2d, 3d}, {4d, 5d, 6d}, {7d, 8d, 9d}};
protected double[] vec1 = {1d, 2d, 3d};
protected double[] vec2 = {4d, 5d, 6d};
@@ -45,7 +45,7 @@
protected double entryTolerance = 10E-16;
protected double normTolerance = 10E-14;
- // Testclass to test the RealVector interface
+ // Testclass to test the RealVector interface
// only with enough content to support the test
public static class SparseRealVectorTestImpl implements RealVector, Serializable {
@@ -521,7 +521,7 @@
OpenMapRealVector v1 = new OpenMapRealVector(vec1);
OpenMapRealVector v2 = new OpenMapRealVector(vec2);
OpenMapRealVector v4 = new OpenMapRealVector(vec4);
- SparseRealVectorTestImpl v2_t = new SparseRealVectorTestImpl(vec2);
+ SparseRealVectorTestImpl v2_t = new SparseRealVectorTestImpl(vec2);
RealVector v_append_1 = v1.append(v2);
assertEquals("testData len", 6, v_append_1.getDimension());
@@ -538,7 +538,7 @@
RealVector v_append_4 = v1.append(v2_t);
assertEquals("testData len", 6, v_append_4.getDimension());
assertEquals("testData is 4.0 ", 4.0, v_append_4.getEntry(3));
-
+
RealVector vout5 = v4.getSubVector(3, 3);
assertEquals("testData len", 3, vout5.getDimension());
assertEquals("testData is 4.0 ", 5.0, vout5.getEntry(1));
@@ -605,7 +605,7 @@
}
- public void testMapFunctions() {
+ public void testMapFunctions() {
OpenMapRealVector v1 = new OpenMapRealVector(vec1);
//octave = v1 .+ 2.0
@@ -806,7 +806,7 @@
//octave = asin(vat)
RealVector v_mapAsinToSelf = vat.copy();
- v_mapAsinToSelf.mapAsinToSelf();
+ v_mapAsinToSelf.mapAsinToSelf();
double[] result_mapAsinToSelf = {0.0d,5.235987755982989e-01d,1.570796326794897e+00d};
assertClose("compare vectors" ,result_mapAsinToSelf,v_mapAsinToSelf.getData(),normTolerance);
@@ -933,12 +933,12 @@
}
- public void testBasicFunctions() {
+ public void testBasicFunctions() {
OpenMapRealVector v1 = new OpenMapRealVector(vec1);
OpenMapRealVector v2 = new OpenMapRealVector(vec2);
OpenMapRealVector v_null = new OpenMapRealVector(vec_null);
- SparseRealVectorTestImpl v2_t = new SparseRealVectorTestImpl(vec2);
+ SparseRealVectorTestImpl v2_t = new SparseRealVectorTestImpl(vec2);
//octave = sqrt(sumsq(v1))
double d_getNorm = v1.getNorm();
@@ -1024,7 +1024,7 @@
assertEquals("compare val ",4d, m_outerProduct_2.getEntry(0,0));
RealVector v_unitVector = v1.unitVector();
- RealVector v_unitVector_2 = v1.mapDivide(v1.getNorm());
+ RealVector v_unitVector_2 = v1.mapDivide(v1.getNorm());
assertClose("compare vect" ,v_unitVector.getData(),v_unitVector_2.getData(),normTolerance);
try {
@@ -1056,21 +1056,21 @@
double[] result_projection_2 = {1.662337662337662, 2.0779220779220777, 2.493506493506493};
assertClose("compare vect", v_projection_2.getData(), result_projection_2, normTolerance);
- }
+ }
- public void testMisc() {
+ public void testMisc() {
OpenMapRealVector v1 = new OpenMapRealVector(vec1);
String out1 = v1.toString();
assertTrue("some output ", out1.length()!=0);
try {
- v1.checkVectorDimensions(2);
+ v1.checkVectorDimensions(2);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// expected behavior
} catch (Exception e) {
fail("wrong exception caught");
- }
+ }
}
@@ -1100,7 +1100,7 @@
OpenMapRealVector v = new OpenMapRealVector(new double[] { 0, 1, 2 });
assertEquals(v,TestUtils.serializeAndRecover(v));
}
-
+
/** verifies that two vectors are close (sup norm) */
protected void assertClose(String msg, double[] m, double[] n,
double tolerance) {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/TriDiagonalTransformerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/TriDiagonalTransformerTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/TriDiagonalTransformerTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/TriDiagonalTransformerTest.java Sat Sep 5 17:36:48 2009
@@ -106,7 +106,7 @@
private void checkOrthogonal(RealMatrix m) {
RealMatrix mTm = m.transpose().multiply(m);
RealMatrix id = MatrixUtils.createRealIdentityMatrix(mTm.getRowDimension());
- assertEquals(0, mTm.subtract(id).getNorm(), 1.0e-15);
+ assertEquals(0, mTm.subtract(id).getNorm(), 1.0e-15);
}
public void testTTriDiagonal() {
@@ -121,7 +121,7 @@
for (int j = 0; j < cols; ++j) {
if ((i < j - 1) || (i > j + 1)) {
assertEquals(0, m.getEntry(i, j), 1.0e-16);
- }
+ }
}
}
}
@@ -176,7 +176,7 @@
// check the same cached instance is returned the second time
assertTrue(q == transformer.getQ());
assertTrue(t == transformer.getT());
-
+
}
public static Test suite() {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/ContinuousOutputModelTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/ContinuousOutputModelTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/ContinuousOutputModelTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/ContinuousOutputModelTest.java Sat Sep 5 17:36:48 2009
@@ -128,7 +128,7 @@
assertEquals(Math.cos(t), y[0], 1.0e-7);
assertEquals(Math.sin(t), y[1], 1.0e-7);
}
-
+
}
public void testErrorConditions()
@@ -136,7 +136,7 @@
ContinuousOutputModel cm = new ContinuousOutputModel();
cm.handleStep(buildInterpolator(0, new double[] { 0.0, 1.0, -2.0 }, 1), true);
-
+
// dimension mismatch
assertTrue(checkAppendError(cm, 1.0, new double[] { 0.0, 1.0 }, 2.0));
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/FirstOrderConverterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/FirstOrderConverterTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/FirstOrderConverterTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/FirstOrderConverterTest.java Sat Sep 5 17:36:48 2009
@@ -39,10 +39,10 @@
assertTrue(eqn1.getDimension() == (2 * eqn2.getDimension()));
}
}
-
+
public void testDecreasingSteps()
throws DerivativeException, IntegratorException {
-
+
double previousError = Double.NaN;
for (int i = 0; i < 10; ++i) {
@@ -53,7 +53,7 @@
assertTrue(Math.abs(error) < Math.abs(previousError));
}
previousError = error;
-
+
}
}
@@ -70,34 +70,34 @@
- Math.sin(4.0);
assertTrue(Math.abs(error) > 0.1);
}
-
+
public static Test suite() {
return new TestSuite(FirstOrderConverterTest.class);
}
private static class Equations
implements SecondOrderDifferentialEquations {
-
+
private int n;
private double omega2;
-
+
public Equations(int n, double omega) {
this.n = n;
omega2 = omega * omega;
}
-
+
public int getDimension() {
return n;
}
-
+
public void computeSecondDerivatives(double t, double[] y, double[] yDot,
double[] yDDot) {
for (int i = 0; i < n; ++i) {
yDDot[i] = -omega2 * y[i];
}
}
-
+
}
private double integrateWithSpecifiedStep(double omega,
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem1.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem1.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem1.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem1.java Sat Sep 5 17:36:48 2009
@@ -52,7 +52,7 @@
setErrorScale(errorScale);
y = new double[y0.length];
}
-
+
/**
* Copy constructor.
* @param problem problem to copy
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem2.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem2.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem2.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem2.java Sat Sep 5 17:36:48 2009
@@ -53,7 +53,7 @@
setErrorScale(errorScale);
y = new double[y0.length];
}
-
+
/**
* Copy constructor.
* @param problem problem to copy
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem3.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem3.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem3.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem3.java Sat Sep 5 17:36:48 2009
@@ -60,14 +60,14 @@
setErrorScale(errorScale);
y = new double[y0.length];
}
-
+
/**
* Simple constructor.
*/
public TestProblem3() {
this(0.1);
}
-
+
/**
* Copy constructor.
* @param problem problem to copy
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem4.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem4.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem4.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem4.java Sat Sep 5 17:36:48 2009
@@ -57,7 +57,7 @@
setErrorScale(errorScale);
y = new double[y0.length];
}
-
+
/**
* Copy constructor.
* @param problem problem to copy
@@ -111,7 +111,7 @@
sign = -sign;
return EventHandler.RESET_STATE;
}
-
+
public void resetState(double t, double[] y) {
y[0] = -y[0];
y[1] = -y[1];
@@ -133,7 +133,7 @@
public int eventOccurred(double t, double[] y, boolean increasing) {
return EventHandler.STOP;
}
-
+
public void resetState(double t, double[] y) {
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblemAbstract.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblemAbstract.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblemAbstract.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblemAbstract.java Sat Sep 5 17:36:48 2009
@@ -96,7 +96,7 @@
calls = 0;
n = y0.length;
this.t0 = t0;
- this.y0 = y0.clone();
+ this.y0 = y0.clone();
}
/**
@@ -112,7 +112,7 @@
* @param errorScale error scale
*/
protected void setErrorScale(double[] errorScale) {
- this.errorScale = errorScale.clone();
+ this.errorScale = errorScale.clone();
}
public int getDimension() {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java Sat Sep 5 17:36:48 2009
@@ -73,10 +73,10 @@
} catch(IntegratorException ie) {
}
}
-
+
public void testDecreasingSteps()
throws DerivativeException, IntegratorException {
-
+
TestProblemAbstract[] problems = TestProblemFactory.getProblems();
for (int k = 0; k < problems.length; ++k) {
@@ -231,7 +231,7 @@
return false;
}
public void reset() {
- }
+ }
});
integ.integrate(new FirstOrderDifferentialEquations() {
private static final long serialVersionUID = 0L;
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java Sat Sep 5 17:36:48 2009
@@ -352,7 +352,7 @@
assertTrue(minStep < (1.0 / 450.0));
assertTrue(maxStep > (1.0 / 4.2));
}
- }
+ }
private boolean firstTime;
private double minStep;
private double maxStep;
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerIntegratorTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerIntegratorTest.java Sat Sep 5 17:36:48 2009
@@ -52,7 +52,7 @@
} catch(IntegratorException ie) {
}
}
-
+
public void testDecreasingSteps()
throws DerivativeException, IntegratorException {
@@ -166,7 +166,7 @@
return false;
}
public void reset() {
- }
+ }
});
integ.integrate(new FirstOrderDifferentialEquations() {
private static final long serialVersionUID = 0L;
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java Sat Sep 5 17:36:48 2009
@@ -145,7 +145,7 @@
for (StepHandler handler : integ.getStepHandlers()) {
oos.writeObject(handler);
}
-
+
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
ContinuousOutputModel cm = (ContinuousOutputModel) ois.readObject();
@@ -171,7 +171,7 @@
private static class DummyIntegrator extends RungeKuttaIntegrator {
-
+
protected DummyIntegrator(RungeKuttaStepInterpolator prototype) {
super("dummy", new double[0], new double[0][0], new double[0], prototype, Double.NaN);
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GillIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GillIntegratorTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GillIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GillIntegratorTest.java Sat Sep 5 17:36:48 2009
@@ -53,10 +53,10 @@
} catch(IntegratorException ie) {
}
}
-
+
public void testDecreasingSteps()
throws DerivativeException, IntegratorException {
-
+
TestProblemAbstract[] problems = TestProblemFactory.getProblems();
for (int k = 0; k < problems.length; ++k) {
@@ -221,7 +221,7 @@
return false;
}
public void reset() {
- }
+ }
});
integ.integrate(new FirstOrderDifferentialEquations() {
private static final long serialVersionUID = 0L;
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54IntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54IntegratorTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54IntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54IntegratorTest.java Sat Sep 5 17:36:48 2009
@@ -79,7 +79,7 @@
}
} catch (Exception e) {
- fail("wrong exception caught: " + e.getMessage());
+ fail("wrong exception caught: " + e.getMessage());
}
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/MidpointIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/MidpointIntegratorTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/MidpointIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/MidpointIntegratorTest.java Sat Sep 5 17:36:48 2009
@@ -52,10 +52,10 @@
} catch(IntegratorException ie) {
}
}
-
+
public void testDecreasingSteps()
throws DerivativeException, IntegratorException {
-
+
TestProblemAbstract[] problems = TestProblemFactory.getProblems();
for (int k = 0; k < problems.length; ++k) {
@@ -166,7 +166,7 @@
return false;
}
public void reset() {
- }
+ }
});
integ.integrate(new FirstOrderDifferentialEquations() {
private static final long serialVersionUID = 0L;
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegratorTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegratorTest.java Sat Sep 5 17:36:48 2009
@@ -53,13 +53,13 @@
} catch(IntegratorException ie) {
}
}
-
+
public void testDecreasingSteps()
throws DerivativeException, IntegratorException {
-
+
TestProblemAbstract[] problems = TestProblemFactory.getProblems();
for (int k = 0; k < problems.length; ++k) {
-
+
double previousError = Double.NaN;
for (int i = 4; i < 10; ++i) {
@@ -217,7 +217,7 @@
return false;
}
public void reset() {
- }
+ }
});
integ.integrate(new FirstOrderDifferentialEquations() {
public void computeDerivatives(double t, double[] y, double[] dot) {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateVectorialOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateVectorialOptimizerTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateVectorialOptimizerTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateVectorialOptimizerTest.java Sat Sep 5 17:36:48 2009
@@ -38,7 +38,7 @@
/**
* <p>Some of the unit tests are re-implementations of the MINPACK <a
* href="http://www.netlib.org/minpack/ex/file17">file17</a> and <a
- * href="http://www.netlib.org/minpack/ex/file22">file22</a> test files.
+ * href="http://www.netlib.org/minpack/ex/file22">file22</a> test files.
* The redistribution policy for MINPACK is available <a
* href="http://www.netlib.org/minpack/disclaimer">here</a>, for
* convenience, it is reproduced below.</p>
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java Sat Sep 5 17:36:48 2009
@@ -53,7 +53,7 @@
Assert.assertNull(ce.getCause());
} catch (Exception e) {
Assert.fail("wrong exception caught: " + e.getMessage());
- }
+ }
try {
MultiDirectional optimizer = new MultiDirectional(0.9, 1.9);
optimizer.optimize(wrong, GoalType.MINIMIZE, new double[] { +2.0 });
@@ -63,7 +63,7 @@
Assert.assertNotNull(ce.getCause());
} catch (Exception e) {
Assert.fail("wrong exception caught: " + e.getMessage());
- }
+ }
}
@Test
@@ -105,7 +105,7 @@
optimum = optimizer.optimize(fourExtrema, GoalType.MINIMIZE, new double[] { +1, 0 });
Assert.assertEquals(xP, optimum.getPoint()[0], 2.0e-8);
Assert.assertEquals(yM, optimum.getPoint()[1], 3.0e-6);
- Assert.assertEquals(valueXpYm, optimum.getValue(), 2.0e-12);
+ Assert.assertEquals(valueXpYm, optimum.getValue(), 2.0e-12);
Assert.assertTrue(optimizer.getEvaluations() > 120);
Assert.assertTrue(optimizer.getEvaluations() < 150);
@@ -213,7 +213,7 @@
final double[] actualPosition = estimate.getPoint();
Assert.assertEquals(expectedPosition[0], actualPosition[0], EPSILON );
Assert.assertEquals(expectedPosition[1], actualPosition[1], EPSILON );
-
+
}
private static class Gaussian2D implements MultivariateRealFunction {
@@ -221,7 +221,7 @@
private final double[] maximumPosition;
private final double std;
-
+
public Gaussian2D(double xOpt, double yOpt, double std) {
maximumPosition = new double[] { xOpt, yOpt };
this.std = std;
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/NelderMeadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/NelderMeadTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/NelderMeadTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/NelderMeadTest.java Sat Sep 5 17:36:48 2009
@@ -66,7 +66,7 @@
assertNull(ce.getCause());
} catch (Exception e) {
fail("wrong exception caught: " + e.getMessage());
- }
+ }
try {
NelderMead optimizer = new NelderMead(0.9, 1.9, 0.4, 0.6);
optimizer.optimize(wrong, GoalType.MINIMIZE, new double[] { +2.0 });
@@ -76,7 +76,7 @@
assertNotNull(ce.getCause());
} catch (Exception e) {
fail("wrong exception caught: " + e.getMessage());
- }
+ }
}
@Test
@@ -118,7 +118,7 @@
optimum = optimizer.optimize(fourExtrema, GoalType.MINIMIZE, new double[] { +1, 0 });
assertEquals(xP, optimum.getPoint()[0], 5.0e-6);
assertEquals(yM, optimum.getPoint()[1], 6.0e-6);
- assertEquals(valueXpYm, optimum.getValue(), 1.0e-11);
+ assertEquals(valueXpYm, optimum.getValue(), 1.0e-11);
assertTrue(optimizer.getEvaluations() > 60);
assertTrue(optimizer.getEvaluations() < 90);
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/fitting/HarmonicFitterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/fitting/HarmonicFitterTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/fitting/HarmonicFitterTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/fitting/HarmonicFitterTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
// 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
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/fitting/PolynomialFitterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/fitting/PolynomialFitterTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/fitting/PolynomialFitterTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/fitting/PolynomialFitterTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
// 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
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java Sat Sep 5 17:36:48 2009
@@ -39,7 +39,7 @@
/**
* <p>Some of the unit tests are re-implementations of the MINPACK <a
* href="http://www.netlib.org/minpack/ex/file17">file17</a> and <a
- * href="http://www.netlib.org/minpack/ex/file22">file22</a> test files.
+ * href="http://www.netlib.org/minpack/ex/file22">file22</a> test files.
* The redistribution policy for MINPACK is available <a
* href="http://www.netlib.org/minpack/disclaimer">here</a>, for
* convenience, it is reproduced below.</p>
@@ -551,8 +551,8 @@
for (int i = 0; i < n; ++i) {
Point2D.Double pi = points.get(i);
double di = pi.distance(center);
- jacobian[i][0] = (center.x - pi.x) / di - dRdX;
- jacobian[i][1] = (center.y - pi.y) / di - dRdY;
+ jacobian[i][0] = (center.x - pi.x) / di - dRdX;
+ jacobian[i][1] = (center.y - pi.y) / di - dRdY;
}
return jacobian;
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java Sat Sep 5 17:36:48 2009
@@ -39,7 +39,7 @@
/**
* <p>Some of the unit tests are re-implementations of the MINPACK <a
* href="http://www.netlib.org/minpack/ex/file17">file17</a> and <a
- * href="http://www.netlib.org/minpack/ex/file22">file22</a> test files.
+ * href="http://www.netlib.org/minpack/ex/file22">file22</a> test files.
* The redistribution policy for MINPACK is available <a
* href="http://www.netlib.org/minpack/disclaimer">here</a>, for
* convenience, it is reproduced below.</p>
@@ -210,7 +210,7 @@
{ 2, 1, 3 },
{ -3, 0, -9 }
}, new double[] { 1, 1, 1 });
-
+
LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1 }, new double[] { 0, 0, 0 });
assertTrue(Math.sqrt(problem.target.length) * optimizer.getRMS() > 0.6);
@@ -590,8 +590,8 @@
for (int i = 0; i < n; ++i) {
Point2D.Double pi = points.get(i);
double di = pi.distance(center);
- jacobian[i][0] = (center.x - pi.x) / di - dRdX;
- jacobian[i][1] = (center.y - pi.y) / di - dRdY;
+ jacobian[i][0] = (center.x - pi.x) / di - dRdX;
+ jacobian[i][1] = (center.y - pi.y) / di - dRdY;
}
return jacobian;