sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1522609 - in /sis/branches/JDK7/core/sis-referencing/src: main/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrix.java test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
Date Thu, 12 Sep 2013 15:02:44 GMT
Author: desruisseaux
Date: Thu Sep 12 15:02:43 2013
New Revision: 1522609

URL: http://svn.apache.org/r1522609
Log:
Added a test case for the transpose operation, and a bug fix.

Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrix.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrix.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrix.java?rev=1522609&r1=1522608&r2=1522609&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrix.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrix.java
[UTF-8] Thu Sep 12 15:02:43 2013
@@ -89,7 +89,7 @@ final class NonSquareMatrix extends Gene
         int k = 0;
         for (int j=0; j<numRow; j++) {
             for (int i=0; i<numCol; i++) {
-                elements[i*numCol + j] = copy[k++];
+                elements[i*numRow + j] = copy[k++];
             }
         }
         this.numRow = numCol;

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java?rev=1522609&r1=1522608&r2=1522609&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
[UTF-8] Thu Sep 12 15:02:43 2013
@@ -187,4 +187,23 @@ public abstract strictfp class MatrixTes
         assertEquals("isAffine",   numRow == numCol, matrix.isAffine());
         assertEquals("isIdentity", numRow == numCol, matrix.isIdentity());
     }
+
+    /**
+     * Tests {@link MatrixSIS#transpose()}.
+     */
+    @Test
+    @DependsOnMethod("testGetElements")
+    public void testTranspose() {
+        final int numRow = getNumRow();
+        final int numCol = getNumCol();
+        final double[] elements = createRandomElements(numRow * numCol);
+        final MatrixSIS matrix = Matrices.create(numRow, numCol, elements);
+        validate(matrix);
+        /*
+         * The JAMA constructor uses column-major array (FORTRAN convention) while SIS uses
row-major
+         * array. In other words, the JAMA matrix is already transposed from the SIS point
of view.
+         */
+        matrix.transpose();
+        assertMatrixEquals(new Matrix(elements, numCol), matrix, STRICT);
+    }
 }



Mime
View raw message