sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1530900 - in /sis/branches/JDK7/core: sis-referencing/src/main/java/org/apache/sis/referencing/datum/ sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/ sis-utility/src/main/java/org/apache/sis/internal/util/ sis-ut...
Date Thu, 10 Oct 2013 09:40:39 GMT
Author: desruisseaux
Date: Thu Oct 10 09:40:38 2013
New Revision: 1530900

URL: http://svn.apache.org/r1530900
Log:
Use double-double arithmetic in 'normalizeColumns()' method too.

Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java?rev=1530900&r1=1530899&r2=1530900&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
[UTF-8] Thu Oct 10 09:40:38 2013
@@ -97,7 +97,7 @@ import java.util.Objects;
  *       </mtr>
  *     </mtable>
  *   </mfenced>
- *   <mo>⋅</mo>
+ *   <mo>×</mo>
  *   <mfenced open="[" close="]">
  *     <mtable>
  *       <mtr><mtd><msub><mi>X</mi><mi>s</mi></msub></mtd></mtr>

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java?rev=1530900&r1=1530899&r2=1530900&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
[UTF-8] Thu Oct 10 09:40:38 2013
@@ -20,7 +20,6 @@ import java.util.Arrays;
 import org.opengis.referencing.operation.Matrix;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ArraysExt;
-import org.apache.sis.math.MathFunctions;
 import org.apache.sis.internal.util.DoubleDouble;
 
 
@@ -394,24 +393,33 @@ class GeneralMatrix extends MatrixSIS {
 
     /**
      * {@inheritDoc}
-     *
-     * <p>The current implementation discards the extended precision, if any.</p>
      */
     @Override
     public final void normalizeColumns() {
         final int numRow = this.numRow; // Protection against accidental changes.
         final int numCol = this.numCol;
-        final double[] column = new double[numRow];
+        final int errors = numRow * numCol; // Where error values start.
+        final double[] elt = getExtendedElements(this, numRow, numCol, false);
+        final DoubleDouble sum = new DoubleDouble();
+        final DoubleDouble dot = new DoubleDouble();
         for (int i=0; i<numCol; i++) {
+            sum.clear();
             for (int j=0; j<numRow; j++) {
-                column[j] = elements[j*numCol + i];
+                dot.setFrom(elt, j*numCol + i, errors);
+                dot.multiply(dot);
+                sum.add(dot);
             }
-            final double m = MathFunctions.magnitude(column);
+            sum.sqrt();
             for (int j=0; j<numRow; j++) {
-                elements[j*numCol + i] /= m;
+                final int k = j*numCol + i;
+                dot.setFrom(sum);
+                dot.inverseDivide(elt, k, errors);
+                dot.storeTo(elt, k, errors);
             }
         }
-        Arrays.fill(elements, numRow * numCol, elements.length, 0);
+        if (elt != elements) {
+            System.arraycopy(elt, 0, elements, 0, elements.length);
+        }
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java?rev=1530900&r1=1530899&r2=1530900&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java
[UTF-8] Thu Oct 10 09:40:38 2013
@@ -696,6 +696,16 @@ public final class DoubleDouble extends 
     }
 
     /**
+     * Sets this double-double value to its square root.
+     *
+     * @todo This method is not yet implemented with double-double precision.
+     */
+    public void sqrt() {
+        value = Math.sqrt(value);
+        error = 0;
+    }
+
+    /**
      * Returns a string representation of this number for debugging purpose.
      * The returned string does not need to contains all digits that this {@code DoubleDouble}
can handle.
      *

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java?rev=1530900&r1=1530899&r2=1530900&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
[UTF-8] Thu Oct 10 09:40:38 2013
@@ -199,7 +199,8 @@ public final class MathFunctions extends
             dot.setToProduct(v1, v1);
             sum.add(dot);
         }
-        return Math.sqrt(sum.value);
+        sum.sqrt();
+        return sum.value;
     }
 
     /**



Mime
View raw message