Author: desruisseaux
Date: Mon Mar 23 10:56:21 2015
New Revision: 1668589
URL: http://svn.apache.org/r1668589
Log:
Referencing: ContextualParameters need to create matrices with extended
precision.
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtendedPrecisionMatrix.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/ContextualParameters.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/UnitaryProjectionTest.java
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtendedPrecisionMatrix.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtendedPrecisionMatrix.java?rev=1668589&r1=1668588&r2=1668589&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtendedPrecisionMatrix.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtendedPrecisionMatrix.java
[UTF-8] Mon Mar 23 10:56:21 2015
@@ -25,11 +25,18 @@ import org.opengis.referencing.operation
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.5
- * @version 0.5
+ * @version 0.6
* @module
*/
public interface ExtendedPrecisionMatrix extends Matrix {
/**
+ * A sentinel value for {@link
org.apache.sis.referencing.operation.matrix.Matrices#create(int, int, Number[])}
+ * meaning that we request an extended precision matrix initialized to the
identity (or diagonal) matrix.
+ * This is a non-public feature because we try to hide our
extended-precision mechanism from the users.
+ */
+ Number[] IDENTITY = new Number[0];
+
+ /**
* Returns a copy of all matrix elements, potentially followed by the
error terms for extended-precision arithmetic.
* Matrix elements are returned in a flat, row-major (column indices vary
fastest) array.
*
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=1668589&r1=1668588&r2=1668589&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] Mon Mar 23 10:56:21 2015
@@ -157,16 +157,17 @@ class GeneralMatrix extends MatrixSIS im
/**
* Creates a new extended precision matrix of the given size.
- * Matrices elements are initialized to zero (not to the matrix identity).
*
* @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) {
+ static GeneralMatrix createExtendedPrecision(final int numRow, final int
numCol, final boolean setToIdentity) {
if (numRow == numCol) {
- return new GeneralMatrix(numRow, numCol, false, 2);
+ return new GeneralMatrix(numRow, numCol, setToIdentity, 2);
} else {
- return new NonSquareMatrix(numRow, numCol, false, 2);
+ return new NonSquareMatrix(numRow, numCol, setToIdentity, 2);
}
}
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=1668589&r1=1668588&r2=1668589&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] Mon Mar 23 10:56:21 2015
@@ -192,7 +192,10 @@ public final class Matrices extends Stat
*/
public static MatrixSIS create(final int numRow, final int numCol, final
Number[] elements) {
ArgumentChecks.ensureNonNull("elements", elements);
- final GeneralMatrix matrix =
GeneralMatrix.createExtendedPrecision(numRow, numCol);
+ if (elements == ExtendedPrecisionMatrix.IDENTITY) { // Intentionally
undocumented features.
+ return GeneralMatrix.createExtendedPrecision(numRow, numCol, true);
+ }
+ final GeneralMatrix matrix =
GeneralMatrix.createExtendedPrecision(numRow, numCol, false);
if (matrix.setElements(elements)) {
/*
* At least one org.apache.sis.internal.util.DoubleDouble instance
has been found,
@@ -715,7 +718,7 @@ public final class Matrices extends Stat
}
final int nc = m2.getNumCol();
MatrixSIS.ensureNumRowMatch(m1.getNumCol(), m2.getNumRow(), nc);
- final GeneralMatrix result =
GeneralMatrix.createExtendedPrecision(m1.getNumRow(), nc);
+ final GeneralMatrix result =
GeneralMatrix.createExtendedPrecision(m1.getNumRow(), nc, false);
result.setToProduct(m1, m2);
return result;
}
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=1668589&r1=1668588&r2=1668589&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] Mon Mar 23 10:56:21 2015
@@ -368,7 +368,7 @@ public abstract class MatrixSIS implemen
public MatrixSIS multiply(final Matrix matrix) throws
MismatchedMatrixSizeException {
final int nc = matrix.getNumCol();
ensureNumRowMatch(getNumCol(), matrix.getNumRow(), nc);
- final GeneralMatrix result =
GeneralMatrix.createExtendedPrecision(getNumRow(), nc);
+ final GeneralMatrix result =
GeneralMatrix.createExtendedPrecision(getNumRow(), nc, false);
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=1668589&r1=1668588&r2=1668589&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] Mon Mar 23 10:56:21 2015
@@ -410,7 +410,7 @@ searchNaN: for (int flatIndex = (size -
* Copy right hand side with pivoting. Write the result directly in
the elements array
* of the result matrix. This block does not perform floating-point
arithmetic operations.
*/
- final GeneralMatrix result =
GeneralMatrix.createExtendedPrecision(size, innerSize);
+ final GeneralMatrix result =
GeneralMatrix.createExtendedPrecision(size, innerSize, false);
final double[] elements = result.elements;
final int errorOffset = size * innerSize;
for (int k=0,j=0; j<size; j++) {
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java?rev=1668589&r1=1668588&r2=1668589&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
[UTF-8] Mon Mar 23 10:56:21 2015
@@ -29,6 +29,7 @@ import org.opengis.parameter.ParameterDe
import org.opengis.parameter.ParameterNotFoundException;
import org.opengis.referencing.operation.Matrix;
import org.opengis.referencing.operation.MathTransformFactory;
+import org.apache.sis.internal.referencing.ExtendedPrecisionMatrix;
import org.apache.sis.internal.referencing.WKTUtilities;
import org.apache.sis.parameter.Parameterized;
import org.apache.sis.referencing.operation.matrix.Matrices;
@@ -150,7 +151,7 @@ public class ContextualParameters extend
if (size == null) {
throw new
IllegalArgumentException(Errors.format(Errors.Keys.MissingValueForProperty_1,
name));
}
- return Matrices.createIdentity(size);
+ return Matrices.create(size, size, ExtendedPrecisionMatrix.IDENTITY);
}
/**
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/UnitaryProjectionTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/UnitaryProjectionTest.java?rev=1668589&r1=1668588&r2=1668589&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/UnitaryProjectionTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/UnitaryProjectionTest.java
[UTF-8] Mon Mar 23 10:56:21 2015
@@ -120,8 +120,8 @@ public final strictfp class UnitaryProje
* Tests the {@link UnitaryProjection#t(double, double)} function.
*
* {@preformat text
- * Forward: y = -log(tsfn(φ))
- * Inverse: φ = cphi2(exp(-y))
+ * Forward: y = -log(t(φ))
+ * Inverse: φ = φ(exp(-y))
* }
*/
@Test