sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1521848 - in /sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix: Matrix1.java Matrix2.java Matrix3.java MatrixSIS.java
Date Wed, 11 Sep 2013 13:56:43 GMT
Author: desruisseaux
Date: Wed Sep 11 13:56:43 2013
New Revision: 1521848

URL: http://svn.apache.org/r1521848
Log:
Added get/setElements methods, and javadoc updates.

Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix1.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix2.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix1.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix1.java?rev=1521848&r1=1521847&r2=1521848&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix1.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix1.java
[UTF-8] Wed Sep 11 13:56:43 2013
@@ -24,7 +24,7 @@ import org.apache.sis.internal.util.Nume
  * A matrix of fixed {@value #SIZE}×{@value #SIZE} size.
  * The matrix member is:
  *
- * <blockquote><pre>┌     ┐
+ * <blockquote><pre> ┌     ┐
  * │ {@link #m00} │
  * └     ┘</pre></blockquote>
  *
@@ -142,6 +142,25 @@ public final class Matrix1 extends Matri
     }
 
     /**
+     * Returns all matrix elements in a flat, row-major (column indices vary fastest) array.
+     * The array length is 1.
+     */
+    @Override
+    public double[] getElements() {
+        return new double[] {m00};
+    }
+
+    /**
+     * Sets all matrix elements from a flat, row-major (column indices vary fastest) array.
+     * The array length shall be 1.
+     */
+    @Override
+    public void setElements(final double[] elements) {
+        ensureLengthMatch(SIZE*SIZE, elements);
+        m00 = elements[0];
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix2.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix2.java?rev=1521848&r1=1521847&r2=1521848&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix2.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix2.java
[UTF-8] Wed Sep 11 13:56:43 2013
@@ -24,7 +24,7 @@ import org.apache.sis.internal.util.Nume
  * A matrix of fixed {@value #SIZE}×{@value #SIZE} size.
  * The matrix members are:
  *
- * <blockquote><pre>┌         ┐
+ * <blockquote><pre> ┌         ┐
  * │ {@link #m00} {@link #m01} │
  * │ {@link #m10} {@link #m11} │
  * └         ┘</pre></blockquote>
@@ -89,11 +89,7 @@ public final class Matrix2 extends Matri
      * @throws IllegalArgumentException If the given array does not have the expected length.
      */
     public Matrix2(final double[] elements) throws IllegalArgumentException {
-        ensureLengthMatch(SIZE*SIZE, elements);
-        m00 = elements[0];
-        m01 = elements[1];
-        m10 = elements[2];
-        m11 = elements[3];
+        setElements(elements);
     }
 
     /**
@@ -173,6 +169,28 @@ public final class Matrix2 extends Matri
     }
 
     /**
+     * Returns all matrix elements in a flat, row-major (column indices vary fastest) array.
+     * The array length is 4.
+     */
+    @Override
+    public double[] getElements() {
+        return new double[] {m00, m01, m10, m11};
+    }
+
+    /**
+     * Sets all matrix elements from a flat, row-major (column indices vary fastest) array.
+     * The array length shall be 4.
+     */
+    @Override
+    public void setElements(final double[] elements) {
+        ensureLengthMatch(SIZE*SIZE, elements);
+        m00 = elements[0];
+        m01 = elements[1];
+        m10 = elements[2];
+        m11 = elements[3];
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java?rev=1521848&r1=1521847&r2=1521848&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java
[UTF-8] Wed Sep 11 13:56:43 2013
@@ -26,14 +26,14 @@ import org.apache.sis.math.MathFunctions
  * A matrix of fixed {@value #SIZE}×{@value #SIZE} size.
  * The matrix members are:
  *
- * <blockquote><pre>┌             ┐
+ * <blockquote><pre> ┌             ┐
  * │ {@link #m00} {@link #m01} {@link #m02} │
  * │ {@link #m10} {@link #m11} {@link #m12} │
  * │ {@link #m20} {@link #m21} {@link #m22} │
  * └             ┘</pre></blockquote>
  *
- * This specialized matrix implementation provides better accuracy than generic implementation
- * for some operations.
+ * In some situations, this specialized matrix implementation may provide better accuracy
than the
+ * generic implementation for matrix inversions and multiplications.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4 (derived from geotk-2.2)
@@ -59,15 +59,15 @@ public final class Matrix3 extends Matri
      */
     public static final int SIZE = 3;
 
-     /** The first matrix element in the first row.   */ public double m00;
-     /** The second matrix element in the first row.  */ public double m01;
-     /** The third matrix element in the first row.   */ public double m02;
-     /** The first matrix element in the second row.  */ public double m10;
-     /** The second matrix element in the second row. */ public double m11;
-     /** The third matrix element in the second row.  */ public double m12;
-     /** The first matrix element in the third row.   */ public double m20;
-     /** The second matrix element in the third row.  */ public double m21;
-     /** The third matrix element in the third row.   */ public double m22;
+    /** The first matrix element in the first row.   */ public double m00;
+    /** The second matrix element in the first row.  */ public double m01;
+    /** The third matrix element in the first row.   */ public double m02;
+    /** The first matrix element in the second row.  */ public double m10;
+    /** The second matrix element in the second row. */ public double m11;
+    /** The third matrix element in the second row.  */ public double m12;
+    /** The first matrix element in the third row.   */ public double m20;
+    /** The second matrix element in the third row.  */ public double m21;
+    /** The third matrix element in the third row.   */ public double m22;
 
     /**
      * Creates a new identity matrix.
@@ -112,16 +112,7 @@ public final class Matrix3 extends Matri
      * @throws IllegalArgumentException If the given array does not have the expected length.
      */
     public Matrix3(final double[] elements) throws IllegalArgumentException {
-        ensureLengthMatch(SIZE*SIZE, elements);
-        m00 = elements[0];
-        m01 = elements[1];
-        m02 = elements[2];
-        m10 = elements[3];
-        m11 = elements[4];
-        m12 = elements[5];
-        m20 = elements[6];
-        m21 = elements[7];
-        m22 = elements[8];
+        setElements(elements);
     }
 
     /**
@@ -160,17 +151,6 @@ public final class Matrix3 extends Matri
     }
 
     /**
-     * Returns all elements in a flat, row-major, array.
-     */
-    private double[] getElements() {
-        return new double[] {
-            m00, m01, m02,
-            m10, m11, m12,
-            m20, m21, m22
-        };
-    }
-
-    /**
      * Retrieves the value at the specified row and column of this matrix.
      * This method can be invoked when the matrix size or type is unknown.
      * If the matrix is known to be an instance of {@code Matrix3},
@@ -223,6 +203,37 @@ public final class Matrix3 extends Matri
     }
 
     /**
+     * Returns all matrix elements in a flat, row-major (column indices vary fastest) array.
+     * The array length is 9.
+     */
+    @Override
+    public double[] getElements() {
+        return new double[] {
+            m00, m01, m02,
+            m10, m11, m12,
+            m20, m21, m22
+        };
+    }
+
+    /**
+     * Sets all matrix elements from a flat, row-major (column indices vary fastest) array.
+     * The array length shall be 9.
+     */
+    @Override
+    public void setElements(final double[] elements) {
+        ensureLengthMatch(SIZE*SIZE, elements);
+        m00 = elements[0];
+        m01 = elements[1];
+        m02 = elements[2];
+        m10 = elements[3];
+        m11 = elements[4];
+        m12 = elements[5];
+        m20 = elements[6];
+        m21 = elements[7];
+        m22 = elements[8];
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override
@@ -330,7 +341,7 @@ public final class Matrix3 extends Matri
     }
 
     /**
-     * Returns {@code true} if the specified object is of type {@code Matrix2} and
+     * Returns {@code true} if the specified object is of type {@code Matrix3} and
      * all of the data members are equal to the corresponding data members in this matrix.
      *
      * @param object The object to compare with this matrix for equality.

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java?rev=1521848&r1=1521847&r2=1521848&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
(original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
Wed Sep 11 13:56:43 2013
@@ -90,6 +90,23 @@ public abstract class MatrixSIS implemen
     }
 
     /**
+     * Returns all matrix elements in a flat, row-major (column indices vary fastest) array.
+     * The array length is <code>{@linkplain #getNumRow()} * {@linkplain #getNumCol()}</code>.
+     *
+     * @return The current matrix elements in a row-major array.
+     */
+    public abstract double[] getElements();
+
+    /**
+     * Sets all matrix elements from a flat, row-major (column indices vary fastest) array.
+     * The array length shall be <code>{@linkplain #getNumRow()} * {@linkplain #getNumCol()}</code>.
+     *
+     * @param elements The new matrix elements in a row-major array.
+     * @throws IllegalArgumentException If the given array does not have the expected length.
+     */
+    public abstract void setElements(final double[] elements);
+
+    /**
      * Returns {@code true} if this matrix represents an affine transform.
      * A transform is affine if the matrix is square and its last row contains
      * only zeros, except in the last column which contains 1.



Mime
View raw message