sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1766500 [1/2] - in /sis/branches/JDK8/core: sis-referencing/src/main/java/org/apache/sis/referencing/cs/ sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/ sis-referencing/src/test/java/org/apache/sis/referencing/op...
Date Tue, 25 Oct 2016 10:22:16 GMT
Author: desruisseaux
Date: Tue Oct 25 10:22:16 2016
New Revision: 1766500

URL: http://svn.apache.org/viewvc?rev=1766500&view=rev
Log:
Use extended precision for the matrix computed by CoordinateSystems.swapAndScaleAxes(...).

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/AffineTransforms2DTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/GeneralMatrixTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatricesTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix2Test.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix4Test.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/SolverTest.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java?rev=1766500&r1=1766499&r2=1766500&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java [UTF-8] Tue Oct 25 10:22:16 2016
@@ -31,6 +31,7 @@ import org.apache.sis.measure.Units;
 import org.apache.sis.util.Static;
 import org.apache.sis.util.Classes;
 import org.apache.sis.util.CharSequences;
+import org.apache.sis.internal.util.DoubleDouble;
 import org.apache.sis.internal.metadata.AxisDirections;
 import org.apache.sis.internal.referencing.Resources;
 import org.apache.sis.referencing.operation.matrix.Matrices;
@@ -310,8 +311,7 @@ public final class CoordinateSystems ext
         for (int j=0; j<targetDim; j++) {
             final Unit<?> targetUnit = targetCS.getAxis(j).getUnit();
             for (int i=0; i<sourceDim; i++) {
-                final double element = matrix.getElement(j,i);
-                if (element == 0) {
+                if (matrix.getElement(j,i) == 0) {
                     // There is no dependency between source[i] and target[j]
                     // (i.e. axes are orthogonal).
                     continue;
@@ -322,18 +322,24 @@ public final class CoordinateSystems ext
                     // between source[i] and target[j].
                     continue;
                 }
-                double scale  = 1;
-                double offset = 0;
+                Number scale  = 1;
+                Number offset = 0;
                 final Number[] coefficients = Units.coefficients(sourceUnit.getConverterToAny(targetUnit));
                 switch (coefficients != null ? coefficients.length : -1) {
-                    case 2:  scale  = coefficients[1].doubleValue();       // Fall through
-                    case 1:  offset = coefficients[0].doubleValue();       // Fall through
+                    case 2:  scale  = coefficients[1];       // Fall through
+                    case 1:  offset = coefficients[0];       // Fall through
                     case 0:  break;
                     default: throw new IncommensurableException(Resources.format(
                                 Resources.Keys.NonLinearUnitConversion_2, sourceUnit, targetUnit));
                 }
-                matrix.setElement(j, i, element*scale);
-                matrix.setElement(j, sourceDim, matrix.getElement(j, sourceDim) + element*offset);
+                final DoubleDouble element = DoubleDouble.castOrCopy(matrix.getNumber(j,i));
+                final DoubleDouble r = new DoubleDouble(element);
+                r.multiply(scale);
+                matrix.setNumber(j, i, r);
+                r.setFrom(element);
+                r.multiply(offset);
+                r.add(matrix.getNumber(j, sourceDim));
+                matrix.setNumber(j, sourceDim, r);
             }
         }
         return matrix;

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java?rev=1766500&r1=1766499&r2=1766500&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java [UTF-8] Tue Oct 25 10:22:16 2016
@@ -36,7 +36,7 @@ import org.apache.sis.internal.referenci
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.7
+ * @version 0.8
  * @module
  *
  * @see Matrices#createDiagonal(int, int)
@@ -89,12 +89,12 @@ class GeneralMatrix extends MatrixSIS im
      * If {@code setToIdentity} is {@code true}, then the elements
      * on the diagonal (<var>j</var> == <var>i</var>) are set to 1.
      *
-     * @param numRow Number of rows.
-     * @param numCol Number of columns.
-     * @param setToIdentity {@code true} for initializing the matrix to the identity matrix,
-     *        or {@code false} for leaving it initialized to zero.
-     * @param precision 1 for normal precision, or 2 for extended precision.
-     *        No other value is allowed (this is not verified).
+     * @param  numRow         number of rows.
+     * @param  numCol         number of columns.
+     * @param  setToIdentity  {@code true} for initializing the matrix to the identity matrix,
+     *                        or {@code false} for leaving it initialized to zero.
+     * @param  precision      1 for normal precision, or 2 for extended precision.
+     *                        No other value is allowed (this is not verified).
      */
     GeneralMatrix(final int numRow, final int numCol, final boolean setToIdentity, final int precision) {
         ensureValidSize(numRow, numCol);
@@ -114,9 +114,9 @@ class GeneralMatrix extends MatrixSIS im
      * The array values are copied in one row at a time in row major fashion.
      * The array shall be exactly {@code numRow*numCol} in length.
      *
-     * @param numRow Number of rows.
-     * @param numCol Number of columns.
-     * @param elements Initial values.
+     * @param  numRow    number of rows.
+     * @param  numCol    number of columns.
+     * @param  elements  initial values.
      */
     GeneralMatrix(final int numRow, final int numCol, final double[] elements) {
         ensureValidSize(numRow, numCol);
@@ -129,7 +129,7 @@ class GeneralMatrix extends MatrixSIS im
     /**
      * Constructs a new matrix and copies the initial values from the given matrix.
      *
-     * @param matrix The matrix to copy.
+     * @param  matrix  the matrix to copy.
      */
     GeneralMatrix(final Matrix matrix) {
         final int numRow = matrix.getNumRow();
@@ -158,10 +158,10 @@ class GeneralMatrix extends MatrixSIS im
     /**
      * Creates a new extended precision matrix of the given size.
      *
-     * @param numRow Number of rows.
-     * @param numCol Number of columns.
-     * @param setToIdentity {@code true} for initializing the matrix to the identity matrix,
-     *        or {@code false} for leaving it initialized to zero.
+     * @param  numRow         number of rows.
+     * @param  numCol         number of columns.
+     * @param  setToIdentity  {@code true} for initializing the matrix to the identity matrix,
+     *                        or {@code false} for leaving it initialized to zero.
      */
     static GeneralMatrix createExtendedPrecision(final int numRow, final int numCol, final boolean setToIdentity) {
         if (numRow == numCol) {
@@ -262,9 +262,9 @@ class GeneralMatrix extends MatrixSIS im
      * Retrieves the value at the specified row and column of this matrix, wrapped in a {@code Number}
      * or a {@link DoubleDouble} depending on available precision.
      *
-     * @param row    The row index, from 0 inclusive to {@link #getNumRow()} exclusive.
-     * @param column The column index, from 0 inclusive to {@link #getNumCol()} exclusive.
-     * @return       The current value at the given row and column.
+     * @param  row     the row index, from 0 inclusive to {@link #getNumRow()} exclusive.
+     * @param  column  the column index, from 0 inclusive to {@link #getNumCol()} exclusive.
+     * @return the current value at the given row and column.
      */
     @Override
     public Number getNumber(int row, int column) {
@@ -285,9 +285,9 @@ class GeneralMatrix extends MatrixSIS im
     /**
      * Retrieves the value at the specified row and column of this matrix.
      *
-     * @param row    The row index, from 0 inclusive to {@link #getNumRow()} exclusive.
-     * @param column The column index, from 0 inclusive to {@link #getNumCol()} exclusive.
-     * @return       The current value at the given row and column.
+     * @param  row     the row index, from 0 inclusive to {@link #getNumRow()} exclusive.
+     * @param  column  the column index, from 0 inclusive to {@link #getNumCol()} exclusive.
+     * @return the current value at the given row and column.
      */
     @Override
     public final double getElement(final int row, final int column) {
@@ -301,9 +301,9 @@ class GeneralMatrix extends MatrixSIS im
     /**
      * Modifies the value at the specified row and column of this matrix.
      *
-     * @param row    The row index, from 0 inclusive to {@link #getNumRow() } exclusive.
-     * @param column The column index, from 0 inclusive to {@link #getNumCol()} exclusive.
-     * @param value  The new value to set at the given row and column.
+     * @param  row     the row index, from 0 inclusive to {@link #getNumRow() } exclusive.
+     * @param  column  the column index, from 0 inclusive to {@link #getNumCol()} exclusive.
+     * @param  value   the new value to set at the given row and column.
      */
     @Override
     public final void setElement(final int row, final int column, final double value) {
@@ -326,7 +326,7 @@ class GeneralMatrix extends MatrixSIS im
      * <p>This method may return a direct reference to the internal array. <strong>Do not modify.</strong>,
      * unless the {@code copy} argument is {@code true}.</p>
      *
-     * @param copy If {@code true}, then the returned array is guaranteed to be a copy, never the internal array.
+     * @param  copy  if {@code true}, then the returned array is guaranteed to be a copy, never the internal array.
      */
     static double[] getExtendedElements(final Matrix matrix, final int numRow, final int numCol, final boolean copy) {
         double[] elements;
@@ -406,11 +406,11 @@ class GeneralMatrix extends MatrixSIS im
      *       may have any values.</li>
      * </ul>
      *
-     * @param  elements The new matrix elements in a row-major array.
+     * @param  elements  the new matrix elements in a row-major array.
      * @return {@code true} if at leat one {@link DoubleDouble} instance has been found, in which case all
      *         errors terms have been initialized, or {@code false} otherwise, in which case no error term
      *         has been initialized (this is a <cite>all or nothing</cite> operation).
-     * @throws IllegalArgumentException If the given array does not have the expected length.
+     * @throws IllegalArgumentException if the given array does not have the expected length.
      *
      * @see Matrices#create(int, int, Number[])
      */
@@ -424,7 +424,10 @@ class GeneralMatrix extends MatrixSIS im
         }
         boolean isExtended = false;
         for (int i=0; i<length; i++) {
-            final Number value = newValues[i];
+            Number value = newValues[i];
+            if (DoubleDouble.shouldConvert(value)) {
+                value = new DoubleDouble(value);
+            }
             final double element = value.doubleValue();
             elements[i] = element;
             final double error;
@@ -461,7 +464,7 @@ class GeneralMatrix extends MatrixSIS im
      * Sets this matrix to the values of another matrix. This method overrides the default implementation with a more
      * efficient implementation in the particular case where the other matrix is an instance of {@code GeneralMatrix}.
      *
-     * @param matrix  The matrix to copy.
+     * @param  matrix  the matrix to copy.
      * @throws MismatchedMatrixSizeException if the given matrix has a different size than this matrix.
      *
      * @since 0.7
@@ -500,7 +503,7 @@ class GeneralMatrix extends MatrixSIS im
     /**
      * Implementation of {@link #isAffine()} with control on whether we require the matrix to be square.
      *
-     * @param square {@code true} if the matrix must be square, or {@code false} for allowing non-square matrices.
+     * @param  square  {@code true} if the matrix must be square, or {@code false} for allowing non-square matrices.
      */
     final boolean isAffine(final boolean square) {
         final int numRow = this.numRow;                     // Protection against accidental changes.
@@ -540,7 +543,7 @@ class GeneralMatrix extends MatrixSIS im
         if (numRow != numCol) {
             return false;
         }
-        int di = 0; // Index of next diagonal element.
+        int di = 0;                                         // Index of next diagonal element.
         final int length = numRow * numCol;
         for (int i=0; i<length; i++) {
             final double element = elements[i];
@@ -630,7 +633,7 @@ class GeneralMatrix extends MatrixSIS im
      * Returns {@code true} if the specified object is of type {@code GeneralMatrix} 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.
+     * @param  object  the object to compare with this matrix for equality.
      * @return {@code true} if the given object is equal to this matrix.
      */
     @Override

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java?rev=1766500&r1=1766499&r2=1766500&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java [UTF-8] Tue Oct 25 10:22:16 2016
@@ -122,9 +122,9 @@ public final class Matrices extends Stat
      * {@value org.apache.sis.referencing.operation.matrix.Matrix4#SIZE} inclusive, the matrix
      * is guaranteed to be an instance of one of {@link Matrix1} … {@link Matrix4} subtypes.</div>
      *
-     * @param numRow For a math transform, this is the number of {@linkplain MathTransform#getTargetDimensions() target dimensions} + 1.
-     * @param numCol For a math transform, this is the number of {@linkplain MathTransform#getSourceDimensions() source dimensions} + 1.
-     * @return An identity matrix of the given size.
+     * @param  numRow  for a math transform, this is the number of {@linkplain MathTransform#getTargetDimensions() target dimensions} + 1.
+     * @param  numCol  for a math transform, this is the number of {@linkplain MathTransform#getSourceDimensions() source dimensions} + 1.
+     * @return an identity matrix of the given size.
      */
     public static MatrixSIS createDiagonal(final int numRow, final int numCol) {
         if (numRow == numCol) {
@@ -144,9 +144,9 @@ public final class Matrices extends Stat
      * {@value org.apache.sis.referencing.operation.matrix.Matrix4#SIZE} inclusive, the matrix
      * is guaranteed to be an instance of one of {@link Matrix1} … {@link Matrix4} subtypes.</div>
      *
-     * @param numRow For a math transform, this is the number of {@linkplain MathTransform#getTargetDimensions() target dimensions} + 1.
-     * @param numCol For a math transform, this is the number of {@linkplain MathTransform#getSourceDimensions() source dimensions} + 1.
-     * @return A matrix of the given size with only zero values.
+     * @param  numRow  for a math transform, this is the number of {@linkplain MathTransform#getTargetDimensions() target dimensions} + 1.
+     * @param  numCol  for a math transform, this is the number of {@linkplain MathTransform#getSourceDimensions() source dimensions} + 1.
+     * @return a matrix of the given size with only zero values.
      */
     public static MatrixSIS createZero(final int numRow, final int numCol) {
         if (numRow == numCol) switch (numRow) {
@@ -176,10 +176,10 @@ public final class Matrices extends Stat
      * {@value org.apache.sis.referencing.operation.matrix.Matrix4#SIZE} inclusive, the matrix
      * is guaranteed to be an instance of one of {@link Matrix1} … {@link Matrix4} subtypes.</div>
      *
-     * @param  numRow   Number of rows.
-     * @param  numCol   Number of columns.
-     * @param  elements The matrix elements in a row-major array. Column indices vary fastest.
-     * @return A matrix initialized to the given elements.
+     * @param  numRow    number of rows.
+     * @param  numCol    number of columns.
+     * @param  elements  the matrix elements in a row-major array. Column indices vary fastest.
+     * @return a matrix initialized to the given elements.
      *
      * @see MatrixSIS#setElements(double[])
      */
@@ -198,10 +198,10 @@ public final class Matrices extends Stat
      * Creates a matrix of size {@code numRow} × {@code numCol} initialized to the given numbers.
      * The elements array size must be equals to {@code numRow*numCol}. Column indices vary fastest.
      *
-     * @param  numRow   Number of rows.
-     * @param  numCol   Number of columns.
-     * @param  elements The matrix elements in a row-major array. Column indices vary fastest.
-     * @return A matrix initialized to the given elements.
+     * @param  numRow    number of rows.
+     * @param  numCol    number of columns.
+     * @param  elements  the matrix elements in a row-major array. Column indices vary fastest.
+     * @return a matrix initialized to the given elements.
      */
     public static MatrixSIS create(final int numRow, final int numCol, final Number[] elements) {
         ArgumentChecks.ensureNonNull("elements", elements);
@@ -240,7 +240,12 @@ public final class Matrices extends Stat
         } else {
             dstCorner = srcCorner = srcOppositeCorner = null;
         }
-        final MatrixSIS matrix = createZero(dstAxes.length+1, srcAxes.length+1);
+        /*
+         * Unconditionally create extended precision matrix even if standard precision would be
+         * enough because callers in other package may perform additional arithmetic operations
+         * on it (for example org.apache.sis.referencing.cs.CoordinateSystems.swapAndScaleAxes).
+         */
+        final MatrixSIS matrix = new GeneralMatrix(dstAxes.length+1, srcAxes.length+1, false, 2);
         /*
          * Maps source axes to destination axes. If no axis is moved (for example if the user
          * want to transform (NORTH,EAST) to (SOUTH,EAST)), then source and destination index
@@ -265,18 +270,23 @@ public final class Matrices extends Stat
                      * They will be left to zero, which is their desired value.
                      */
                     final boolean same = srcDir.equals(dstDir);
-                    double scale = same ? +1 : -1;
-                    double translate = 0;
                     if (useEnvelopes) {
                         // See the comment in transform(Envelope, Envelope) for an explanation about why
                         // we use the lower/upper corners instead than getMinimum()/getMaximum() methods.
-                        translate  = dstCorner.getOrdinate(dstIndex);
-                        scale     *= dstEnvelope.getSpan(dstIndex) /
-                                     srcEnvelope.getSpan(srcIndex);
-                        translate -= scale * (same ? srcCorner : srcOppositeCorner).getOrdinate(srcIndex);
+                        final DoubleDouble scale = new DoubleDouble(same ? +1 : -1, 0);
+                        scale.multiply(dstEnvelope.getSpan(dstIndex));
+                        scale.divide  (srcEnvelope.getSpan(srcIndex));
+
+                        final DoubleDouble translate = new DoubleDouble(scale);
+                        translate.multiply((same ? srcCorner : srcOppositeCorner).getOrdinate(srcIndex));
+                        translate.negate();
+                        translate.add(dstCorner.getOrdinate(dstIndex));
+
+                        matrix.setNumber(dstIndex, srcIndex,       scale);
+                        matrix.setNumber(dstIndex, srcAxes.length, translate);
+                    } else {
+                        matrix.setElement(dstIndex, srcIndex, same ? +1 : -1);
                     }
-                    matrix.setElement(dstIndex, srcIndex,       scale);
-                    matrix.setElement(dstIndex, srcAxes.length, translate);
                 }
             }
             if (!hasFound) {
@@ -332,9 +342,9 @@ public final class Matrices extends Stat
      *   └     ┘   └              ┘   └     ┘
      * }
      *
-     * @param  srcEnvelope The source envelope.
-     * @param  dstEnvelope The destination envelope.
-     * @return The transform from the given source envelope to target envelope.
+     * @param  srcEnvelope  the source envelope.
+     * @param  dstEnvelope  the destination envelope.
+     * @return the transform from the given source envelope to target envelope.
      *
      * @see #createTransform(AxisDirection[], AxisDirection[])
      * @see #createTransform(Envelope, AxisDirection[], Envelope, AxisDirection[])
@@ -409,10 +419,10 @@ public final class Matrices extends Stat
      *   └    ┘   └         ┘   └    ┘
      * }
      *
-     * @param  srcAxes The ordered sequence of axis directions for source coordinate system.
-     * @param  dstAxes The ordered sequence of axis directions for destination coordinate system.
-     * @return The transform from the given source axis directions to the given target axis directions.
-     * @throws IllegalArgumentException If {@code dstAxes} contains at least one axis not found in {@code srcAxes},
+     * @param  srcAxes  the ordered sequence of axis directions for source coordinate system.
+     * @param  dstAxes  the ordered sequence of axis directions for destination coordinate system.
+     * @return the transform from the given source axis directions to the given target axis directions.
+     * @throws IllegalArgumentException if {@code dstAxes} contains at least one axis not found in {@code srcAxes},
      *         or if some colinear axes were found.
      *
      * @see #createTransform(Envelope, Envelope)
@@ -469,15 +479,15 @@ public final class Matrices extends Stat
      * }
      * </div>
      *
-     * @param  srcEnvelope The source envelope.
-     * @param  srcAxes     The ordered sequence of axis directions for source coordinate system.
-     * @param  dstEnvelope The destination envelope.
-     * @param  dstAxes     The ordered sequence of axis directions for destination coordinate system.
-     * @return The transform from the given source envelope and axis directions
+     * @param  srcEnvelope  the source envelope.
+     * @param  srcAxes      the ordered sequence of axis directions for source coordinate system.
+     * @param  dstEnvelope  the destination envelope.
+     * @param  dstAxes      the ordered sequence of axis directions for destination coordinate system.
+     * @return the transform from the given source envelope and axis directions
      *         to the given envelope and target axis directions.
-     * @throws MismatchedDimensionException If an envelope {@linkplain Envelope#getDimension() dimension} does not
+     * @throws MismatchedDimensionException if an envelope {@linkplain Envelope#getDimension() dimension} does not
      *         match the length of the axis directions sequence.
-     * @throws IllegalArgumentException If {@code dstAxes} contains at least one axis not found in {@code srcAxes},
+     * @throws IllegalArgumentException if {@code dstAxes} contains at least one axis not found in {@code srcAxes},
      *         or if some colinear axes were found.
      *
      * @see #createTransform(Envelope, Envelope)
@@ -531,8 +541,8 @@ public final class Matrices extends Stat
      * The inverse of the matrix created by this method will put {@link Double#NaN} values in the extra dimensions.
      * Other dimensions will work as expected.
      *
-     * @param  sourceDimensions The number of dimensions in source coordinates.
-     * @param  selectedDimensions The 0-based indices of source ordinate values to keep.
+     * @param  sourceDimensions    the number of dimensions in source coordinates.
+     * @param  selectedDimensions  the 0-based indices of source ordinate values to keep.
      *         The length of this array will be the number of dimensions in target coordinates.
      * @return An affine transform matrix keeping only the given source dimensions, and discarding all others.
      * @throws IllegalArgumentException if a value of {@code selectedDimensions} is lower than 0
@@ -607,10 +617,10 @@ public final class Matrices extends Stat
      * }
      * </div>
      *
-     * @param  firstAffectedOrdinate The lowest index of the affected ordinates.
-     * @param  subMatrix The matrix to use for affected ordinates.
-     * @param  numTrailingOrdinates Number of trailing ordinates to pass through.
-     * @return A matrix for the same transform than the given matrix,
+     * @param  firstAffectedOrdinate  the lowest index of the affected ordinates.
+     * @param  subMatrix              the matrix to use for affected ordinates.
+     * @param  numTrailingOrdinates   number of trailing ordinates to pass through.
+     * @return a matrix for the same transform than the given matrix,
      *         augmented with leading and trailing pass-through coordinates.
      *
      * @see org.apache.sis.referencing.operation.DefaultMathTransformFactory#createPassThroughTransform(int, MathTransform, int)
@@ -761,8 +771,8 @@ public final class Matrices extends Stat
      * and {@value org.apache.sis.referencing.operation.matrix.Matrix4#SIZE} inclusive, the returned matrix is
      * usually an instance of one of {@link Matrix1} … {@link Matrix4} subtypes.</div>
      *
-     * @param matrix The matrix to copy, or {@code null}.
-     * @return A copy of the given matrix, or {@code null} if the given matrix was null.
+     * @param  matrix  the matrix to copy, or {@code null}.
+     * @return a copy of the given matrix, or {@code null} if the given matrix was null.
      *
      * @see MatrixSIS#clone()
      * @see MatrixSIS#castOrCopy(Matrix)
@@ -790,8 +800,8 @@ public final class Matrices extends Stat
      * Returns an unmodifiable view of the given matrix. The returned matrix is immutable
      * only if the given {@code matrix} is not modified anymore after this method call.
      *
-     * @param matrix The matrix for which to get an unmodifiable view, or {@code null}.
-     * @return A unmodifiable view of the given matrix, or {@code null} if the given matrix was null.
+     * @param  matrix  the matrix for which to get an unmodifiable view, or {@code null}.
+     * @return a unmodifiable view of the given matrix, or {@code null} if the given matrix was null.
      *
      * @since 0.6
      */
@@ -807,9 +817,9 @@ public final class Matrices extends Stat
      * Returns a new matrix which is the result of multiplying the first matrix with the second one.
      * In other words, returns {@code m1} × {@code m2}.
      *
-     * @param  m1 The first matrix to multiply.
-     * @param  m2 The second matrix to multiply.
-     * @return The result of {@code m1} × {@code m2}.
+     * @param  m1  the first matrix to multiply.
+     * @param  m2  the second matrix to multiply.
+     * @return the result of {@code m1} × {@code m2}.
      * @throws MismatchedMatrixSizeException if the number of columns in {@code m1} is not equals to the
      *         number of rows in {@code m2}.
      *
@@ -831,8 +841,8 @@ public final class Matrices extends Stat
     /**
      * Returns the inverse of the given matrix.
      *
-     * @param  matrix The matrix to inverse, or {@code null}.
-     * @return The inverse of this matrix, or {@code null} if the given matrix was null.
+     * @param  matrix  the matrix to inverse, or {@code null}.
+     * @return the inverse of this matrix, or {@code null} if the given matrix was null.
      * @throws NoninvertibleMatrixException if the given matrix is not invertible.
      *
      * @see MatrixSIS#inverse()
@@ -856,7 +866,7 @@ public final class Matrices extends Stat
      * A transform is affine if the matrix is square and its last row contains
      * only zeros, except in the last column which contains 1.
      *
-     * @param matrix The matrix to test.
+     * @param  matrix  the matrix to test.
      * @return {@code true} if the matrix represents an affine transform.
      *
      * @see MatrixSIS#isAffine()
@@ -874,7 +884,7 @@ public final class Matrices extends Stat
      * This method returns {@code true} if the given matrix {@linkplain #isAffine(Matrix) is affine}
      * and differs from the identity matrix only in the last column.
      *
-     * @param matrix The matrix to test.
+     * @param  matrix  the matrix to test.
      * @return {@code true} if the matrix represents a translation.
      *
      * @since 0.7
@@ -906,8 +916,8 @@ public final class Matrices extends Stat
      * errors. In case of doubt, it is often safer to use the strict {@link MatrixSIS#isIdentity()} method instead
      * than this one.</p>
      *
-     * @param  matrix The matrix to test for identity.
-     * @param  tolerance The tolerance value, or 0 for a strict comparison.
+     * @param  matrix     the matrix to test for identity.
+     * @param  tolerance  the tolerance value, or 0 for a strict comparison.
      * @return {@code true} if this matrix is close to the identity matrix given the tolerance threshold.
      *
      * @see MatrixSIS#isIdentity()
@@ -924,7 +934,7 @@ public final class Matrices extends Stat
                 if (i == j) {
                     e--;
                 }
-                if (!(Math.abs(e) <= tolerance)) {  // Uses '!' in order to catch NaN values.
+                if (!(Math.abs(e) <= tolerance)) {              // Uses '!' in order to catch NaN values.
                     return false;
                 }
             }
@@ -947,13 +957,13 @@ public final class Matrices extends Stat
      * and <var>v2</var><sub>j,i</sub> to compare, the tolerance threshold is scaled by
      * {@code max(abs(v1), abs(v2))}. Otherwise the threshold is used as-is.
      *
-     * @param  m1       The first matrix to compare, or {@code null}.
-     * @param  m2       The second matrix to compare, or {@code null}.
-     * @param  epsilon  The tolerance value.
-     * @param  relative If {@code true}, then the tolerance value is relative to the magnitude
-     *         of the matrix elements being compared.
-     * @return {@code true} if the values of the two matrix do not differ by a quantity
-     *         greater than the given tolerance threshold.
+     * @param  m1        the first matrix to compare, or {@code null}.
+     * @param  m2        the second matrix to compare, or {@code null}.
+     * @param  epsilon   the tolerance value.
+     * @param  relative  if {@code true}, then the tolerance value is relative to the magnitude
+     *                   of the matrix elements being compared.
+     * @return {@code true} if the values of the two matrix do not differ by a quantity greater
+     *         than the given tolerance threshold.
      *
      * @see MatrixSIS#equals(Matrix, double)
      */
@@ -1010,9 +1020,9 @@ public final class Matrices extends Stat
      *       For more control, use {@link #equals(Matrix, Matrix, double, boolean)} instead.</li>
      * </ul>
      *
-     * @param  m1  The first matrix to compare, or {@code null}.
-     * @param  m2  The second matrix to compare, or {@code null}.
-     * @param  mode The strictness level of the comparison.
+     * @param  m1    the first matrix to compare, or {@code null}.
+     * @param  m2    the second matrix to compare, or {@code null}.
+     * @param  mode  the strictness level of the comparison.
      * @return {@code true} if both matrices are equal.
      *
      * @see MatrixSIS#equals(Object, ComparisonMode)
@@ -1059,8 +1069,8 @@ public final class Matrices extends Stat
      * reference system. In addition, the last column is often a translation vector having a magnitude very
      * different than the other columns.</div>
      *
-     * @param  matrix The matrix for which to get a string representation.
-     * @return A string representation of the given matrix.
+     * @param  matrix  the matrix for which to get a string representation.
+     * @return a string representation of the given matrix.
      */
     public static String toString(final Matrix matrix) {
         final int numRow = matrix.getNumRow();
@@ -1077,7 +1087,7 @@ public final class Matrices extends Stat
          * Create now the string representation of all matrix elements and measure the width
          * of the integer field and the fraction field, then the total width of each column.
          */
-        int spacing = 1; // Spacing is 1 before the first column only, then SPACING for other columns.
+        int spacing = 1;                // Spacing is 1 before the first column only, then SPACING for other columns.
         for (int i=0; i<numCol; i++) {
             for (int j=0; j<numRow; j++) {
                 final int flatIndex = j*numCol + i;
@@ -1091,7 +1101,7 @@ public final class Matrices extends Stat
                  */
                 if (value == -1 || value == 0 || value == +1) {
                     noFractionDigits[flatIndex] = true;
-                    width = spacing + element.length() - 2; // The -2 is for ignoring the trailing ".0"
+                    width = spacing + element.length() - 2;           // The -2 is for ignoring the trailing ".0"
                     widthBeforeFraction[i] = (byte) Math.max(widthBeforeFraction[i], width);
                 } else {
                     /*
@@ -1128,7 +1138,7 @@ public final class Matrices extends Stat
                 elements[flatIndex] = element;
             }
             totalWidth += columnWidth[i];
-            spacing = SPACING; // Specing before all columns after the first one.
+            spacing = SPACING;                              // Spacing before all columns after the first one.
         }
         /*
          * Now append the formatted elements with the appropriate amount of spaces before each value,
@@ -1147,9 +1157,9 @@ public final class Matrices extends Stat
                 int spaces, s = element.lastIndexOf('.');
                 if (s >= 0) {
                     if (hasDecimalSeparator[i]) s++;
-                    spaces = widthBeforeFraction[i] - s; // Number of spaces for alignment on the decimal separator
+                    spaces = widthBeforeFraction[i] - s;    // Number of spaces for alignment on the decimal separator
                 } else {
-                    spaces = columnWidth[i] - width; // Number of spaces for right alignment (NaN or ∞ cases)
+                    spaces = columnWidth[i] - width;        // Number of spaces for right alignment (NaN or ∞ cases)
                 }
                 buffer.append(CharSequences.spaces(spaces)).append(element);
                 if (s >= 0) {
@@ -1159,7 +1169,7 @@ public final class Matrices extends Stat
                      */
                     s += maximumFractionDigits[i] - width;
                     if (noFractionDigits[flatIndex]) {
-                        buffer.setLength(buffer.length() - 2); // Erase the trailing ".0"
+                        buffer.setLength(buffer.length() - 2);      // Erase the trailing ".0"
                         s += 2;
                     } else {
                         int n = Math.min(s, maximumPaddingZeros[flatIndex]);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java?rev=1766500&r1=1766499&r2=1766500&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java [UTF-8] Tue Oct 25 10:22:16 2016
@@ -77,7 +77,7 @@ public abstract class MatrixSIS implemen
      * Ensures that the given array is non-null and has the expected length.
      * This is a convenience method for subclasses constructors.
      *
-     * @throws IllegalArgumentException If the given array does not have the expected length.
+     * @throws IllegalArgumentException if the given array does not have the expected length.
      */
     static void ensureLengthMatch(final int expected, final double[] elements) throws IllegalArgumentException {
         ArgumentChecks.ensureNonNull("elements", elements);
@@ -106,10 +106,10 @@ public abstract class MatrixSIS implemen
      * Ensures that the number of rows of a given matrix matches the given value.
      * This is a convenience method for {@link #multiply(Matrix)} implementations.
      *
-     * @param expected The expected number of rows.
-     * @param actual   The actual number of rows in the matrix to verify.
-     * @param numCol   The number of columns to report in case of errors. This is an arbitrary
-     *                 value and have no incidence on the verification performed by this method.
+     * @param  expected  the expected number of rows.
+     * @param  actual    the actual number of rows in the matrix to verify.
+     * @param  numCol    the number of columns to report in case of errors. This is an arbitrary
+     *                   value and have no incidence on the verification performed by this method.
      */
     static void ensureNumRowMatch(final int expected, final int actual, final int numCol) {
         if (actual != expected) {
@@ -130,8 +130,8 @@ public abstract class MatrixSIS implemen
      * an instance of {@code MatrixSIS}, then it is returned unchanged. Otherwise all elements
      * are copied in a new {@code MatrixSIS} object.
      *
-     * @param  matrix The matrix to cast or copy, or {@code null}.
-     * @return The matrix argument if it can be safely casted (including {@code null} argument),
+     * @param  matrix  the matrix to cast or copy, or {@code null}.
+     * @return the matrix argument if it can be safely casted (including {@code null} argument),
      *         or a copy of the given matrix otherwise.
      *
      * @see Matrices#copy(Matrix)
@@ -166,20 +166,42 @@ public abstract class MatrixSIS implemen
      * Retrieves the value at the specified row and column of this matrix, wrapped in a {@code Number}.
      * The {@code Number} type depends on the matrix accuracy.
      *
-     * @param row    The row index, from 0 inclusive to {@link #getNumRow()} exclusive.
-     * @param column The column index, from 0 inclusive to {@link #getNumCol()} exclusive.
-     * @return       The current value at the given row and column.
+     * @param  row     the row index, from 0 inclusive to {@link #getNumRow()} exclusive.
+     * @param  column  the column index, from 0 inclusive to {@link #getNumCol()} exclusive.
+     * @return the current value at the given row and column.
      */
     public Number getNumber(int row, int column) {
         return getElement(row, column);
     }
 
     /**
+     * Modifies the value at the specified row and column of this matrix.
+     * This method is the converses of {@link #getNumber(int, int)}.
+     *
+     * @param  row     the row index, from 0 inclusive to {@link #getNumRow()} exclusive.
+     * @param  column  the column index, from 0 inclusive to {@link #getNumCol()} exclusive.
+     * @param  value   the new matrix element value.
+     *
+     * @since 0.8
+     *
+     * @see #setElement(int, int, double)
+     */
+    public void setNumber(int row, int column, final Number value) {
+        if (value instanceof DoubleDouble) {
+            set(row, column, (DoubleDouble) value);
+        } else if (DoubleDouble.shouldConvert(value)) {
+            set(row, column, new DoubleDouble(value));
+        } else {
+            setElement(row, column, value.doubleValue());
+        }
+    }
+
+    /**
      * Retrieves the value at the specified row and column of this matrix.
      *
-     * @param row    The row index, from 0 inclusive to {@link #getNumRow()} exclusive.
-     * @param column The column index, from 0 inclusive to {@link #getNumCol()} exclusive.
-     * @return       The current value at the given row and column.
+     * @param  row     the row index, from 0 inclusive to {@link #getNumRow()} exclusive.
+     * @param  column  the column index, from 0 inclusive to {@link #getNumCol()} exclusive.
+     * @return the current value at the given row and column.
      */
     @Override
     public abstract double getElement(int row, int column);
@@ -188,7 +210,7 @@ public abstract class MatrixSIS implemen
      * Returns a copy of all matrix elements in a flat, row-major (column indices vary fastest) array.
      * The array length is <code>{@linkplain #getNumRow()} * {@linkplain #getNumCol()}</code>.
      *
-     * @return A copy of all current matrix elements in a row-major array.
+     * @return a copy of all current matrix elements in a row-major array.
      */
     public double[] getElements() {
         final int numRow = getNumRow();
@@ -207,8 +229,8 @@ public abstract class MatrixSIS implemen
      * All subclasses in this {@code org.apache.sis.referencing.operation.matrix} package override this
      * method with a more efficient implementation.
      *
-     * @param dest The destination array. May be longer than necessary (this happen when the caller needs to
-     *             append {@link org.apache.sis.internal.util.DoubleDouble#error} values after the elements).
+     * @param  dest  the destination array. May be longer than necessary (this happen when the caller needs to
+     *               append {@link org.apache.sis.internal.util.DoubleDouble#error} values after the elements).
      */
     void getElements(final double[] dest) {
         final double[] elements = getElements();
@@ -219,10 +241,10 @@ public abstract class MatrixSIS implemen
      * Copies the elements of the given matrix in the given array.
      * This method ignores the error terms, if any.
      *
-     * @param matrix   The matrix to copy.
-     * @param numRow   {@code matrix.getNumRow()}.
-     * @param numCol   {@code matrix.getNumCol()}.
-     * @param elements Where to copy the elements.
+     * @param  matrix    the matrix to copy.
+     * @param  numRow    {@code matrix.getNumRow()}.
+     * @param  numCol    {@code matrix.getNumCol()}.
+     * @param  elements  where to copy the elements.
      */
     static void getElements(final Matrix matrix, final int numRow, final int numCol, final double[] elements) {
         if (matrix instanceof MatrixSIS) {
@@ -251,17 +273,17 @@ public abstract class MatrixSIS implemen
     /**
      * Sets elements in a sub-region of this matrix, optionally including error terms.
      *
-     * @param source    Row-major values as given by {@link ExtendedPrecisionMatrix#getExtendedElements()}.
-     * @param length    Number of elements ({@code numRow} × {@code numCol}) in the source matrix, not including error terms.
-     * @param stride    Number of columns in the source matrix, used for computing indices in {@code source} array.
-     * @param srcRow    Index of the first row from the {@code source} to copy in {@code this}.
-     * @param srcCol    Index of the first column from the {@code source} to copy in {@code this}.
-     * @param dstRow    Index of the first row in {@code this} where to copy the {@code source} values.
-     * @param dstCol    Index of the first column in {@code this} where to copy the {@code source} values.
-     * @param numRow    Number of rows to copy.
-     * @param numCol    Number of columns to copy.
-     * @param transfer  If both {@code source} and {@code this} use extended precision,
-     *                  the temporary object to use for transferring values. Otherwise {@code null}.
+     * @param  source     row-major values as given by {@link ExtendedPrecisionMatrix#getExtendedElements()}.
+     * @param  length     number of elements ({@code numRow} × {@code numCol}) in the source matrix, not including error terms.
+     * @param  stride     number of columns in the source matrix, used for computing indices in {@code source} array.
+     * @param  srcRow     index of the first row from the {@code source} to copy in {@code this}.
+     * @param  srcCol     index of the first column from the {@code source} to copy in {@code this}.
+     * @param  dstRow     index of the first row in {@code this} where to copy the {@code source} values.
+     * @param  dstCol     index of the first column in {@code this} where to copy the {@code source} values.
+     * @param  numRow     number of rows to copy.
+     * @param  numCol     number of columns to copy.
+     * @param  transfer   if both {@code source} and {@code this} use extended precision,
+     *                    the temporary object to use for transferring values. Otherwise {@code null}.
      */
     final void setElements(final double[] source, final int length, final int stride, final DoubleDouble transfer,
                            int srcRow, final int srcCol,
@@ -287,7 +309,7 @@ public abstract class MatrixSIS implemen
      * Sets this matrix to the values of another matrix.
      * The given matrix must have the same size.
      *
-     * @param matrix  The matrix to copy.
+     * @param  matrix  the matrix to copy.
      * @throws MismatchedMatrixSizeException if the given matrix has a different size than this matrix.
      *
      * @since 0.7
@@ -448,9 +470,9 @@ public abstract class MatrixSIS implemen
      *   </tr>
      * </table>
      *
-     * @param srcDim The dimension of the ordinate to rescale in the source coordinates.
-     * @param scale  The amount by which to multiply the source ordinate value before to apply the transform, or {@code null} if none.
-     * @param offset The amount by which to translate the source ordinate value before to apply the transform, or {@code null} if none.
+     * @param  srcDim  the dimension of the ordinate to rescale in the source coordinates.
+     * @param  scale   the amount by which to multiply the source ordinate value before to apply the transform, or {@code null} if none.
+     * @param  offset  the amount by which to translate the source ordinate value before to apply the transform, or {@code null} if none.
      * @throws UnsupportedOperationException if this matrix is unmodifiable.
      *
      * @see AffineTransform#concatenate(AffineTransform)
@@ -483,9 +505,9 @@ public abstract class MatrixSIS implemen
      * given dimension. Converting a point with the resulting matrix is equivalent to first convert the point with
      * the original matrix, then convert the result with {@code ordinates[tgtDim] = ordinates[tgtDim] * scale + offset}.
      *
-     * @param tgtDim The dimension of the ordinate to rescale in the target coordinates.
-     * @param scale  The amount by which to multiply the target ordinate value after this transform, or {@code null} if none.
-     * @param offset The amount by which to translate the target ordinate value after this transform, or {@code null} if none.
+     * @param  tgtDim  the dimension of the ordinate to rescale in the target coordinates.
+     * @param  scale   the amount by which to multiply the target ordinate value after this transform, or {@code null} if none.
+     * @param  offset  the amount by which to translate the target ordinate value after this transform, or {@code null} if none.
      * @throws UnsupportedOperationException if this matrix is unmodifiable.
      *
      * @see AffineTransform#preConcatenate(AffineTransform)
@@ -520,8 +542,8 @@ public abstract class MatrixSIS implemen
      * <code>{@linkplain AffineTransform#concatenate AffineTransform.concatenate}(other)</code>:
      * first transforms by the supplied transform and then transform the result by the original transform.
      *
-     * @param  matrix The matrix to multiply to this matrix.
-     * @return The result of {@code this} × {@code matrix}.
+     * @param  matrix  the matrix to multiply to this matrix.
+     * @return the result of {@code this} × {@code matrix}.
      * @throws MismatchedMatrixSizeException if the number of rows in the given matrix is not equals to the
      *         number of columns in this matrix.
      */
@@ -538,8 +560,8 @@ public abstract class MatrixSIS implemen
      * This is equivalent to first computing the inverse of {@code this}, then multiplying the result
      * by the given matrix.
      *
-     * @param  matrix The matrix to solve.
-     * @return The <var>U</var> matrix that satisfies {@code this} × <var>U</var> = {@code matrix}.
+     * @param  matrix  the matrix to solve.
+     * @return the <var>U</var> matrix that satisfies {@code this} × <var>U</var> = {@code matrix}.
      * @throws MismatchedMatrixSizeException if the number of rows in the given matrix is not equals
      *         to the number of columns in this matrix.
      * @throws NoninvertibleMatrixException if this matrix is not invertible.
@@ -551,7 +573,7 @@ public abstract class MatrixSIS implemen
     /**
      * Returns the inverse of this matrix.
      *
-     * @return The inverse of this matrix.
+     * @return the inverse of this matrix.
      * @throws NoninvertibleMatrixException if this matrix is not invertible.
      *
      * @see AffineTransform#createInverse()
@@ -564,9 +586,9 @@ public abstract class MatrixSIS implemen
      * Returns a new matrix with the same elements than this matrix except for the specified rows.
      * This method is useful for removing a range of <em>target</em> dimensions in an affine transform.
      *
-     * @param  lower Index of the first row to remove (inclusive).
-     * @param  upper Index after the last row to remove (exclusive).
-     * @return A copy of this matrix with the specified rows removed.
+     * @param  lower  index of the first row to remove (inclusive).
+     * @param  upper  index after the last row to remove (exclusive).
+     * @return a copy of this matrix with the specified rows removed.
      *
      * @since 0.7
      */
@@ -600,9 +622,9 @@ public abstract class MatrixSIS implemen
      * This method is useful for removing a range of <em>source</em> dimensions in an affine transform.
      * Coordinates will be converted as if the values in the removed dimensions were zeros.
      *
-     * @param  lower  Index of the first column to remove (inclusive).
-     * @param  upper  Index after the last column to remove (exclusive).
-     * @return A copy of this matrix with the specified columns removed.
+     * @param  lower  index of the first column to remove (inclusive).
+     * @param  upper  index after the last column to remove (exclusive).
+     * @return a copy of this matrix with the specified columns removed.
      *
      * @since 0.7
      */
@@ -634,7 +656,7 @@ public abstract class MatrixSIS implemen
     /**
      * Returns a hash code value based on the data values in this matrix.
      *
-     * @return A hash code value for this matrix.
+     * @return a hash code value for this matrix.
      */
     @Override
     public int hashCode() {
@@ -645,7 +667,7 @@ public abstract class MatrixSIS implemen
      * Returns {@code true} if the specified object is of the same class than this matrix 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.
+     * @param  object  the object to compare with this matrix for equality.
      * @return {@code true} if the given object is equal to this matrix.
      */
     @Override
@@ -680,8 +702,8 @@ public abstract class MatrixSIS implemen
      *       smaller than or equals to the given threshold.</li>
      * </ul>
      *
-     * @param matrix    The matrix to compare.
-     * @param tolerance The tolerance value.
+     * @param  matrix     the matrix to compare.
+     * @param  tolerance  the tolerance value.
      * @return {@code true} if this matrix is close enough to the given matrix given the tolerance value.
      *
      * @see Matrices#equals(Matrix, Matrix, double, boolean)
@@ -706,8 +728,8 @@ public abstract class MatrixSIS implemen
      *       The threshold value is determined empirically and may change in any future SIS versions.</li>
      * </ul>
      *
-     * @param  object The object to compare to {@code this}.
-     * @param  mode The strictness level of the comparison.
+     * @param  object  the object to compare to {@code this}.
+     * @param  mode    the strictness level of the comparison.
      * @return {@code true} if both objects are equal.
      *
      * @see Matrices#equals(Matrix, Matrix, ComparisonMode)
@@ -720,7 +742,7 @@ public abstract class MatrixSIS implemen
     /**
      * Returns a clone of this matrix.
      *
-     * @return A new matrix of the same class and with the same values than this matrix.
+     * @return a new matrix of the same class and with the same values than this matrix.
      *
      * @see Matrices#copy(Matrix)
      */

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/AffineTransforms2DTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/AffineTransforms2DTest.java?rev=1766500&r1=1766499&r2=1766500&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/AffineTransforms2DTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/AffineTransforms2DTest.java [UTF-8] Tue Oct 25 10:22:16 2016
@@ -64,7 +64,7 @@ public final strictfp class AffineTransf
     /**
      * Run the test in the flipped or unflipped case.
      *
-     * @param f -1 for the flipped case, or +1 for the unflipped case.
+     * @param  f  -1 for the flipped case, or +1 for the unflipped case.
      */
     private static void runTest(final int f) {
         // Test identity
@@ -113,7 +113,7 @@ public final strictfp class AffineTransf
         assertEquals( r, AffineTransforms2D.getRotation(tr), EPS);
         assertEquals(-1, AffineTransforms2D.getSwapXY  (tr));
         assertEquals( f, AffineTransforms2D.getFlip    (tr));
-        assertEquals( 1, getFlipFromType(tr)); // Always unflipped according Java 1.5.0_09...
+        assertEquals( 1, getFlipFromType(tr));                      // Always unflipped according Java 1.5.0_09
 
         // Tests axis swapping
         r = toRadians(-90 * f);

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/GeneralMatrixTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/GeneralMatrixTest.java?rev=1766500&r1=1766499&r2=1766500&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/GeneralMatrixTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/GeneralMatrixTest.java [UTF-8] Tue Oct 25 10:22:16 2016
@@ -40,11 +40,11 @@ public final strictfp class GeneralMatri
     /**
      * Computes a random size for the next matrix to create.
      *
-     * @param random The random number generator to use.
+     * @param  random  the random number generator to use.
      */
     @Override
     void prepareNewMatrixSize(final Random random) {
-        size = 5 + random.nextInt(8); // Matrix sizes from 5 to 12 inclusive.
+        size = 5 + random.nextInt(8);                   // Matrix sizes from 5 to 12 inclusive.
     }
 
     /** {@inheritDoc} */ @Override int getNumRow() {return size;}
@@ -69,10 +69,10 @@ public final strictfp class GeneralMatri
     @Test
     public void testGetExtendedElements() {
         testGetExtendedElements(new GeneralMatrix(2, 2, new double[] {
-                StrictMath.PI / 180, // Degrees to radians
-                180 / StrictMath.PI, // Radians to degrees
-                0.9,                 // Gradians to degrees
-                0.1234567}));        // Random value with no special meaning.
+                StrictMath.PI / 180,            // Degrees to radians
+                180 / StrictMath.PI,            // Radians to degrees
+                0.9,                            // Gradians to degrees
+                0.1234567}));                   // Random value with no special meaning.
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatricesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatricesTest.java?rev=1766500&r1=1766499&r2=1766500&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatricesTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatricesTest.java [UTF-8] Tue Oct 25 10:22:16 2016
@@ -81,7 +81,7 @@ public final strictfp class MatricesTest
         }
         final MatrixSIS matrix = Matrices.create(SIZE, SIZE, elements);
         assertInstanceOf("Created with DoubleDouble elements", GeneralMatrix.class, matrix);
-        assertFalse(expected.equals(matrix)); // Because not the same type.
+        assertFalse(expected.equals(matrix));                                       // Because not the same type.
         assertTrue(Matrices.equals(expected, matrix, ComparisonMode.BY_CONTRACT));
         final double[] errors = ((GeneralMatrix) matrix).elements;
         for (int i = 0; i < SIZE*SIZE; i++) {
@@ -130,12 +130,12 @@ public final strictfp class MatricesTest
         assertFalse("isIdentity", matrix.isIdentity());
         assertEquals("numRow", 4, matrix.getNumRow());
         assertEquals("numCol", 4, matrix.getNumCol());
-        assertEquals(Matrices.create(4, 4, new double[] {
+        assertMatrixEquals("(N,E,U) → (W,U,S)", Matrices.create(4, 4, new double[] {
              0,-1, 0, 0,
              0, 0, 1, 0,
             -1, 0, 0, 0,
              0, 0, 0, 1
-        }), matrix);
+        }), matrix, STRICT);
     }
 
     /**
@@ -156,11 +156,11 @@ public final strictfp class MatricesTest
         assertFalse("isIdentity", matrix.isIdentity());
         assertEquals("numRow", 3, matrix.getNumRow());
         assertEquals("numCol", 4, matrix.getNumCol());
-        assertEquals(Matrices.create(3, 4, new double[] {
+        assertMatrixEquals("(N,E,U) → (D,N)", Matrices.create(3, 4, new double[] {
             0, 0,-1, 0,
             1, 0, 0, 0,
             0, 0, 0, 1
-        }), matrix);
+        }), matrix, STRICT);
     }
 
     /**
@@ -181,11 +181,11 @@ public final strictfp class MatricesTest
         assertFalse("isIdentity", matrix.isIdentity());
         assertEquals("numRow", 3, matrix.getNumRow());
         assertEquals("numCol", 4, matrix.getNumCol());
-        assertEquals(Matrices.create(3, 4, new double[] {
+        assertMatrixEquals("(N,E,U) → (D,D)", Matrices.create(3, 4, new double[] {
             0, 0,-1, 0,
             0, 0,-1, 0,
             0, 0, 0, 1
-        }), matrix);
+        }), matrix, STRICT);
     }
 
     /**
@@ -303,11 +303,11 @@ public final strictfp class MatricesTest
         assertFalse("isIdentity", matrix.isIdentity());
         assertEquals("numRow", 3, matrix.getNumRow());
         assertEquals("numCol", 3, matrix.getNumCol());
-        assertEquals(Matrices.create(3, 3, new double[] {
+        assertMatrixEquals("(N,E) → (E,N)", Matrices.create(3, 3, new double[] {
             0,   -3.0, 350,
             2.5,  0,    75,
             0,    0,     1
-        }), matrix);
+        }), matrix, STRICT);
         /*
          * Test dropping a dimension.
          */
@@ -319,11 +319,11 @@ public final strictfp class MatricesTest
                 dstEnvelope, new AxisDirection[] {EAST, NORTH});
         assertEquals("numRow", 3, matrix.getNumRow());
         assertEquals("numCol", 4, matrix.getNumCol());
-        assertEquals(Matrices.create(3, 4, new double[] {
+        assertMatrixEquals("(N,E,U) → (E,N)", Matrices.create(3, 4, new double[] {
             0,   -3.0, 0, 350,
             2.5,  0,   0,  75,
             0,    0,   0,   1
-        }), matrix);
+        }), matrix, STRICT);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix2Test.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix2Test.java?rev=1766500&r1=1766499&r2=1766500&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix2Test.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix2Test.java [UTF-8] Tue Oct 25 10:22:16 2016
@@ -74,9 +74,9 @@ public final strictfp class Matrix2Test
     @Test
     public void testGetExtendedElements() {
         GeneralMatrixTest.testGetExtendedElements(new Matrix2(
-                StrictMath.PI / 180, // Degrees to radians
-                180 / StrictMath.PI, // Radians to degrees
-                0.9,                 // Gradians to degrees
-                0.1234567));         // Random value with no special meaning.
+                StrictMath.PI / 180,        // Degrees to radians
+                180 / StrictMath.PI,        // Radians to degrees
+                0.9,                        // Gradians to degrees
+                0.1234567));                // Random value with no special meaning.
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix4Test.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix4Test.java?rev=1766500&r1=1766499&r2=1766500&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix4Test.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix4Test.java [UTF-8] Tue Oct 25 10:22:16 2016
@@ -95,7 +95,7 @@ public final strictfp class Matrix4Test
         final Matrix4 step1 = new Matrix4(
                 0.9,  0,    0,    parisMeridian,
                 0,    0.9,  0,    0,
-                0,    0,    0.8,  0, // Random conversion factor for z values.
+                0,    0,    0.8,  0,                // Random conversion factor for z values.
                 0,    0,    0,    1);
         /*
          * Degrees to radians with swapping of (longitude, latitude) axes

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java?rev=1766500&r1=1766499&r2=1766500&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java [UTF-8] Tue Oct 25 10:22:16 2016
@@ -120,7 +120,7 @@ public abstract strictfp class MatrixTes
      * (which happen only when performing some more extensive tests), then the given seed will be replaced
      * by a random one.
      *
-     * @param seed The initial seed.
+     * @param  seed  the initial seed.
      */
     final void initialize(final long seed) {
         random = DETERMINIST ? new Random(seed) : TestUtilities.createRandomNumberGenerator();
@@ -130,7 +130,7 @@ public abstract strictfp class MatrixTes
      * Computes a random size for the next matrix to create. This method is overridden
      * only by subclasses that test matrix implementations supporting arbitrary sizes.
      *
-     * @param random The random number generator to use for computing a random matrix size.
+     * @param  random  the random number generator to use for computing a random matrix size.
      */
     void prepareNewMatrixSize(final Random random) {
     }
@@ -151,9 +151,9 @@ public abstract strictfp class MatrixTes
     /**
      * Verifies that the SIS matrix is equals to the JAMA one, up to the given tolerance value.
      *
-     * @param expected  The JAMA matrix used as a reference implementation.
-     * @param actual    The SIS matrix to compare to JAMA.
-     * @param tolerance The tolerance threshold, usually either {@link #STRICT} or {@link #TOLERANCE}.
+     * @param  expected   the JAMA matrix used as a reference implementation.
+     * @param  actual     the SIS matrix to compare to JAMA.
+     * @param  tolerance  the tolerance threshold, usually either {@link #STRICT} or {@link #TOLERANCE}.
      */
     static void assertEqualsJAMA(final Matrix expected, final MatrixSIS actual, final double tolerance) {
         final int numRow = actual.getNumRow();
@@ -396,9 +396,9 @@ public abstract strictfp class MatrixTes
      * Consequently it is sub-classes responsibility to add a {@code testConvertBefore()} method
      * which invoke this method.
      *
-     * @param matrix The matrix of size 3×3 to test.
-     * @param withShear {@code true} for including shear in the matrix to test.
-     *        This value can be set to {@code false} if the subclass want to test a simpler case.
+     * @param  matrix     the matrix of size 3×3 to test.
+     * @param  withShear  {@code true} for including shear in the matrix to test.
+     *         This value can be set to {@code false} if the subclass want to test a simpler case.
      *
      * @since 0.6
      */
@@ -466,7 +466,7 @@ public abstract strictfp class MatrixTes
      * Consequently it is sub-classes responsibility to add a {@code testConvertAfter()} method
      * which invoke this method.
      *
-     * @param matrix The matrix of size 3×3 to test.
+     * @param  matrix  the matrix of size 3×3 to test.
      *
      * @since 0.6
      */

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java?rev=1766500&r1=1766499&r2=1766500&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java [UTF-8] Tue Oct 25 10:22:16 2016
@@ -51,11 +51,11 @@ public final strictfp class NonSquareMat
     /**
      * Computes a random size for the next matrix to create.
      *
-     * @param random The random number generator to use.
+     * @param  random  the random number generator to use.
      */
     @Override
     void prepareNewMatrixSize(final Random random) {
-        numRow = 5 + random.nextInt(8); // Matrix sizes from 5 to 12 inclusive.
+        numRow = 5 + random.nextInt(8);                 // Matrix sizes from 5 to 12 inclusive.
         int n;
         do n = 5 + random.nextInt(8);
         while (n == numRow);
@@ -150,9 +150,9 @@ public final strictfp class NonSquareMat
      * Tests {@link NonSquareMatrix#inverse()} or {@link NonSquareMatrix#solve(Matrix)} with a conversion
      * matrix having more source dimensions (columns) than target dimensions (rows).
      *
-     * @param  Y    The matrix to give to {@code solve(Y)}, {@code null} for testing {@code inverse()}.
-     * @param  sf   The scale factor by which to multiply all expected scale elements.
-     * @param  uks  Value of unknown scales (O for {@code inverse()}, or NaN for {@code solve(Y)}).
+     * @param  Y    the matrix to give to {@code solve(Y)}, {@code null} for testing {@code inverse()}.
+     * @param  sf   the scale factor by which to multiply all expected scale elements.
+     * @param  uks  value of unknown scales (O for {@code inverse()}, or NaN for {@code solve(Y)}).
      * @throws NoninvertibleMatrixException if the matrix can not be inverted.
      */
     private static void testDimensionReduction(final MatrixSIS Y, final double sf, final double uks)
@@ -178,8 +178,8 @@ public final strictfp class NonSquareMat
      * Tests {@link NonSquareMatrix#inverse()} or {@link NonSquareMatrix#solve(Matrix)} with a conversion
      * matrix having more target dimensions (rows) than source dimensions (columns).
      *
-     * @param  Y    The matrix to give to {@code solve(Y)}, {@code null} for testing {@code inverse()}.
-     * @param  sf   The scale factor by which to multiply all expected scale elements.
+     * @param  Y   the matrix to give to {@code solve(Y)}, {@code null} for testing {@code inverse()}.
+     * @param  sf  the scale factor by which to multiply all expected scale elements.
      * @throws NoninvertibleMatrixException if the matrix can not be inverted.
      */
     private static void testDimensionIncrease(final MatrixSIS Y, final double sf)

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/SolverTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/SolverTest.java?rev=1766500&r1=1766499&r2=1766500&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/SolverTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/SolverTest.java [UTF-8] Tue Oct 25 10:22:16 2016
@@ -91,7 +91,7 @@ public final strictfp class SolverTest e
     /**
      * Tests the {@code Solver.solve(MatrixSIS, Matrix, int)} method.
      *
-     * @throws NoninvertibleMatrixException Should never happen.
+     * @throws NoninvertibleMatrixException if an unexpected error occurred while inverting the matrix.
      */
     @Test
     public void testSolve() throws NoninvertibleMatrixException {
@@ -111,7 +111,7 @@ public final strictfp class SolverTest e
             try {
                 jama = reference.solve(referenceArg);
             } catch (RuntimeException e) {
-                out.println(e); // "Matrix is singular."
+                out.println(e);                                         // "Matrix is singular."
                 continue;
             }
             final MatrixSIS U = Solver.solve(matrix, matrixArg);
@@ -122,7 +122,7 @@ public final strictfp class SolverTest e
     /**
      * Tests {@link Solver#inverse(MatrixSIS, boolean)} with a square matrix that contains a {@link Double#NaN} value.
      *
-     * @throws NoninvertibleMatrixException Should not happen.
+     * @throws NoninvertibleMatrixException if an unexpected error occurred while inverting the matrix.
      */
     @Test
     @DependsOnMethod("testSolve")



Mime
View raw message