Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/TestMatrixView.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/TestMatrixView.java?rev=1164016&r1=1164015&r2=1164016&view=diff ============================================================================== --- mahout/trunk/math/src/test/java/org/apache/mahout/math/TestMatrixView.java (original) +++ mahout/trunk/math/src/test/java/org/apache/mahout/math/TestMatrixView.java Thu Sep 1 11:29:29 2011 @@ -45,18 +45,16 @@ public final class TestMatrixView extend @Test public void testCardinality() { - int[] c = test.size(); - assertEquals("row cardinality", values.length - 2, c[ROW]); - assertEquals("col cardinality", values[0].length - 1, c[COL]); + assertEquals("row cardinality", values.length - 2, test.rowSize()); + assertEquals("col cardinality", values[0].length - 1, test.columnSize()); } @Test public void testCopy() { - int[] c = test.size(); Matrix copy = test.clone(); assertTrue("wrong class", copy instanceof MatrixView); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', test.getQuick(row, col), copy.getQuick(row, col), EPSILON); } @@ -65,9 +63,8 @@ public final class TestMatrixView extend @Test public void testGetQuick() { - int[] c = test.size(); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', values[row + 1][col + 1], test.getQuick(row, col), EPSILON); } @@ -78,23 +75,22 @@ public final class TestMatrixView extend public void testLike() { Matrix like = test.like(); assertTrue("type", like instanceof DenseMatrix); - assertEquals("rows", test.size()[ROW], like.size()[ROW]); - assertEquals("columns", test.size()[COL], like.size()[COL]); + assertEquals("rows", test.rowSize(), like.rowSize()); + assertEquals("columns", test.columnSize(), like.columnSize()); } @Test public void testLikeIntInt() { Matrix like = test.like(4, 4); assertTrue("type", like instanceof DenseMatrix); - assertEquals("rows", 4, like.size()[ROW]); - assertEquals("columns", 4, like.size()[COL]); + assertEquals("rows", 4, like.rowSize()); + assertEquals("columns", 4, like.columnSize()); } @Test public void testSetQuick() { - int[] c = test.size(); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { test.setQuick(row, col, 1.23); assertEquals("value[" + row + "][" + col + ']', 1.23, test.getQuick( row, col), EPSILON); @@ -105,8 +101,8 @@ public final class TestMatrixView extend @Test public void testSize() { int[] c = test.getNumNondefaultElements(); - assertEquals("row size", values.length - 2, c[ROW]); - assertEquals("col size", values[0].length - 1, c[COL]); + assertEquals("row size", values.length - 2, test.rowSize()); + assertEquals("col size", values[0].length - 1, test.columnSize()); } @Test @@ -114,9 +110,8 @@ public final class TestMatrixView extend int[] offset = {1, 1}; int[] size = {2, 1}; Matrix view = test.viewPart(offset, size); - int[] c = view.size(); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < view.rowSize(); row++) { + for (int col = 0; col < view.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', values[row + 2][col + 2], view.getQuick(row, col), EPSILON); } @@ -146,10 +141,9 @@ public final class TestMatrixView extend @Test public void testAssignDouble() { - int[] c = test.size(); test.assign(4.53); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', 4.53, test.getQuick( row, col), EPSILON); } @@ -158,10 +152,9 @@ public final class TestMatrixView extend @Test public void testAssignDoubleArrayArray() { - int[] c = test.size(); test.assign(new double[3][2]); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', 0.0, test.getQuick(row, col), EPSILON); } @@ -170,16 +163,14 @@ public final class TestMatrixView extend @Test(expected = CardinalityException.class) public void testAssignDoubleArrayArrayCardinality() { - int[] c = test.size(); - test.assign(new double[c[ROW] + 1][c[COL]]); + test.assign(new double[test.rowSize() + 1][test.columnSize()]); } @Test public void testAssignMatrixBinaryFunction() { - int[] c = test.size(); test.assign(test, Functions.PLUS); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', 2 * values[row + 1][col + 1], test.getQuick(row, col), EPSILON); } @@ -193,11 +184,10 @@ public final class TestMatrixView extend @Test public void testAssignMatrix() { - int[] c = test.size(); Matrix value = test.like(); value.assign(test); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', test.getQuick(row, col), value.getQuick(row, col), EPSILON); } @@ -211,10 +201,9 @@ public final class TestMatrixView extend @Test public void testAssignUnaryFunction() { - int[] c = test.size(); test.assign(Functions.NEGATE); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', -values[row + 1][col + 1], test.getQuick(row, col), EPSILON); } @@ -223,10 +212,9 @@ public final class TestMatrixView extend @Test public void testDivide() { - int[] c = test.size(); Matrix value = test.divide(4.53); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', values[row + 1][col + 1] / 4.53, value.getQuick(row, col), EPSILON); } @@ -235,9 +223,8 @@ public final class TestMatrixView extend @Test public void testGet() { - int[] c = test.size(); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', values[row + 1][col + 1], test.get(row, col), EPSILON); } @@ -246,9 +233,8 @@ public final class TestMatrixView extend @Test(expected = IndexException.class) public void testGetIndexUnder() { - int[] c = test.size(); - for (int row = -1; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = -1; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { test.get(row, col); } } @@ -256,9 +242,8 @@ public final class TestMatrixView extend @Test(expected = IndexException.class) public void testGetIndexOver() { - int[] c = test.size(); - for (int row = 0; row < c[ROW] + 1; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize() + 1; row++) { + for (int col = 0; col < test.columnSize(); col++) { test.get(row, col); } } @@ -266,10 +251,9 @@ public final class TestMatrixView extend @Test public void testMinus() { - int[] c = test.size(); Matrix value = test.minus(test); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', 0.0, value.getQuick(row, col), EPSILON); } } @@ -282,10 +266,9 @@ public final class TestMatrixView extend @Test public void testPlusDouble() { - int[] c = test.size(); Matrix value = test.plus(4.53); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', values[row + 1][col + 1] + 4.53, value.getQuick(row, col), EPSILON); } @@ -294,10 +277,9 @@ public final class TestMatrixView extend @Test public void testPlusMatrix() { - int[] c = test.size(); Matrix value = test.plus(test); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', values[row + 1][col + 1] * 2, value.getQuick(row, col), EPSILON); } @@ -311,9 +293,8 @@ public final class TestMatrixView extend @Test(expected = IndexException.class) public void testSetUnder() { - int[] c = test.size(); - for (int row = -1; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = -1; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { test.set(row, col, 1.23); } } @@ -321,9 +302,8 @@ public final class TestMatrixView extend @Test(expected = IndexException.class) public void testSetOver() { - int[] c = test.size(); - for (int row = 0; row < c[ROW] + 1; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize() + 1; row++) { + for (int col = 0; col < test.columnSize(); col++) { test.set(row, col, 1.23); } } @@ -331,10 +311,9 @@ public final class TestMatrixView extend @Test public void testTimesDouble() { - int[] c = test.size(); Matrix value = test.times(4.53); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', values[row + 1][col + 1] * 4.53, value.getQuick(row, col), EPSILON); } @@ -343,12 +322,10 @@ public final class TestMatrixView extend @Test public void testTimesMatrix() { - int[] c = test.size(); Matrix transpose = test.transpose(); Matrix value = test.times(transpose); - int[] v = value.size(); - assertEquals("rows", c[ROW], v[ROW]); - assertEquals("cols", c[ROW], v[COL]); + assertEquals("rows", test.rowSize(), value.rowSize()); + assertEquals("cols", test.rowSize(), value.columnSize()); // TODO: check the math too, lazy } @@ -360,13 +337,11 @@ public final class TestMatrixView extend @Test public void testTranspose() { - int[] c = test.size(); Matrix transpose = test.transpose(); - int[] t = transpose.size(); - assertEquals("rows", c[COL], t[ROW]); - assertEquals("cols", c[ROW], t[COL]); - for (int row = 0; row < c[ROW]; row++) { - for (int col = 0; col < c[COL]; col++) { + assertEquals("rows", test.columnSize(), transpose.rowSize()); + assertEquals("cols", test.rowSize(), transpose.columnSize()); + for (int row = 0; row < test.rowSize(); row++) { + for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', test.getQuick(row, col), transpose.getQuick(col, row), EPSILON); }
Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSparseColumnMatrix.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSparseColumnMatrix.java?rev=1164016&r1=1164015&r2=1164016&view=diff ============================================================================== --- mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSparseColumnMatrix.java (original) +++ mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSparseColumnMatrix.java Thu Sep 1 11:29:29 2011 @@ -21,10 +21,9 @@ public final class TestSparseColumnMatri @Override public Matrix matrixFactory(double[][] values) { - int[] cardinality = {values.length, values[0].length}; - Matrix matrix = new SparseColumnMatrix(cardinality); - for (int row = 0; row < cardinality[ROW]; row++) { - for (int col = 0; col < cardinality[COL]; col++) { + Matrix matrix = new SparseColumnMatrix(values.length, values[0].length); + for (int row = 0; row < matrix.rowSize(); row++) { + for (int col = 0; col < matrix.columnSize(); col++) { matrix.setQuick(row, col, values[row][col]); } } Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSparseMatrix.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSparseMatrix.java?rev=1164016&r1=1164015&r2=1164016&view=diff ============================================================================== --- mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSparseMatrix.java (original) +++ mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSparseMatrix.java Thu Sep 1 11:29:29 2011 @@ -21,10 +21,9 @@ public final class TestSparseMatrix exte @Override public Matrix matrixFactory(double[][] values) { - int[] cardinality = {values.length, values[0].length}; - Matrix matrix = new SparseMatrix(cardinality); - for (int row = 0; row < cardinality[ROW]; row++) { - for (int col = 0; col < cardinality[COL]; col++) { + Matrix matrix = new SparseMatrix(values.length, values[0].length); + for (int row = 0; row < matrix.rowSize(); row++) { + for (int col = 0; col < matrix.columnSize(); col++) { matrix.setQuick(row, col, values[row][col]); } } Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSparseRowMatrix.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSparseRowMatrix.java?rev=1164016&r1=1164015&r2=1164016&view=diff ============================================================================== --- mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSparseRowMatrix.java (original) +++ mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSparseRowMatrix.java Thu Sep 1 11:29:29 2011 @@ -21,10 +21,9 @@ public final class TestSparseRowMatrix e @Override public Matrix matrixFactory(double[][] values) { - int[] cardinality = {values.length, values[0].length}; - Matrix matrix = new SparseRowMatrix(cardinality); - for (int row = 0; row < cardinality[ROW]; row++) { - for (int col = 0; col < cardinality[COL]; col++) { + Matrix matrix = new SparseRowMatrix(values.length, values[0].length); + for (int row = 0; row < matrix.rowSize(); row++) { + for (int col = 0; col < matrix.columnSize(); col++) { matrix.setQuick(row, col, values[row][col]); } } Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/TestVectorView.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/TestVectorView.java?rev=1164016&r1=1164015&r2=1164016&view=diff ============================================================================== --- mahout/trunk/math/src/test/java/org/apache/mahout/math/TestVectorView.java (original) +++ mahout/trunk/math/src/test/java/org/apache/mahout/math/TestVectorView.java Thu Sep 1 11:29:29 2011 @@ -306,10 +306,10 @@ public final class TestVectorView extend @Test public void testCrossProduct() { Matrix result = test.cross(test); - assertEquals("row size", test.size(), result.size()[0]); - assertEquals("col size", test.size(), result.size()[1]); - for (int row = 0; row < result.size()[0]; row++) { - for (int col = 0; col < result.size()[1]; col++) { + assertEquals("row size", test.size(), result.rowSize()); + assertEquals("col size", test.size(), result.columnSize()); + for (int row = 0; row < result.rowSize(); row++) { + for (int col = 0; col < result.columnSize(); col++) { assertEquals("cross[" + row + "][" + col + ']', test.getQuick(row) * test.getQuick(col), result.getQuick(row, col), EPSILON); } Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/als/AlternateLeastSquaresSolverTest.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/als/AlternateLeastSquaresSolverTest.java?rev=1164016&r1=1164015&r2=1164016&view=diff ============================================================================== --- mahout/trunk/math/src/test/java/org/apache/mahout/math/als/AlternateLeastSquaresSolverTest.java (original) +++ mahout/trunk/math/src/test/java/org/apache/mahout/math/als/AlternateLeastSquaresSolverTest.java Thu Sep 1 11:29:29 2011 @@ -42,7 +42,7 @@ public class AlternateLeastSquaresSolver public void addLambdaTimesNuiTimesE() { int nui = 5; double lambda = 0.2; - Matrix matrix = new SparseMatrix(new int[] { 5, 5 }); + Matrix matrix = new SparseMatrix(5, 5); solver.addLambdaTimesNuiTimesE(matrix, lambda, nui); Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/decomposer/SolverTest.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/decomposer/SolverTest.java?rev=1164016&r1=1164015&r2=1164016&view=diff ============================================================================== --- mahout/trunk/math/src/test/java/org/apache/mahout/math/decomposer/SolverTest.java (original) +++ mahout/trunk/math/src/test/java/org/apache/mahout/math/decomposer/SolverTest.java Thu Sep 1 11:29:29 2011 @@ -127,7 +127,7 @@ public abstract class SolverTest extends int numCols, int entriesPerRow, double entryMean) { - Matrix m = new SparseRowMatrix(new int[]{numRows, numCols}); + Matrix m = new SparseRowMatrix(numRows, numCols); //double n = 0; //Random r = RandomUtils.getRandom(); Random r = new Random(1234L);
