Author: desruisseaux
Date: Thu Mar 19 12:40:51 2015
New Revision: 1667726

URL: http://svn.apache.org/r1667726
Log:
Referencing: reduce the number of casts needed before to multiply of inverse a 
matrix.

Modified:
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.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/main/java/org/apache/sis/referencing/operation/matrix/Solver.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformDirect2D.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/NonLinearParameters.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java?rev=1667726&r1=1667725&r2=1667726&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
 [UTF-8] Thu Mar 19 12:40:51 2015
@@ -30,7 +30,7 @@ import org.opengis.referencing.datum.Ell
 import org.opengis.referencing.datum.PrimeMeridian;
 import org.opengis.referencing.datum.GeodeticDatum;
 import org.opengis.referencing.operation.Matrix;
-import org.apache.sis.referencing.operation.matrix.MatrixSIS;
+import org.apache.sis.referencing.operation.matrix.Matrices;
 import 
org.apache.sis.referencing.operation.matrix.NoninvertibleMatrixException;
 import org.apache.sis.metadata.iso.extent.Extents;
 import org.apache.sis.internal.referencing.ExtentSelector;
@@ -370,7 +370,7 @@ public class DefaultGeodeticDatum extend
      *       then the matrix will be built from those parameters.</li>
      *   <li>Otherwise if the other datum contains {@code BursaWolfParameters} 
having this datum
      *       as their target (ignoring metadata), then the matrix will be 
