sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1540209 [2/2] - in /sis/branches/JDK6: ./ application/sis-console/src/main/resources/org/apache/sis/console/ core/sis-metadata/src/main/java/org/apache/sis/metadata/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/ core/...
Date Fri, 08 Nov 2013 22:24:14 GMT
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java?rev=1540209&r1=1540208&r2=1540209&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java [UTF-8] Fri Nov  8 22:24:13 2013
@@ -19,7 +19,6 @@ package org.apache.sis.math;
 import java.util.Arrays;
 import org.apache.sis.util.Static;
 import org.apache.sis.util.ArraysExt;
-import org.apache.sis.util.Workaround;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.util.DoubleDouble;
@@ -58,9 +57,10 @@ import static org.apache.sis.internal.ut
  *
  * @author  Martin Desruisseaux (MPO, IRD, Geomatys)
  * @since   0.3 (derived from geotk-1.0)
- * @version 0.3
+ * @version 0.4
  * @module
  *
+ * @see DecimalFunctions
  * @see org.apache.sis.util.Numbers
  */
 public final class MathFunctions extends Static {
@@ -73,6 +73,11 @@ public final class MathFunctions extends
 
     /**
      * The logarithm of 2 in base 10, which is approximated by {@value}.
+     * This constant is useful for converting a power of 2 to a power of 10 as below:
+     *
+     * {@preformat java
+     *   double exp10 = exp2 * LOG10_2;
+     * }
      *
      * @see Math#log10(double)
      * @see #getExponent(double)
@@ -82,29 +87,6 @@ public final class MathFunctions extends
     public static final double LOG10_2 = 0.3010299956639812;
 
     /**
-     * The greatest power of 10 such as {@code Math.pow(10, E10_FOR_ZERO) == 0}.
-     * This is the exponent in {@code parseDouble("1E-324")} < {@link Double#MIN_VALUE},
-     * which is stored as zero because non-representable as a {@code double} value.
-     * The next power, {@code parseDouble("1E-323")}, is a non-zero {@code double} value.
-     *
-     * @see Double#MIN_VALUE
-     */
-    static final int E10_FOR_ZERO = -324;
-
-    /**
-     * Table of some integer powers of 10. Used for faster computation in {@link #pow10(int)}.
-     *
-     * @see #pow10(int)
-     */
-    private static final double[] POW10 = {
-        1E+00, 1E+01, 1E+02, 1E+03, 1E+04, 1E+05, 1E+06, 1E+07, 1E+08, 1E+09,
-        1E+10, 1E+11, 1E+12, 1E+13, 1E+14, 1E+15, 1E+16, 1E+17, 1E+18, 1E+19,
-        1E+20, 1E+21, 1E+22
-        // Do not add more elements, unless we verified that 1/x is accurate.
-        // Last time we tried, it was not accurate anymore starting at 1E+23.
-    };
-
-    /**
      * The minimal ordinal value for {@code NaN} numbers created by {@link #toNanFloat(int)}.
      *
      * @see #toNanFloat(int)
@@ -225,52 +207,7 @@ public final class MathFunctions extends
     }
 
     /**
-     * Returns the number of fraction digits needed for formatting in base 10 numbers of the given
-     * accuracy. If the {@code strict} argument is {@code true}, then for any given {@code accuracy}
-     * this method returns a value <var>n</var> such as the difference between adjacent numbers
-     * formatted in base 10 with <var>n</var> fraction digits will always be equal or smaller
-     * than {@code accuracy}. Examples:
-     *
-     * <ul>
-     *   <li>{@code fractionDigitsForDelta(0.001, true)} returns 3.</li>
-     *   <li>{@code fractionDigitsForDelta(0.009, true)} returns 3.</li>
-     *   <li>{@code fractionDigitsForDelta(0.010, true)} returns 2.</li>
-     *   <li>{@code fractionDigitsForDelta(0.099, true)} returns 3 (special case).</li>
-     * </ul>
-     *
-     * <p>Special cases:</p>
-     * <ul>
-     *   <li>If {@code accuracy} is {@link Double#NaN NaN} or infinity, then this method returns 0
-     *       since those values are not represented by decimal digits.</li>
-     *
-     *   <li>If {@code accuracy} is 0, then this method returns 324 since 10<sup>-324</sup> is the first power of 10
-     *       smaller than the minimal strictly positive {@code double} value ({@value java.lang.Double#MIN_VALUE}).
-     *
-     *       {@note The above value can be understood in an other way: if the first 324 fraction digits are zero,
-     *              then the IEEE <code>double</code> value is guaranteed to be rounded to exactly 0 no matter
-     *              what the next fraction digits are.}</li>
-     *
-     *   <li>If {@code accuracy} is greater than 1, then this method returns
-     *       the number of "unnecessary" trailing zeros as a negative number.
-     *
-     *       {@example <code>fractionDigitsForDelta(100, …)</code> returns -2.}</li>
-     *
-     *   <li>If the first non-zero digits of {@code accuracy} are equal or greater than 95
-     *       (e.g. 0.00099) and the {@code strict} argument is {@code true}, then this method
-     *       increases the number of needed fraction digits in order to prevent the rounded
-     *       number to be collapsed into the next integer value.
-     *
-     *       {@example
-     *       If <code>accuracy</code> is 0.95, then a return value of 1 is not sufficient since
-     *       the rounded value of 0.95 with 1 fraction digit would be 1.0. Such value would be a
-     *       violation of this method contract since the difference between 0 and that formatted
-     *       value would be greater than the accuracy. Note that this is not an artificial rule;
-     *       this is related to the fact that 0.9999… is mathematically strictly equals to 1.}</li>
-     * </ul>
-     *
-     * <p>Invoking this method is equivalent to computing <code>(int)
-     * -{@linkplain Math#floor(double) floor}({@linkplain Math#log10(double) log10}(accuracy))</code>
-     * except for the 0, {@code NaN}, infinities and {@code 0.…95} special cases.</p>
+     * @deprecated Moved to the {@link DecimalFunctions} class.
      *
      * @param  accuracy The desired accuracy of numbers to format in base 10.
      * @param  strict {@code true} for checking the {@code 0.…95} special case.
@@ -281,91 +218,9 @@ public final class MathFunctions extends
      *
      * @see java.text.NumberFormat#setMaximumFractionDigits(int)
      */
+    @Deprecated
     public static int fractionDigitsForDelta(double accuracy, final boolean strict) {
-        accuracy = Math.abs(accuracy);
-        final boolean isFraction = (accuracy < 1);
-        /*
-         * Compute (int) Math.log10(x) with opportunist use of the POW10 array.
-         * We use the POW10 array because accurate calculation of log10 is relatively costly,
-         * while we only want the integer part. A micro-benchmarking on JDK7 suggested that a
-         * binary search on POW10 is about 30% faster than invoking (int) Math.log10(x).
-         */
-        int i = Arrays.binarySearch(POW10, isFraction ? 1/accuracy : accuracy);
-        if (i >= 0) {
-            return isFraction ? i : -i;
-        }
-        i = ~i;
-        double scale;
-        if (i < POW10.length) {
-            scale = POW10[i];
-            if (!isFraction) {
-                i = -(i-1);
-                scale = 10 / scale;
-            }
-        } else { // 'x' is out of range or NaN.
-            final double y = Math.log10(accuracy);
-            if (Double.isInfinite(y)) {
-                return (accuracy == 0) ? -E10_FOR_ZERO : 0;
-            }
-            i = -((int) Math.floor(y));
-            scale = pow10(i);
-        }
-        if (strict) {
-            while ((accuracy *= scale) >= 9.5) {
-                i++; // The 0.…95 special case.
-                accuracy -= Math.floor(accuracy);
-                scale = 10;
-            }
-        }
-        return i;
-    }
-
-    /**
-     * Returns the number of significant fraction digits when formatting the given number in base 10.
-     * This method does <strong>not</strong> ignore trailing zeros.
-     * For example {@code fractionDigitsForValue(1.0)} returns 16,
-     * because the {@code double} format can store <i>almost</i> 16 decimal digits after 1.
-     *
-     * {@note We said <i>almost</i> because the very last digit may be able to store only a subset of the
-     *        [0 … 9] digits.}
-     *
-     * Invoking this method is equivalent to invoking <code>{@linkplain #fractionDigitsForDelta(double, boolean)
-     * fractionDigitsForDelta}(Math.{@linkplain Math#ulp(double) ulp}(value), false)</code>, except that it is
-     * potentially faster.
-     *
-     * <p>Special cases:</p>
-     * <ul>
-     *   <li>If {@code value} is {@link Double#NaN NaN} or infinity, then this method returns 0
-     *       since those values are not represented by decimal digits.</li>
-     *
-     *   <li>If {@code value} is 0, then this method returns 324 since
-     *       {@code Math.ulp(0)} = {@value java.lang.Double#MIN_VALUE}.</li>
-     * </ul>
-     *
-     * {@example This method is useful with <code>NumberFormat</code> for formatting all significant digits
-     *           of a <code>double</code> value, padding with trailing zeros if necessary, but no more than
-     *           necessary.}
-     *
-     * @param  value The value for which to get the number of significant digits.
-     * @return The number of significant digits (may be negative), or 0 if {@code value} is NaN or infinity.
-     *
-     * @see java.text.NumberFormat#setMinimumFractionDigits(int)
-     *
-     * @since 0.4
-     */
-    public static int fractionDigitsForValue(final double value) {
-        /*
-         * We really need Math.getExponent(value) here rather than MathFunctions.getExponent(value).
-         * What we actually want is MathFunctions.getExponent(Math.ulp(value)), but we get the same
-         * result more efficiently if we replace the call to Math.ulp(double) by a SIGNIFICAND_SIZE
-         * subtraction in the exponent, provided that the exponent has NOT been corrected for sub-
-         * normal numbers (in order to reproduce the Math.ulp behavior).
-         */
-        final int exponent = Math.getExponent(value);
-        if (exponent <= Double.MAX_EXPONENT) { // Exclude NaN and ±∞ cases.
-            return (int) -Math.floor(LOG10_2 * (exponent - SIGNIFICAND_SIZE));
-        }
-        return 0;
+        return DecimalFunctions.fractionDigitsForDelta(accuracy, strict);
     }
 
     /**
@@ -423,30 +278,29 @@ public final class MathFunctions extends
     }
 
     /**
-     * Computes 10 raised to the power of <var>x</var>. This method delegates to
-     * <code>{@linkplain #pow10(int) pow10}((int) x)</code> if <var>x</var> is an
-     * integer, or to <code>{@linkplain Math#pow(double, double) Math.pow}(10, x)</code>
-     * otherwise.
+     * Computes 10 raised to the power of <var>x</var>. Invoking this method is equivalent to invoking
+     * <code>{@linkplain Math#pow(double, double) Math.pow}(10, x)</code>, but is slightly more accurate
+     * in the special case where the given argument is an integer.
      *
      * @param x The exponent.
      * @return 10 raised to the given exponent.
      *
      * @see #pow10(int)
      * @see Math#pow(double, double)
+     * @see Math#log10(double)
      */
     public static double pow10(final double x) {
         final int ix = (int) x;
         if (ix == x) {
-            return pow10(ix);
+            return DecimalFunctions.pow10(ix);
         } else {
             return Math.pow(10, x);
         }
     }
 
     /**
-     * Computes 10 raised to the power of <var>x</var>. This method tries to be slightly more
-     * accurate than <code>{@linkplain Math#pow(double, double) Math.pow}(10, x)</code>,
-     * sometime at the cost of performance.
+     * Computes 10 raised to the power of <var>x</var>. This method is faster and slightly more accurate
+     * than invoking <code>{@linkplain Math#pow(double, double) Math.pow}(10, x)</code>.
      *
      * {@note This method has been defined because the standard <code>Math.pow(10, x)</code>
      *        method does not always return the closest IEEE floating point representation.
@@ -455,31 +309,23 @@ public final class MathFunctions extends
      *        is a special case since it is used for scaling axes or formatting human-readable
      *        output.}
      *
+     * Special cases:
+     * <ul>
+     *   <li>If <var>x</var> is equals or lower than -324, then the result is 0.</li>
+     *   <li>If <var>x</var> is equals or greater than 309, then the result is {@linkplain Double#POSITIVE_INFINITY positive infinity}.</li>
+     *   <li>If <var>x</var> is in the [0 … 18] range inclusive, then the result is exact.</li>
+     *   <li>For all other <var>x</var> values, the result is the closest IEEE 754 approximation.</li>
+     * </ul>
+     *
      * @param x The exponent.
      * @return 10 raised to the given exponent.
+     *
+     * @see #pow10(double)
+     * @see #LOG10_2
+     * @see DecimalFunctions
      */
-    @Workaround(library="JDK", version="1.4")
     public static double pow10(final int x) {
-        if (x >= 0) {
-            if (x < POW10.length) {
-                return POW10[x];
-            }
-        } else if (x != Integer.MIN_VALUE) {
-            final int nx = -x;
-            if (nx < POW10.length) {
-                return 1 / POW10[nx];
-            }
-        }
-        try {
-            /*
-             * Double.parseDouble("1E"+x) gives as good or better numbers than Math.pow(10,x)
-             * for ALL integer powers, but is slower. We hope that the current workaround is only
-             * temporary. See http://developer.java.sun.com/developer/bugParade/bugs/4358794.html
-             */
-            return Double.parseDouble("1E" + x);
-        } catch (NumberFormatException exception) {
-            return StrictMath.pow(10, x);
-        }
+        return DecimalFunctions.pow10(x);
     }
 
     /**
@@ -648,7 +494,10 @@ public final class MathFunctions extends
      * @return {@code +1} if <var>x</var> is positive, {@code -1} if negative, or 0 otherwise.
      *
      * @see Math#signum(double)
+     *
+     * @deprecated Something close is available in standard Java as {@link Math#signum(double)}.
      */
+    @Deprecated
     public static int sgn(final double x) {
         if (x > 0) return +1;
         if (x < 0) return -1;
@@ -665,7 +514,10 @@ public final class MathFunctions extends
      * @return {@code +1} if <var>x</var> is positive, {@code -1} if negative, or 0 otherwise.
      *
      * @see Math#signum(float)
+     *
+     * @deprecated Something close is available in standard Java as {@link Math#signum(float)}.
      */
+    @Deprecated
     public static int sgn(final float x) {
         if (x > 0) return +1;
         if (x < 0) return -1;
@@ -680,7 +532,10 @@ public final class MathFunctions extends
      *
      * @param x The number from which to get the sign.
      * @return {@code +1} if <var>x</var> is positive, {@code -1} if negative, or 0 otherwise.
+     *
+     * @deprecated Available in standard Java as {@link Long#signum(long)}.
      */
+    @Deprecated
     public static int sgn(long x) {
         if (x > 0) return +1;
         if (x < 0) return -1;
@@ -695,7 +550,10 @@ public final class MathFunctions extends
      *
      * @param x The number from which to get the sign.
      * @return {@code +1} if <var>x</var> is positive, {@code -1} if negative, or 0 otherwise.
+     *
+     * @deprecated Available in standard Java as {@link Integer#signum(int)}.
      */
+    @Deprecated
     public static int sgn(int x) {
         if (x > 0) return +1;
         if (x < 0) return -1;
@@ -710,7 +568,10 @@ public final class MathFunctions extends
      *
      * @param x The number from which to get the sign.
      * @return {@code +1} if <var>x</var> is positive, {@code -1} if negative, or 0 otherwise.
+     *
+     * @deprecated Something close is available in standard Java as {@link Integer#signum(int)}.
      */
+    @Deprecated
     public static short sgn(short x) {
         if (x > 0) return +1;
         if (x < 0) return -1;
@@ -725,7 +586,10 @@ public final class MathFunctions extends
      *
      * @param x The number from which to get the sign.
      * @return {@code +1} if <var>x</var> is positive, {@code -1} if negative, or 0 otherwise.
+     *
+     * @deprecated Something close is available in standard Java as {@link Integer#signum(int)}.
      */
+    @Deprecated
     public static byte sgn(byte x) {
         if (x > 0) return +1;
         if (x < 0) return -1;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java?rev=1540209&r1=1540208&r2=1540209&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java [UTF-8] Fri Nov  8 22:24:13 2013
@@ -398,7 +398,7 @@ public class StatisticsFormat extends Ta
             delta = max(delta/stats.count(), ulp(extremum)); // Mean delta for uniform distribution, not finer than 'double' accuracy.
             if (format instanceof NumberFormat) {
                 setFractionDigits((NumberFormat) format, max(0, ADDITIONAL_DIGITS
-                        + MathFunctions.fractionDigitsForDelta(delta, false)));
+                        + DecimalFunctions.fractionDigitsForDelta(delta, false)));
             } else {
                 // A future version could configure DateFormat here.
             }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java?rev=1540209&r1=1540208&r2=1540209&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java [UTF-8] Fri Nov  8 22:24:13 2013
@@ -39,7 +39,7 @@ import static java.lang.Double.isInfinit
 import static org.apache.sis.math.MathFunctions.pow10;
 import static org.apache.sis.math.MathFunctions.truncate;
 import static org.apache.sis.math.MathFunctions.isNegative;
-import static org.apache.sis.math.MathFunctions.fractionDigitsForDelta;
+import static org.apache.sis.math.DecimalFunctions.fractionDigitsForDelta;
 
 // Related to JDK7
 import org.apache.sis.internal.jdk7.Objects;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1540209&r1=1540208&r2=1540209&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] Fri Nov  8 22:24:13 2013
@@ -461,6 +461,7 @@ public final class Units extends Static 
              * with "deg", then the check should be put in the above block instead.
              */
             if (uom.equals("°")                      || equalsIgnorePlural(uom, "decimal_degree")) return NonSI.DEGREE_ANGLE;
+            if (uom.equalsIgnoreCase("arcsec"))                                                    return NonSI.SECOND_ANGLE;
             if (uom.equalsIgnoreCase("rad")          || equalsIgnorePlural(uom, "radian"))         return SI.RADIAN;
             if (equalsIgnorePlural(uom, "kilometer") || equalsIgnorePlural(uom, "kilometre"))      return SI.KILOMETRE;
             if (equalsIgnorePlural(uom, "meter")     || equalsIgnorePlural(uom, "metre"))          return SI.METRE;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/Numbers.java?rev=1540209&r1=1540208&r2=1540209&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/Numbers.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/Numbers.java [UTF-8] Fri Nov  8 22:24:13 2013
@@ -159,21 +159,6 @@ public final class Numbers extends Stati
     }
 
     /**
-     * Returns {@code true} if the given {@code type} is an integer type. This method performs
-     * the same test than {@link #isPrimitiveInteger}, excluding {@link BigInteger}.
-     *
-     * @param  type The type to test (may be {@code null}).
-     * @return {@code true} if {@code type} is the primitive of wrapper class of
-     *         {@link Long}, {@link Integer}, {@link Short} or {@link Byte}.
-     *
-     * @see #isInteger(Class)
-     */
-    private static boolean isPrimitiveInteger(final Class<?> type) {
-        final Numbers mapping = MAPPING.get(type);
-        return (mapping != null) && mapping.isInteger && (mapping.internal != 'L');
-    }
-
-    /**
      * Returns the number of bits used by primitive of the specified type.
      * The given type must be a primitive type or its wrapper class.
      *
@@ -274,17 +259,16 @@ public final class Numbers extends Stati
                                                       final Class<? extends Number> c2)
             throws IllegalArgumentException
     {
+        if (c1 == null) return c2;
+        if (c2 == null) return c1;
         final Numbers m1 = MAPPING.get(c1);
-        if (m1 == null && c1 != null) {
+        if (m1 == null) {
             throw unknownType(c1);
         }
         final Numbers m2 = MAPPING.get(c2);
-        if (m2 == null && c2 != null) {
+        if (m2 == null) {
             throw unknownType(c2);
         }
-        if (c1 == null) return c2;
-        if (c2 == null) return c1;
-        // At this point, m1 and m2 can not be null.
         return (m1.ordinal >= m2.ordinal) ? c1 : c2;
     }
 
@@ -336,17 +320,16 @@ public final class Numbers extends Stati
                                                          final Class<? extends Number> c2)
             throws IllegalArgumentException
     {
+        if (c1 == null) return c2;
+        if (c2 == null) return c1;
         final Numbers m1 = MAPPING.get(c1);
-        if (m1 == null && c1 != null) {
+        if (m1 == null) {
             throw unknownType(c1);
         }
         final Numbers m2 = MAPPING.get(c2);
-        if (m2 == null && c2 != null) {
+        if (m2 == null) {
             throw unknownType(c2);
         }
-        if (c1 == null) return c2;
-        if (c2 == null) return c1;
-        // At this point, m1 and m2 can not be null.
         return (m1.ordinal < m2.ordinal) ? c1 : c2;
     }
 

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java?rev=1540209&r1=1540208&r2=1540209&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java [UTF-8] Fri Nov  8 22:24:13 2013
@@ -20,6 +20,7 @@ import java.util.Random;
 import java.math.BigDecimal;
 import java.math.MathContext;
 import java.lang.reflect.Field;
+import org.apache.sis.math.DecimalFunctions;
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.TestUtilities;
@@ -40,7 +41,7 @@ import static java.lang.StrictMath.*;
  * @version 0.4
  * @module
  */
-@DependsOn(org.apache.sis.math.MathFunctionsTest.class)
+@DependsOn(org.apache.sis.math.DecimalFunctionsTest.class)
 public final strictfp class DoubleDoubleTest extends TestCase {
     /**
      * Number of time to repeat arithmetic tests.
@@ -289,61 +290,75 @@ public final strictfp class DoubleDouble
     }
 
     /**
-     * List of all {@link DoubleDouble#VALUES} as string decimal representation.
+     * List of all {@link DoubleDouble#VALUES} as string decimal representations,
+     * together with some additional values to test.
      */
     private static final String[] PREDEFINED_VALUES = {
-         "0.000001",
-         "0.00001",
-         "0.0001",
-         "0.00027777777777777777777777777777777778",
-         "0.001",
-         "0.002777777777777777777777777777777778",
-         "0.01",
-         "0.01666666666666666666666666666666667",
-         "0.01745329251994329576923690768488613",
          "0.1",
-         "0.201168",
-         "0.3048",
-         "0.785398163397448309615660845819876",
-         "0.9",
-         "0.9144",
-         "1.111111111111111111111111111111111",
-         "1.414213562373095048801688724209698",
-         "1.570796326794896619231321691639751",
-         "1.8288",
-         "2.356194490192344928846982537459627",
-         "2.54",
-         "3.14159265358979323846264338327950",
-         "6.28318530717958647692528676655901",
-        "20.1168",
-        "57.2957795130823208767981548141052"
+         "0.01",
+         "0.001",
+         "0.0001",
+         "0.00001",
+         "0.000001",
+         "0.3048",                                      // Feet to metres
+         "0.201168",                                    // Link to metres
+         "0.9144",                                      // Yard to metres
+         "1.8288",                                      // Fathom to metres
+        "20.1168",                                      // Chain to metres
+         "2.54",                                        // Inch to centimetres
+         "0.9",                                         // Degrees to gradians
+         "1.111111111111111111111111111111111",         // Gradian to degrees
+         "0.002777777777777777777777777777777778",      // 1/360°
+         "0.0002777777777777777777777777777777778",     // Second to degrees
+         "0.01666666666666666666666666666666667",       // Minute to degrees
+         "0.000004848136811095359935899141023579480",   // Arc-second to radians
+         "0.01745329251994329576923690768488613",       // Degrees to radians
+        "57.2957795130823208767981548141052",           // Radians to degrees
+         "3.14159265358979323846264338327950",          //  π
+         "6.28318530717958647692528676655901",          // 2π
+         "1.570796326794896619231321691639751",         //  π/2
+         "0.785398163397448309615660845819876",         //  π/4
+         "2.356194490192344928846982537459627",         // 3π/4
+         "1.414213562373095048801688724209698"          // √2
     };
 
     /**
-     * Ensures that the {@link DoubleDouble#VALUES} elements are sorted in strictly increasing order.
-     * Also ensures that {@link DoubleDouble#ERRORS} has the same number of elements.
+     * Verifies the {@link DoubleDouble#VALUES} and {@link DoubleDouble#ERRORS} arrays.
+     *
+     * <ul>
+     *   <li>Elements in the {@code VALUES} array shall be sorted in increasing order.</li>
+     *   <li>{@code VALUES} and {@code ERRORS} arrays shall have the same length.</li>
+     *   <li>The arrays do not contains an entry for a value that could be omitted.</li>
+     * </ul>
      *
      * @throws Exception If a reflective operation failed (should never happen).
      */
     @Test
-    public void testValuesSorted() throws Exception {
+    public void testArraysConsistency() throws Exception {
         Field field = DoubleDouble.class.getDeclaredField("VALUES");
         field.setAccessible(true);
-        double[] array = (double[]) field.get(null);
-        assertTrue(ArraysExt.isSorted(array, true));
-        assertEquals(PREDEFINED_VALUES.length, array.length);
+        final double[] values = (double[]) field.get(null);
+        assertTrue(ArraysExt.isSorted(values, true));
 
         field = DoubleDouble.class.getDeclaredField("ERRORS");
         field.setAccessible(true);
-        array = (double[]) field.get(null);
-        assertEquals(PREDEFINED_VALUES.length, array.length);
+        final double[] errors = (double[]) field.get(null);
+        assertEquals(values.length, errors.length);
+
+        for (int i=0; i<values.length; i++) {
+            final double value = values[i];
+            final double delta = DecimalFunctions.deltaForDoubleToDecimal(value);
+            if (delta == errors[i]) {
+                fail("(value,entry) pair for value " + value + " can be omitted.");
+            }
+        }
     }
 
     /**
      * Tests {@link DoubleDouble#errorForWellKnownValue(double)}.
      */
     @Test
-    @DependsOnMethod("testValuesSorted")
+    @DependsOnMethod("testArraysConsistency")
     public void testErrorForWellKnownValue() {
         for (final String text : PREDEFINED_VALUES) {
             final double     value         = Double.valueOf(text);
@@ -375,11 +390,13 @@ public final strictfp class DoubleDouble
         assertEquals(6.123233995736766036E-17, DoubleDouble.errorForWellKnownValue(PI / 2), STRICT);
         assertEquals(3.061616997868383018E-17, DoubleDouble.errorForWellKnownValue(PI / 4), STRICT);
         assertEquals(9.184850993605148436E-17, DoubleDouble.errorForWellKnownValue(PI * (3./4)), STRICT);
+        assertEquals(9.320078015422868E-23,    DoubleDouble.errorForWellKnownValue(PI / (180 * 60 * 60)), STRICT);
 
-        assertTrue("toDegrees", DoubleDouble.errorForWellKnownValue(180 / PI)     != 0);
-        assertTrue("toDegrees", DoubleDouble.errorForWellKnownValue(toDegrees(1)) != 0);
-        assertTrue("toRadians", DoubleDouble.errorForWellKnownValue(PI / 180)     != 0);
-        assertTrue("toRadians", DoubleDouble.errorForWellKnownValue(toRadians(1)) != 0);
+        // Following is actually an anti-regression test.
+        assertEquals("toDegrees", -1.9878495670576283E-15, DoubleDouble.errorForWellKnownValue(180 / PI),     STRICT);
+        assertEquals("toDegrees", -1.9878495670576283E-15, DoubleDouble.errorForWellKnownValue(toDegrees(1)), STRICT);
+        assertEquals("toRadians",  2.9486522708701687E-19, DoubleDouble.errorForWellKnownValue(PI / 180),     STRICT);
+        assertEquals("toRadians",  2.9486522708701687E-19, DoubleDouble.errorForWellKnownValue(toRadians(1)), STRICT);
     }
 
     /**
@@ -392,6 +409,7 @@ public final strictfp class DoubleDouble
             final DoubleDouble dd;
             switch (i) {
                 case 0:  dd = DoubleDouble.createDegreesToRadians(); break;
+                case 1:  dd = DoubleDouble.createSecondsToRadians(); break;
                 default: return; // Test done.
             }
             assertEquals(DoubleDouble.errorForWellKnownValue(dd.value), dd.error, STRICT);

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/NumericsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/NumericsTest.java?rev=1540209&r1=1540208&r2=1540209&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/NumericsTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/NumericsTest.java [UTF-8] Fri Nov  8 22:24:13 2013
@@ -16,6 +16,9 @@
  */
 package org.apache.sis.internal.util;
 
+import java.util.Random;
+import org.apache.sis.math.MathFunctions;
+import org.apache.sis.test.TestUtilities;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -23,7 +26,7 @@ import static java.lang.Double.NaN;
 import static java.lang.Double.POSITIVE_INFINITY;
 import static java.lang.Double.NEGATIVE_INFINITY;
 import static org.apache.sis.internal.util.Numerics.*;
-import static org.apache.sis.test.Assert.*;
+import static org.junit.Assert.*;
 
 
 /**
@@ -36,7 +39,7 @@ import static org.apache.sis.test.Assert
  */
 public final strictfp class NumericsTest extends TestCase {
     /**
-     * Tests the {@link Utilities#epsilonEqual(double, double)} method.
+     * Tests the {@link Numerics#epsilonEqual(double, double)} method.
      */
     @Test
     public void testEpsilonEqual() {
@@ -51,4 +54,82 @@ public final strictfp class NumericsTest
         assertTrue (epsilonEqual(-100, -100 + COMPARISON_THRESHOLD * 50));
         assertFalse(epsilonEqual( 100,  100 + COMPARISON_THRESHOLD * 150));
     }
+
+    /**
+     * Tests the {@link Numerics#toExp10(int)} method over the full [-2620 … 2620] range of values
+     * (the validity range documented by method javadoc). Also verifies our javadoc claim that
+     * {@code toExp10(getExponent(10ⁿ))} returns {@code n-1} except for {@code n == 0}.
+     */
+    @Test
+    public void testToExp10() {
+        for (int i=-2620; i<=2620; i++) {
+            assertEquals(Math.floor(i * MathFunctions.LOG10_2), toExp10(i), 0);
+        }
+        for (int i=-307; i<=308; i++) {
+            final String value = "1E" + i;
+            assertEquals(value, (i == 0) ? i : i-1, toExp10(StrictMath.getExponent(Double.parseDouble(value))));
+        }
+    }
+
+    /**
+     * Tests the {@link Numerics#getSignificand(double)} method.
+     */
+    @Test
+    public void testGetSignificand() {
+        assertSignificandEquals(0x00000000000000L, 0d);
+        assertSignificandEquals(0x10000000000000L, 1d);
+        assertSignificandEquals(0x1F400000000000L, 1000d);
+        assertSignificandEquals(0x1FFFFFFFFFFFFFL, Double.MAX_VALUE);
+        assertSignificandEquals(0x10000000000000L, Double.MIN_NORMAL);
+        assertSignificandEquals(0x00000000000002L, Double.MIN_VALUE);
+        assertSignificandEquals(0x10000000000000L, Double.POSITIVE_INFINITY);
+        assertSignificandEquals(0x10000000000000L, Double.NEGATIVE_INFINITY);
+        final Random random = TestUtilities.createRandomNumberGenerator();
+        for (int i=0; i<100; i++) {
+            final double value = random.nextGaussian();
+            assertSignificandEquals(getSignificand(value), -value);
+        }
+    }
+
+    /**
+     * Tests the {@link Numerics#getSignificand(float)} method.
+     */
+    @Test
+    public void testGetSignificandOfFloat() {
+        assertSignificandEquals(0x000000, 0f);
+        assertSignificandEquals(0x800000, 1f);
+        assertSignificandEquals(0xFA0000, 1000f);
+        assertSignificandEquals(0xFFFFFF, Float.MAX_VALUE);
+        assertSignificandEquals(0x800000, Float.MIN_NORMAL);
+        assertSignificandEquals(0x000002, Float.MIN_VALUE);
+        assertSignificandEquals(0x800000, Float.POSITIVE_INFINITY);
+        assertSignificandEquals(0x800000, Float.NEGATIVE_INFINITY);
+        final Random random = TestUtilities.createRandomNumberGenerator();
+        for (int i=0; i<100; i++) {
+            final float value = (float) random.nextGaussian();
+            assertSignificandEquals(getSignificand(value), -value);
+        }
+    }
+
+    /**
+     * Asserts that {@link Numerics#getSignificand(double)} returns the expected value,
+     * then verify the {@link StrictMath#scalb(double, int)} identity.
+     */
+    private static void assertSignificandEquals(final long expected, final double value) {
+        assertEquals(expected, getSignificand(value));
+        final int e = StrictMath.getExponent(value) - SIGNIFICAND_SIZE;
+        final double recomposed = StrictMath.scalb((double) expected, e);
+        assertEquals(value, StrictMath.copySign(recomposed, value), 0);
+    }
+
+    /**
+     * Asserts that {@link Numerics#getSignificand(float)} returns the expected value,
+     * then verify the {@link StrictMath#scalb(float, int)} identity.
+     */
+    private static void assertSignificandEquals(final int expected, final float value) {
+        assertEquals(expected, getSignificand(value));
+        final int e = StrictMath.getExponent(value) - SIGNIFICAND_SIZE_OF_FLOAT;
+        final float recomposed = StrictMath.scalb((float) expected, e);
+        assertEquals(value, StrictMath.copySign(recomposed, value), 0f);
+    }
 }

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java?rev=1540209&r1=1540208&r2=1540209&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java [UTF-8] Fri Nov  8 22:24:13 2013
@@ -39,19 +39,20 @@ import org.apache.sis.internal.jdk8.JDK8
  * @version 0.4
  * @module
  */
-@DependsOn(org.apache.sis.util.ArraysExtTest.class)
+@DependsOn({
+    org.apache.sis.util.ArraysExtTest.class,
+    org.apache.sis.internal.util.NumericsTest.class
+})
 public final strictfp class MathFunctionsTest extends TestCase {
     /**
-     * Small number for floating point comparisons.
+     * Tolerance threshold for strict comparisons of floating point values.
      */
-    private static final double EPS = 1E-12;
+    private static final double STRICT = 0;
 
     /**
-     * The maximal exponent value such as {@code parseDouble("1E+304")} still a finite number.
-     *
-     * @see Double#MAX_VALUE
+     * Small number for floating point comparisons.
      */
-    private static final int MAX_E10 = 308;
+    private static final double EPS = 1E-12;
 
     /**
      * Highest prime number representable as a signed {@code short}.
@@ -68,12 +69,8 @@ public final strictfp class MathFunction
      */
     @Test
     public void testConstants() {
-        assertEquals(StrictMath.sqrt (2), MathFunctions.SQRT_2,  0);
-        assertEquals(StrictMath.log10(2), MathFunctions.LOG10_2, 0);
-        assertEquals(0,  parseDouble("1E" +  E10_FOR_ZERO), 0);
-        assertTrue  (0 < parseDouble("1E" + (E10_FOR_ZERO + 1)));
-        assertTrue  (POSITIVE_INFINITY > parseDouble("1E" +  MAX_E10));
-        assertEquals(POSITIVE_INFINITY,  parseDouble("1E" + (MAX_E10 + 1)), 0);
+        assertEquals(StrictMath.sqrt (2), SQRT_2,  STRICT);
+        assertEquals(StrictMath.log10(2), LOG10_2, STRICT);
     }
 
     /**
@@ -82,10 +79,10 @@ public final strictfp class MathFunction
     @Test
     @DependsOnMethod({"testIsPositiveZero", "testIsNegativeZero"})
     public void testTruncate() {
-        assertEquals(+4.0, truncate(+4.9), 0);
-        assertEquals(-4.0, truncate(-4.9), 0);
-        assertEquals(+0.0, truncate(+0.1), 0);
-        assertEquals(-0.0, truncate(-0.1), 0);
+        assertEquals(+4.0, truncate(+4.9), STRICT);
+        assertEquals(-4.0, truncate(-4.9), STRICT);
+        assertEquals(+0.0, truncate(+0.1), STRICT);
+        assertEquals(-0.0, truncate(-0.1), STRICT);
         assertTrue("Positive zero", isPositiveZero(truncate(+0.5)));
         assertTrue("Negative zero", isNegativeZero(truncate(-0.5)));
         assertTrue("Positive zero", isPositiveZero(truncate(+0.0)));
@@ -104,81 +101,6 @@ public final strictfp class MathFunction
     }
 
     /**
-     * Tests {@link MathFunctions#fractionDigitsForDelta(double, boolean)}.
-     */
-    @Test
-    public void testFractionDigitsForDelta() {
-        assertEquals(3, fractionDigitsForDelta(0.001, true));
-        assertEquals(3, fractionDigitsForDelta(0.009, true));
-        assertEquals(2, fractionDigitsForDelta(0.010, true));
-        assertEquals(2, fractionDigitsForDelta(0.015, true));
-        assertEquals(1, fractionDigitsForDelta(0.100, true));
-        assertEquals(1, fractionDigitsForDelta(0.125, true));
-        assertEquals(1, fractionDigitsForDelta(0.949, true));
-        assertEquals(2, fractionDigitsForDelta(0.994, true)); // Special case
-        assertEquals(3, fractionDigitsForDelta(0.999, true)); // Special case
-
-        assertEquals( 0, fractionDigitsForDelta(  1.0, true));
-        assertEquals( 0, fractionDigitsForDelta(  1.9, true));
-        assertEquals( 0, fractionDigitsForDelta(  9.1, true));
-        assertEquals(-1, fractionDigitsForDelta( 10.0, true));
-        assertEquals(-1, fractionDigitsForDelta( 19.9, true));
-        assertEquals(-1, fractionDigitsForDelta( 94.9, true));
-        assertEquals( 0, fractionDigitsForDelta( 99.0, true)); // Special case
-        assertEquals(-2, fractionDigitsForDelta(100.0, true));
-        assertEquals(-2, fractionDigitsForDelta(100.1, true));
-        assertEquals(-1, fractionDigitsForDelta(994.9, true)); // Special case
-        assertEquals(+1, fractionDigitsForDelta(999.9, true)); // Special case
-        assertEquals(-3, fractionDigitsForDelta(1000,  true));
-
-        // Tests values out of the POW10 array range.
-        assertEquals(23,  fractionDigitsForDelta(1.0E-23,  true));
-        assertEquals(23,  fractionDigitsForDelta(1.9E-23,  true));
-        assertEquals(23,  fractionDigitsForDelta(9.1E-23,  true));
-        assertEquals(24,  fractionDigitsForDelta(9.6E-23,  true)); // Special case
-        assertEquals(300, fractionDigitsForDelta(1.1E-300, true));
-
-        assertEquals(-23,  fractionDigitsForDelta(1.0E+23,  true));
-        assertEquals(-23,  fractionDigitsForDelta(1.9E+23,  true));
-        assertEquals(-23,  fractionDigitsForDelta(9.1E+23,  true));
-        assertEquals(-22,  fractionDigitsForDelta(9.6E+23,  true)); // Special case
-        assertEquals(-300, fractionDigitsForDelta(1.1E+300, true));
-
-        // Other cases.
-        assertEquals(-E10_FOR_ZERO, fractionDigitsForDelta(0,                 false));
-        assertEquals(-E10_FOR_ZERO, fractionDigitsForDelta(MIN_VALUE,         false));
-        assertEquals(           16, fractionDigitsForDelta(Math.ulp(1.0),     false));
-        assertEquals(           15, fractionDigitsForDelta(Math.ulp(45.0),    false));
-        assertEquals(            0, fractionDigitsForDelta(NaN,               false));
-        assertEquals(            0, fractionDigitsForDelta(POSITIVE_INFINITY, false));
-        assertEquals(            0, fractionDigitsForDelta(NEGATIVE_INFINITY, false));
-    }
-
-    /**
-     * Tests {@link MathFunctions#fractionDigitsForValue(double)}.
-     */
-    @Test
-    public void testFractionDigitsForValue() {
-        assertEquals(-E10_FOR_ZERO, fractionDigitsForValue(0));
-        assertEquals(-E10_FOR_ZERO, fractionDigitsForValue(MIN_VALUE));
-        assertEquals(           16, fractionDigitsForValue(1));
-        assertEquals(           15, fractionDigitsForValue(45));
-        assertEquals(            0, fractionDigitsForValue(NaN));
-        assertEquals(            0, fractionDigitsForValue(POSITIVE_INFINITY));
-        assertEquals(            0, fractionDigitsForValue(NEGATIVE_INFINITY));
-        for (int i=E10_FOR_ZERO; i<=MAX_E10; i++) {
-            final double value = pow10(i);
-            final double accuracy = pow10(-fractionDigitsForValue(value));
-            assertEquals("Shall not be greater than ULP", 0, accuracy, StrictMath.ulp(value));
-        }
-        for (int i=MIN_EXPONENT; i<=MAX_EXPONENT; i++) {
-            final double value = StrictMath.scalb(1, i);
-            final double accuracy = pow10(-fractionDigitsForValue(value));
-            assertEquals("Shall not be greater than ULP", 0, accuracy, StrictMath.ulp(value));
-        }
-    }
-
-    /**
      * Tests the {@link MathFunctions#getExponent(double)} method.
      * This method performs two tests:
      *
@@ -227,19 +149,7 @@ public final strictfp class MathFunction
          */
         for (int i = MIN_EXPONENT - SIGNIFICAND_SIZE; i <= MAX_EXPONENT; i++) {
             assertEquals(StrictMath.floor(StrictMath.log10(StrictMath.scalb(1.0, i))),
-                         StrictMath.floor(LOG10_2 * i /* i = getExponent(value) */), 0);
-        }
-    }
-
-    /**
-     * Tests the {@link MathFunctions#pow10(double)} method.
-     * This will indirectly test {@link MathFunctions#pow10(int)}
-     * since the former will delegate to the later in this test.
-     */
-    @Test
-    public void testPow10() {
-        for (int i=E10_FOR_ZERO; i<=MAX_E10; i++) { // Range of allowed exponents in base 10.
-            assertEquals(parseDouble("1E"+i), pow10((double) i), 0);
+                         StrictMath.floor(LOG10_2 * i /* i = getExponent(value) */), STRICT);
         }
     }
 
@@ -284,10 +194,10 @@ public final strictfp class MathFunction
      */
     @Test
     public void testXorSign() {
-        assertEquals( 10, xorSign( 10,  0.5), 0);
-        assertEquals(-10, xorSign(-10,  0.5), 0);
-        assertEquals( 10, xorSign(-10, -0.5), 0);
-        assertEquals(-10, xorSign( 10, -0.5), 0);
+        assertEquals( 10, xorSign( 10,  0.5), STRICT);
+        assertEquals(-10, xorSign(-10,  0.5), STRICT);
+        assertEquals( 10, xorSign(-10, -0.5), STRICT);
+        assertEquals(-10, xorSign( 10, -0.5), STRICT);
     }
 
     /**

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java?rev=1540209&r1=1540208&r2=1540209&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java [UTF-8] Fri Nov  8 22:24:13 2013
@@ -52,6 +52,11 @@ public final strictfp class StatisticsTe
     private static final double EPS = 1E-10;
 
     /**
+     * Tolerance threshold for strict comparisons of floating point values.
+     */
+    private static final double STRICT = 0;
+
+    /**
      * Tests the initial state of newly constructed instance.
      */
     @Test
@@ -217,8 +222,8 @@ public final strictfp class StatisticsTe
             }
             assertEquals(global.count(),    byBlock.count());
             assertEquals(global.countNaN(), byBlock.countNaN());
-            assertEquals(global.minimum(),  byBlock.minimum(), 0.0);
-            assertEquals(global.maximum(),  byBlock.maximum(), 0.0);
+            assertEquals(global.minimum(),  byBlock.minimum(), STRICT);
+            assertEquals(global.maximum(),  byBlock.maximum(), STRICT);
             assertEquals(global.mean(),     byBlock.mean(),    1E-15);
             assertEquals(global.rms(),      byBlock.rms(),     1E-15);
         }
@@ -240,8 +245,8 @@ public final strictfp class StatisticsTe
         assertNotSame(statistics, after);
         assertEquals( 3,                 after.count());
         assertEquals( 1,                 after.countNaN());
-        assertEquals(10.0,               after.minimum(),                0.0);
-        assertEquals(40.0,               after.maximum(),                0.0);
+        assertEquals(10.0,               after.minimum(),             STRICT);
+        assertEquals(40.0,               after.maximum(),             STRICT);
         assertEquals(23.333333333333333, after.mean(),                   EPS);
         assertEquals(26.457513110645905, after.rms(),                    EPS);
         assertEquals(12.472191289246473, after.standardDeviation(true),  EPS);

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java?rev=1540209&r1=1540208&r2=1540209&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java [UTF-8] Fri Nov  8 22:24:13 2013
@@ -238,6 +238,7 @@ public final strictfp class UnitsTest ex
         assertSame(DEGREE_ANGLE, valueOf("degrees_east"));
         assertSame(DEGREE_ANGLE, valueOf("degrées_north"));
         assertSame(DEGREE_ANGLE, valueOf("decimal_degree"));
+        assertSame(SECOND_ANGLE, valueOf("arcsec"));
         assertSame(RADIAN,       valueOf("rad"));
         assertSame(RADIAN,       valueOf("radian"));
         assertSame(RADIAN,       valueOf("radians"));

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java?rev=1540209&r1=1540208&r2=1540209&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java [UTF-8] Fri Nov  8 22:24:13 2013
@@ -223,6 +223,7 @@ public final strictfp class TestUtilitie
 
     /**
      * Returns a unlocalized string representation of {@code NAME} and {@code VALUE} columns of the given tree table.
+     * Dates and times, if any, will be formatted using the {@code "yyyy-MM-dd HH:mm:ss"} pattern in UTC timezone.
      * This method is used mostly as a convenient way to verify the content of an ISO 19115 metadata object.
      *
      * @param  table The table for which to get a string representation.

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1540209&r1=1540208&r2=1540209&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] Fri Nov  8 22:24:13 2013
@@ -36,6 +36,8 @@ import org.junit.BeforeClass;
     org.apache.sis.internal.test.XMLComparatorTest.class,
 
     // Most basic functions of SIS library.
+    org.apache.sis.internal.jdk8.JDK8Test.class,
+    org.apache.sis.internal.util.NumericsTest.class,
     org.apache.sis.setup.OptionKeyTest.class,
     org.apache.sis.util.ArraysExtTest.class,
     org.apache.sis.util.CharactersTest.class,
@@ -54,12 +56,11 @@ import org.junit.BeforeClass;
     org.apache.sis.util.logging.MonolineFormatterTest.class,
     org.apache.sis.util.logging.LoggerAdapterTest.class,
     org.apache.sis.math.MathFunctionsTest.class,
+    org.apache.sis.math.DecimalFunctionsTest.class,
     org.apache.sis.math.StatisticsTest.class,
     org.apache.sis.math.StatisticsFormatTest.class,
     org.apache.sis.internal.util.UtilitiesTest.class,
-    org.apache.sis.internal.util.NumericsTest.class,
     org.apache.sis.internal.util.DoubleDoubleTest.class,
-    org.apache.sis.internal.jdk8.JDK8Test.class,
 
     // Collections.
     org.apache.sis.internal.util.CheckedArrayListTest.class,

Modified: sis/branches/JDK6/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java?rev=1540209&r1=1540208&r2=1540209&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java [UTF-8] Fri Nov  8 22:24:13 2013
@@ -110,22 +110,10 @@ public final strictfp class MetadataRead
             "  │   ├─Cell geometry…………………………………………………………………… Area\n" +
             "  │   └─Transformation parameter availability…… false\n" +
             "  ├─Identification info\n" +
-            "  │   ├─Spatial representation type……………………………… Grid\n" +
-            "  │   ├─Extent\n" +
-            "  │   │   ├─Geographic element\n" +
-            "  │   │   │   ├─West bound longitude…………………………… 180°W\n" +
-            "  │   │   │   ├─East bound longitude…………………………… 180°E\n" +
-            "  │   │   │   ├─South bound latitude…………………………… 90°S\n" +
-            "  │   │   │   ├─North bound latitude…………………………… 90°N\n" +
-            "  │   │   │   └─Extent type code……………………………………… true\n" +
-            "  │   │   └─Vertical element\n" +
-            "  │   │       ├─Minimum value……………………………………………… 0.0\n" +
-            "  │   │       └─Maximum value……………………………………………… 0.0\n" +
-            "  │   ├─Abstract………………………………………………………………………………… NCEP SST Global 5.0 x 2.5 degree model data\n" +
             "  │   ├─Citation\n" +
             "  │   │   ├─Title……………………………………………………………………………… Sea Surface Temperature Analysis Model\n" +
             "  │   │   ├─Date\n" +
-            "  │   │   │   ├─Date……………………………………………………………………… 2005/09/22 00:00:00\n" +
+            "  │   │   │   ├─Date……………………………………………………………………… 2005-09-22 00:00:00\n" +
             "  │   │   │   └─Date type………………………………………………………… Creation\n" +
             "  │   │   ├─Identifier\n" +
             "  │   │   │   ├─Code……………………………………………………………………… NCEP/SST/Global_5x2p5deg/SST_Global_5x2p5deg_20050922_0000.nc\n" +
@@ -134,20 +122,32 @@ public final strictfp class MetadataRead
             "  │   │   └─Cited responsible party\n" +
             "  │   │       ├─Individual name………………………………………… NOAA/NWS/NCEP\n" +
             "  │   │       └─Role……………………………………………………………………… Originator\n" +
+            "  │   ├─Abstract………………………………………………………………………………… NCEP SST Global 5.0 x 2.5 degree model data\n" +
+            "  │   ├─Point of contact\n" +
+            "  │   │   ├─Individual name…………………………………………………… NOAA/NWS/NCEP\n" +
+            "  │   │   └─Role………………………………………………………………………………… Point of contact\n" +
             "  │   ├─Descriptive keywords\n" +
             "  │   │   ├─Keyword………………………………………………………………………… EARTH SCIENCE > Oceans > Ocean Temperature > Sea Surface Temperature\n" +
             "  │   │   ├─Type………………………………………………………………………………… Theme\n" +
             "  │   │   └─Thesaurus name\n" +
             "  │   │       └─Title…………………………………………………………………… GCMD Science Keywords\n" +
-            "  │   ├─Point of contact\n" +
-            "  │   │   ├─Individual name…………………………………………………… NOAA/NWS/NCEP\n" +
-            "  │   │   └─Role………………………………………………………………………………… Point of contact\n" +
-            "  │   └─Resource constraints\n" +
-            "  │       └─Use limitation……………………………………………………… Freely available\n" +
+            "  │   ├─Resource constraints\n" +
+            "  │   │   └─Use limitation……………………………………………………… Freely available\n" +
+            "  │   ├─Spatial representation type……………………………… Grid\n" +
+            "  │   └─Extent\n" +
+            "  │       ├─Geographic element\n" +
+            "  │       │   ├─West bound longitude…………………………… 180°W\n" +
+            "  │       │   ├─East bound longitude…………………………… 180°E\n" +
+            "  │       │   ├─South bound latitude…………………………… 90°S\n" +
+            "  │       │   ├─North bound latitude…………………………… 90°N\n" +
+            "  │       │   └─Extent type code……………………………………… true\n" +
+            "  │       └─Vertical element\n" +
+            "  │           ├─Minimum value……………………………………………… 0.0\n" +
+            "  │           └─Maximum value……………………………………………… 0.0\n" +
             "  ├─Content info\n" +
             "  │   └─Dimension\n" +
-            "  │       ├─Descriptor………………………………………………………………… Sea temperature\n" +
-            "  │       └─Sequence identifier………………………………………… SST\n" +
+            "  │       ├─Sequence identifier………………………………………… SST\n" +
+            "  │       └─Descriptor………………………………………………………………… Sea temperature\n" +
             "  └─Data quality info\n" +
             "      └─Lineage\n" +
             "          └─Statement…………………………………………………………………… 2003-04-07 12:12:50 - created by gribtocdl" +



Mime
View raw message