sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1533591 - in /sis/branches/JDK7/core/sis-utility/src: main/java/org/apache/sis/internal/util/DoubleDouble.java test/java/org/apache/sis/internal/util/DoubleDoubleTest.java
Date Fri, 18 Oct 2013 18:56:30 GMT
Author: desruisseaux
Date: Fri Oct 18 18:56:29 2013
New Revision: 1533591

URL: http://svn.apache.org/r1533591
Log:
Case for sqrt(2).

Modified:
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java

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=1533591&r1=1533590&r2=1533591&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] Fri Oct 18 18:56:29 2013
@@ -144,6 +144,7 @@ public final class DoubleDouble extends 
          0.9,                                       // Degrees to gradians
          0.9144,                                    // Yard to metres
          1.111111111111111111111111111111111,       // Gradian to degrees
+         1.414213562373095048801688724209698,       // √2
          1.570796326794896619231321691639751,       // π/2
          1.8288,                                    // Fathom to metres
          2.356194490192344928846982537459627,       // π * 3/4
@@ -183,6 +184,7 @@ public final class DoubleDouble extends 
         /*  0.9       */ -2.2204460492503132E-17,
         /*  0.9144    */  9.414691248821328E-18,
         /*  1.111111… */ -4.9343245538895844E-17,
+        /*  1.414213… */ -9.667293313452913E-17,
         /*  1.570796… */  6.123233995736766E-17,
         /*  1.8288    */  1.8829382497642655E-17,
         /*  2.356194… */  9.184850993605148E-17,
@@ -724,9 +726,7 @@ public final class DoubleDouble extends 
         setToProduct(r, r);
         subtract(thisValue, thisError);
         divide(-2*r, 0); // Multiplication by 2 does not cause any precision lost.
-        error = value;
-        value = r;
-        normalize();
+        setToQuickSum(r, value);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java?rev=1533591&r1=1533590&r2=1533591&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java
[UTF-8] Fri Oct 18 18:56:29 2013
@@ -57,7 +57,7 @@ public final strictfp class DoubleDouble
      * This is a tolerance factor in units of {@link DoubleDouble#error} ULP, so even a "scary"
      * factor like 1E+4 should be very small compared to the {@link DoubleDouble#value}.
      */
-    private static final double PRODUCT_TOLERANCE_FACTOR = 10000;
+    private static final double PRODUCT_TOLERANCE_FACTOR = 20000;
 
     /**
      * Tolerance threshold for strict comparisons of floating point values.
@@ -271,6 +271,7 @@ public final strictfp class DoubleDouble
          "0.9",
          "0.9144",
          "1.111111111111111111111111111111111",
+         "1.414213562373095048801688724209698",
          "1.570796326794896619231321691639751",
          "1.8288",
          "2.356194490192344928846982537459627",
@@ -360,6 +361,7 @@ public final strictfp class DoubleDouble
         final DoubleDouble dd = new DoubleDouble();
         dd.value = 2;
         dd.sqrt();
+        assertNormalizedAndEquals(sqrt(2), dd);
         assertEquals(0, SQRT2.subtract(toBigDecimal(dd)).doubleValue(), 1E-32);
         /*
          * If we have been able to compute √2, now test with random values.



Mime
View raw message