built from those parameters
-     *       and {@linkplain MatrixSIS#inverse() inverted}.</li>
+     *       and {@linkplain 
org.apache.sis.referencing.operation.matrix.MatrixSIS#inverse() inverted}.</li>
      * </ol>
      *
      * <p><b>Multi-occurrences resolution</b><br>
@@ -404,7 +404,7 @@ public class DefaultGeodeticDatum extend
         if (targetDatum instanceof DefaultGeodeticDatum) {
             candidate = ((DefaultGeodeticDatum) targetDatum).select(this, 
selector);
             if (candidate != null) try {
-                return MatrixSIS.castOrCopy(createTransformation(candidate, 
areaOfInterest)).inverse();
+                return Matrices.inverse(createTransformation(candidate, 
areaOfInterest));
             } catch (NoninvertibleMatrixException e) {
                 /*
                  * Should never happen because 
BursaWolfParameters.getPositionVectorTransformation(Date)

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=1667726&r1=1667725&r2=1667726&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] Thu Mar 19 12:40:51 2015
@@ -321,6 +321,13 @@ class GeneralMatrix extends MatrixSIS im
             } else {
                 elements = Arrays.copyOf(elements, length);
             }
+        } else if (matrix instanceof ExtendedPrecisionMatrix) {
+            elements = ((ExtendedPrecisionMatrix) 
matrix).getExtendedElements();
+            if (elements.length == length) {
+                return elements;
+            } else {
+                elements = Arrays.copyOf(elements, length);
+            }
         } else {
             elements = new double[length];
             getElements(matrix, numRow, numCol, elements);
@@ -551,7 +558,7 @@ class GeneralMatrix extends MatrixSIS im
      * Sets this matrix to the product of the given matrices: {@code this = A 
× B}.
      * The matrix sizes much match - this is not verified unless assertions 
are enabled.
      */
-    final void setToProduct(final MatrixSIS A, final Matrix B) {
+    final void setToProduct(final Matrix A, final Matrix B) {
         final int numRow = this.numRow; // Protection against accidental 
changes.
         final int numCol = this.numCol;
         final int nc = A.getNumCol();

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=1667726&r1=1667725&r2=1667726&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] Thu Mar 19 12:40:51 2015
@@ -64,7 +64,7 @@ import java.util.Objects;
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.6
  * @module
  *
  * @see org.apache.sis.parameter.TensorParameters
@@ -693,6 +693,54 @@ 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}.
+     * @throws MismatchedMatrixSizeException if the number of columns in 
{@code m1} is not equals to the
+     *         number of rows in {@code m2}.
+     *
+     * @see MatrixSIS#multiply(Matrix)
+     *
+     * @since 0.6
+     */
+    public static MatrixSIS multiply(final Matrix m1, final Matrix m2) throws 
MismatchedMatrixSizeException {
+        if (m1 instanceof MatrixSIS) {
+            return ((MatrixSIS) m1).multiply(m2);  // Maybe the subclass 
override that method.
+        }
+        final int nc = m2.getNumCol();
+        MatrixSIS.ensureNumRowMatch(m1.getNumCol(), m2.getNumRow(), nc);
+        final GeneralMatrix result = 
GeneralMatrix.createExtendedPrecision(m1.getNumRow(), nc);
+        result.setToProduct(m1, m2);
+        return result;
+    }
+
+    /**
+     * 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.
+     * @throws NoninvertibleMatrixException if the given matrix is not 
invertible.
+     *
+     * @see MatrixSIS#inverse()
+     *
+     * @since 0.6
+     */
+    public static MatrixSIS inverse(final Matrix matrix) throws 
NoninvertibleMatrixException {
+        if (matrix == null) {
+            return null;
+        } else if (matrix instanceof MatrixSIS) {
+            return ((MatrixSIS) matrix).inverse();  // Maybe the subclass 
override that method.
+        } else if (matrix.getNumRow() != matrix.getNumCol()) {
+            return new NonSquareMatrix(matrix).inverse();
+        } else {
+            return Solver.inverse(matrix, true);
+        }
+    }
+
+    /**
      * Returns {@code true} if the given 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.
@@ -706,21 +754,9 @@ public final class Matrices extends Stat
     public static boolean isAffine(final Matrix matrix) {
         if (matrix instanceof MatrixSIS) {
             return ((MatrixSIS) matrix).isAffine();
+        } else {
+            return MatrixSIS.isAffine(matrix);
         }
-        // Following is executed only if the given matrix is not a SIS 
implementation.
-        int j = matrix.getNumRow();
-        int i = matrix.getNumCol();
-        if (i != j--) {
-            return false; // Matrix is not square.
-        }
-        double e = 1;
-        while (--i >= 0) {
-            if (matrix.getElement(j, i) != e) {
-                return false;
-            }
-            e = 0;
-        }
-        return true;
     }
 
     /**

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=1667726&r1=1667725&r2=1667726&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] Thu Mar 19 12:40:51 2015
@@ -93,8 +93,7 @@ public abstract class MatrixSIS implemen
      * @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 Matrix matrix, 
final int numCol) {
-        final int actual = matrix.getNumRow();
+    static void ensureNumRowMatch(final int expected, final int actual, final 
int numCol) {
         if (actual != expected) {
             throw new MismatchedMatrixSizeException(Errors.format(
                     Errors.Keys.MismatchedMatrixSize_4, expected, "⒩", actual, 
numCol));
@@ -190,7 +189,28 @@ public abstract class MatrixSIS implemen
      * @see Matrices#isAffine(Matrix)
      * @see 
org.apache.sis.referencing.operation.transform.LinearTransform#isAffine()
      */
-    public abstract boolean isAffine();
+    public boolean isAffine() {
+        return isAffine(this);
+    }
+
+    /**
+     * Fallback for matrix of unknown implementation.
+     */
+    static boolean isAffine(final Matrix matrix) {
+        int j = matrix.getNumRow();
+        int i = matrix.getNumCol();
+        if (i != j--) {
+            return false; // Matrix is not square.
+        }
+        double e = 1;
+        while (--i >= 0) {
+            if (matrix.getElement(j, i) != e) {
+                return false;
+            }
+            e = 0;
+        }
+        return true;
+    }
 
     /**
      * Returns {@code true} if this matrix is an identity matrix.
@@ -242,11 +262,9 @@ public abstract class MatrixSIS implemen
      *         number of columns in this matrix.
      */
     public MatrixSIS multiply(final Matrix matrix) throws 
MismatchedMatrixSizeException {
-        final int numRow = getNumRow();
-        final int numCol = getNumCol();
         final int nc = matrix.getNumCol();
-        ensureNumRowMatch(numCol, matrix, nc);
-        final GeneralMatrix result = 
GeneralMatrix.createExtendedPrecision(numRow, nc);
+        ensureNumRowMatch(getNumCol(), matrix.getNumRow(), nc);
+        final GeneralMatrix result = 
GeneralMatrix.createExtendedPrecision(getNumRow(), nc);
         result.setToProduct(this, matrix);
         return result;
     }

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Solver.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Solver.java?rev=1667726&r1=1667725&r2=1667726&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Solver.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Solver.java
 [UTF-8] Thu Mar 19 12:40:51 2015
@@ -24,7 +24,7 @@ import org.apache.sis.util.ArraysExt;
 
 /**
  * Computes the value of <var>U</var> which solves {@code X} × <var>U</var> = 
{@code Y}.
- * The {@link #solve(MatrixSIS, Matrix, int)} method in this class is adapted 
from the {@code LUDecomposition}
+ * The {@link #solve(Matrix, Matrix, int)} method in this class is adapted 
from the {@code LUDecomposition}
  * class of the <a href="http://math.nist.gov/javanumerics/jama";>JAMA matrix 
package</a>. JAMA is provided in
  * the public domain.
  *
@@ -37,9 +37,9 @@ import org.apache.sis.util.ArraysExt;
  * @version 0.4
  * @module
  */
-final class Solver implements Matrix {
+final class Solver implements Matrix { // Not Cloneable, despite the clone() 
method.
     /**
-     * The size of the (i, j, s) tuples used internally by {@link 
#solve(MatrixSIS, Matrix, double[], int, int)}
+     * The size of the (i, j, s) tuples used internally by {@link 
#solve(Matrix, Matrix, double[], int, int)}
      * for storing information about the NaN values.
      */
     private static final int TUPLE_SIZE = 3;
@@ -112,7 +112,7 @@ final class Solver implements Matrix {
      * @param  noChange If {@code true}, do not allow modifications to the 
{@code X} matrix.
      * @throws NoninvertibleMatrixException If the {@code X} matrix is not 
square or singular.
      */
-    static MatrixSIS inverse(final MatrixSIS X, final boolean noChange) throws 
NoninvertibleMatrixException {
+    static MatrixSIS inverse(final Matrix X, final boolean noChange) throws 
NoninvertibleMatrixException {
         final int size = X.getNumRow();
         final int numCol = X.getNumCol();
         if (numCol != size) {
@@ -129,14 +129,14 @@ final class Solver implements Matrix {
      * @param  Y The desired result of {@code X} × <var>U</var>.
      * @throws NoninvertibleMatrixException If the {@code X} matrix is not 
square or singular.
      */
-    static MatrixSIS solve(final MatrixSIS X, final Matrix Y) throws 
NoninvertibleMatrixException {
-        final int size = X.getNumRow();
+    static MatrixSIS solve(final Matrix X, final Matrix Y) throws 
NoninvertibleMatrixException {
+        final int size   = X.getNumRow();
         final int numCol = X.getNumCol();
         if (numCol != size) {
             throw new 
NoninvertibleMatrixException(Errors.format(Errors.Keys.NonInvertibleMatrix_2, 
size, numCol));
         }
         final int innerSize = Y.getNumCol();
-        GeneralMatrix.ensureNumRowMatch(size, Y, innerSize);
+        GeneralMatrix.ensureNumRowMatch(size, Y.getNumRow(), innerSize);
         double[] eltY = null;
         if (Y instanceof GeneralMatrix) {
             eltY = ((GeneralMatrix) Y).elements;
@@ -176,7 +176,7 @@ final class Solver implements Matrix {
      * @param  noChange  If {@code true}, do not allow modifications to the 
{@code X} matrix.
      * @throws NoninvertibleMatrixException If the {@code X} matrix is not 
square or singular.
      */
-    private static MatrixSIS solve(final MatrixSIS X, final Matrix Y, final 
double[] eltY,
+    private static MatrixSIS solve(final Matrix X, final Matrix Y, final 
double[] eltY,
             final int size, final int innerSize, final boolean noChange) 
throws NoninvertibleMatrixException
     {
         assert (X.getNumRow() == size && X.getNumCol() == size) : size;
@@ -191,7 +191,7 @@ final class Solver implements Matrix {
          */
         int[] indexOfNaN = null;
         int   indexCount = 0;
-        if (X.isAffine()) {
+        if ((X instanceof MatrixSIS) ? ((MatrixSIS) X).isAffine() : 
MatrixSIS.isAffine(X)) {    // Avoid dependency to Matrices class.
             /*
              * Conservatively search for NaN values only if the matrix looks 
like an affine transform.
              * If the matrix is affine, then we will assume that we can 
interpret the last column as

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java?rev=1667726&r1=1667725&r2=1667726&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
 [UTF-8] Thu Mar 19 12:40:51 2015
@@ -33,7 +33,7 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.SingleOperation;
 import org.apache.sis.geometry.GeneralDirectPosition;
 import org.apache.sis.parameter.Parameterized;
-import org.apache.sis.referencing.operation.matrix.MatrixSIS;
+import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.io.wkt.FormattableObject;
 import org.apache.sis.internal.referencing.WKTUtilities;
@@ -1031,7 +1031,7 @@ public abstract class AbstractMathTransf
             if (point != null) {
                 point = this.transform(point, null);
             }
-            return 
MatrixSIS.castOrCopy(AbstractMathTransform.this.derivative(point)).inverse();
+            return 
Matrices.inverse(AbstractMathTransform.this.derivative(point));
         }
 
         /**

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java?rev=1667726&r1=1667725&r2=1667726&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
 [UTF-8] Thu Mar 19 12:40:51 2015
@@ -31,7 +31,6 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.NoninvertibleTransformException;
 import org.apache.sis.parameter.Parameterized;
 import org.apache.sis.referencing.operation.matrix.Matrices;
-import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 import org.apache.sis.internal.system.Semaphores;
 import org.apache.sis.util.Classes;
 import org.apache.sis.util.LenientComparable;
@@ -240,7 +239,7 @@ class ConcatenatedTransform extends Abst
         if (matrix1 != null) {
             final Matrix matrix2 = MathTransforms.getMatrix(tr2);
             if (matrix2 != null) {
-                final Matrix matrix = 
MatrixSIS.castOrCopy(matrix2).multiply(matrix1);
+                final Matrix matrix = Matrices.multiply(matrix2, matrix1);
                 if (Matrices.isIdentity(matrix, IDENTITY_TOLERANCE)) {
                     return MathTransforms.identity(matrix.getNumRow() - 1);
                 }
@@ -584,7 +583,7 @@ class ConcatenatedTransform extends Abst
         if (derivate) {
             final Matrix matrix1 = 
MathTransforms.derivativeAndTransform(transform1, srcPts, srcOff, buffer, 
offset);
             final Matrix matrix2 = 
MathTransforms.derivativeAndTransform(transform2, buffer, offset, dstPts, 
dstOff);
-            return MatrixSIS.castOrCopy(matrix2).multiply(matrix1);
+            return Matrices.multiply(matrix2, matrix1);
         } else {
             transform1.transform(srcPts, srcOff, buffer, offset, 1);
             transform2.transform(buffer, offset, dstPts, dstOff, 1);
@@ -849,7 +848,7 @@ class ConcatenatedTransform extends Abst
     public Matrix derivative(final DirectPosition point) throws 
TransformException {
         final Matrix matrix1 = transform1.derivative(point);
         final Matrix matrix2 = 
transform2.derivative(transform1.transform(point, null));
-        return MatrixSIS.castOrCopy(matrix2).multiply(matrix1);
+        return Matrices.multiply(matrix2, matrix1);
     }
 
     /**

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformDirect2D.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformDirect2D.java?rev=1667726&r1=1667725&r2=1667726&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformDirect2D.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformDirect2D.java
 [UTF-8] Thu Mar 19 12:40:51 2015
@@ -22,7 +22,7 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.MathTransform2D;
 import org.opengis.referencing.operation.TransformException;
 import org.opengis.referencing.operation.NoninvertibleTransformException;
-import org.apache.sis.referencing.operation.matrix.MatrixSIS;
+import org.apache.sis.referencing.operation.matrix.Matrices;
 
 
 /**
@@ -93,7 +93,7 @@ final class ConcatenatedTransformDirect2
         final MathTransform2D transform2 = (MathTransform2D) this.transform2;
         final Matrix matrix1 = transform1.derivative(point);
         final Matrix matrix2 = 
transform2.derivative(transform1.transform(point,null));
-        return MatrixSIS.castOrCopy(matrix2).multiply(matrix1);
+        return Matrices.multiply(matrix2, matrix1);
     }
 
     /**

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/NonLinearParameters.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/NonLinearParameters.java?rev=1667726&r1=1667725&r2=1667726&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/NonLinearParameters.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/NonLinearParameters.java
 [UTF-8] Thu Mar 19 12:40:51 2015
@@ -304,7 +304,7 @@ public abstract class NonLinearParameter
          */
         Matrix userDefined = inverse ? denormalize : normalize;
         if (!inverse) try {
-            userDefined = MatrixSIS.castOrCopy(userDefined).inverse();
+            userDefined = Matrices.inverse(userDefined);
         } catch (NoninvertibleMatrixException e) {
             // Should never happen. But if it does, we abandon the attempt to 
change
             // the list elements and will format the objects in their "raw" 
format.
@@ -312,7 +312,7 @@ public abstract class NonLinearParameter
             return index;
         }
         if (hasBefore) {
-            userDefined = MatrixSIS.castOrCopy(userDefined).multiply(before);
+            userDefined = Matrices.multiply(userDefined, before);
         }
         /*
          * At this point "userDefined" is the affine transform to show to user 
instead of the
@@ -330,13 +330,13 @@ public abstract class NonLinearParameter
          */
         userDefined = inverse ? normalize : denormalize;
         if (!inverse) try {
-            userDefined = MatrixSIS.castOrCopy(userDefined).inverse();
+            userDefined = Matrices.inverse(userDefined);
         } catch (NoninvertibleMatrixException e) {
             unexpectedException(e);
             return index;
         }
         if (hasAfter) {
-            userDefined = MatrixSIS.castOrCopy(after).multiply(userDefined);
+            userDefined = Matrices.multiply(after, userDefined);
         }
         after = userDefined.isIdentity() ? null : userDefined;
         /*

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java?rev=1667726&r1=1667725&r2=1667726&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
 [UTF-8] Thu Mar 19 12:40:51 2015
@@ -427,9 +427,7 @@ class ProjectiveTransform extends Abstra
              *           inverse = this;
              *       } else { ... }
              */
-            MatrixSIS matrix = Matrices.copy(this);
-            matrix = matrix.inverse();
-            ProjectiveTransform inv = createInverse(matrix);
+            ProjectiveTransform inv = createInverse(Matrices.inverse(this));
             inv.inverse = this;
             inverse = inv;
         }


Reply via email to