Index: lutinmatrix/src/test/org/codelutin/math/matrix/MatrixNDTest.java diff -u lutinmatrix/src/test/org/codelutin/math/matrix/MatrixNDTest.java:1.8 lutinmatrix/src/test/org/codelutin/math/matrix/MatrixNDTest.java:1.9 --- lutinmatrix/src/test/org/codelutin/math/matrix/MatrixNDTest.java:1.8 Mon Aug 28 11:41:20 2006 +++ lutinmatrix/src/test/org/codelutin/math/matrix/MatrixNDTest.java Mon Apr 2 10:51:44 2007 @@ -21,9 +21,9 @@ * * Created: 10 mai 2004 * -* @version $Revision: 1.8 $ +* @version $Revision: 1.9 $ * -* Mise a jour: $Date: 2006/08/28 11:41:20 $ +* Mise a jour: $Date: 2007/04/02 10:51:44 $ * par : $Author: bpoussin $ */ @@ -417,6 +417,36 @@ assertEquals(3, mat1.getValue(5,2,6), 0); } + public void testSumOverDim() throws Exception { + + MatrixND mat = null; + + mat = getFactory().create(new int[]{6, 7}); + MatrixND result = getFactory().create(new int[]{3, 7}); + + MatrixHelper.fill(mat, 3); + + MatrixND sub = mat.getSubMatrix(0, 0, 1); + result.paste(new int[]{0,0}, sub.sumOverDim(0)); + + sub = mat.getSubMatrix(0, 1, 3); + result.paste(new int[]{1,0}, sub.sumOverDim(0)); + + sub = mat.getSubMatrix(0, 4, 2); + result.paste(new int[]{2,0}, sub.sumOverDim(0)); + + mat = getFactory().create(new int[]{6, 7}); + MatrixHelper.fill(mat, 3); + + + + mat = mat.sumOverDim(0, 0, 1); + mat = mat.sumOverDim(0, 1, 3); + mat = mat.sumOverDim(0, 2, 2); + + assertTrue(result.equalsValues(mat)); + } + public void testReduce() throws Exception { MatrixND mat = null; @@ -659,5 +689,7 @@ } return result; } + + }