commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r322442 - in /jakarta/commons/proper/math/trunk: ./ src/java/org/apache/commons/math/analysis/ src/java/org/apache/commons/math/complex/ src/java/org/apache/commons/math/linear/ src/java/org/apache/commons/math/stat/descriptive/moment/ src/...
Date Sun, 16 Oct 2005 03:29:22 GMT
Author: psteitz
Date: Sat Oct 15 20:29:14 2005
New Revision: 322442

URL: http://svn.apache.org/viewcvs?rev=322442&view=rev
Log:
Merging bug fixes in r267517:r321515 from MATH_1_1 branch.

Modified:
    jakarta/commons/proper/math/trunk/maven.xml
    jakarta/commons/proper/math/trunk/project.xml
    jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/BisectionSolver.java
    jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java
    jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
    jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Skewness.java
    jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Max.java
    jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Min.java
    jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java
    jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java
    jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/ResizableDoubleArray.java
    jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java
    jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/StatUtilsTest.java
    jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/rank/MaxTest.java
    jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/rank/MinTest.java
    jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/util/MathUtilsTest.java
    jakarta/commons/proper/math/trunk/xdocs/changes.xml

Modified: jakarta/commons/proper/math/trunk/maven.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/maven.xml?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/maven.xml (original)
+++ jakarta/commons/proper/math/trunk/maven.xml Sat Oct 15 20:29:14 2005
@@ -47,6 +47,8 @@
   
   <preGoal name="dist:build-src">
     <copy todir="${maven.dist.src.assembly.dir}">
+      <fileset file='${basedir}/checkstyle.xml'/>
+      <fileset file='${basedir}/license-header.txt'/>
       <fileset file='${basedir}/NOTICE.txt'/>
       <fileset file='${basedir}/RELEASE-NOTES.txt'/>
     </copy>

Modified: jakarta/commons/proper/math/trunk/project.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/project.xml?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/project.xml (original)
+++ jakarta/commons/proper/math/trunk/project.xml Sat Oct 15 20:29:14 2005
@@ -84,6 +84,11 @@
       <name>1.1</name>
       <tag>MATH_1_1_RC1</tag>
     </version>
+    <version>
+      <id>1.1-RC3</id>
+      <name>1.1</name>
+      <tag>MATH_1_1_RC3</tag>
+    </version>
   </versions>
   <developers>
     <developer>
@@ -140,6 +145,9 @@
     </contributor>
     <contributor>
       <name>Christopher Schuck</name>
+    </contributor>
+    <contributor>
+      <name>Mauro Talevi</name>
     </contributor>
     <contributor>
       <name>Kim van der Linde</name>

Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/BisectionSolver.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/BisectionSolver.java?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/BisectionSolver.java
(original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/BisectionSolver.java
Sat Oct 15 20:29:14 2005
@@ -87,7 +87,6 @@
             if (fm * fmin > 0.0) {
                 // max and m bracket the root.
                 min = m;
-                fmin = fm;
             } else {
                 // min and m bracket the root.
                 max = m;

Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java
(original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java
Sat Oct 15 20:29:14 2005
@@ -17,6 +17,7 @@
 package org.apache.commons.math.complex;
 
 import java.io.Serializable;
+import org.apache.commons.math.util.MathUtils;
 
 /**
  * Representation of a Complex number - a number which has both a 
@@ -33,7 +34,7 @@
     /** The square root of -1. A number representing "0.0 + 1.0i".*/    
     public static final Complex I = new Complex(0.0, 1.0);
     
-    /** A complex number representing "(Double.NaN) + (Double.NaN)i" */
+    /** A complex number analogous to {@link java.lang.Double#NaN} */
     public static final Complex NaN = new Complex(Double.NaN, Double.NaN);
 
     /** A complex number representing "1.0 + 0.0i" */    
@@ -147,9 +148,16 @@
     }
     
     /**
-     * Test for the equality of two Complex objects.  If both the
-     * real and imaginary parts of two Complex numbers are exactly
-     * the same, the two Complex objects are considered to be equal.
+     * Test for the equality of two Complex objects.
+     * <p>
+     * If both the real and imaginary parts of two Complex numbers
+     * are exactly the same, and neither is <code>Double.NaN</code>, the two
+     * Complex objects are considered to be equal. 
+     * <p>
+     * All <code>NaN</code> values are considered to be equal - i.e, if either
+     * (or both) real and imaginary parts of the complex number are equal
+     * to Double.NaN, the complex number is equal to 
+     * <code>Complex.NaN</code>.
      *
      * @param other Object to test for equality to this
      * @return true if two Complex objects are equal, false if
@@ -164,20 +172,39 @@
             ret = true;
         } else if (other == null) {
             ret = false;
-        } else {
+        } else  {
             try {
                 Complex rhs = (Complex)other;
+                if (rhs.isNaN()) {
+                    ret = this.isNaN();
+                } else {
                 ret = (Double.doubleToRawLongBits(real) ==
                         Double.doubleToRawLongBits(rhs.getReal())) &&
                     (Double.doubleToRawLongBits(imaginary) ==
                         Double.doubleToRawLongBits(rhs.getImaginary())); 
+                }
             } catch (ClassCastException ex) {
                 // ignore exception
                 ret = false;
             }
         }
-        
+      
         return ret;
+    }
+    
+    /**
+     * Get a hashCode for the complex number.
+     * <p>
+     * All NaN values have the same hash code.
+     * 
+     * @return a hash code value for this object
+     */
+    public int hashCode() {
+        if (isNaN()) {
+            return 7;
+        }
+        return 37 * (17 * MathUtils.hash(imaginary) + 
+            MathUtils.hash(real));
     }
 
     /**

Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealMatrixImpl.java?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
(original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
Sat Oct 15 20:29:14 2005
@@ -871,7 +871,8 @@
     /**
      * Returns true iff <code>object</code> is a 
      * <code>RealMatrixImpl</code> instance with the same dimensions as this
-     *  and all corresponding matrix entries are equal.
+     * and all corresponding matrix entries are equal.  Corresponding entries
+     * are compared using {@link java.lang.Double#doubleToLongBits(double)}
      * 
      * @param object the object to test equality against.
      * @return true if object equals this
@@ -891,7 +892,8 @@
         }
         for (int row = 0; row < nRows; row++) {
             for (int col = 0; col < nCols; col++) {
-                if (data[row][col] != m.getEntry(row, col)) {
+                if (Double.doubleToLongBits(data[row][col]) != 
+                    Double.doubleToLongBits(m.getEntry(row, col))) {
                     return false;
                 }
             }

Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Skewness.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Skewness.java?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Skewness.java
(original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Skewness.java
Sat Oct 15 20:29:14 2005
@@ -91,15 +91,13 @@
             return Double.NaN;
         }
         double variance = moment.m2 / (double) (moment.n - 1);
-        double skewness = Double.NaN;
         if (variance < 10E-20) {
-            skewness = 0.0;
+            return 0.0d;
         } else {
             double n0 = (double) moment.getN();
-            skewness = (n0 * moment.m3) /
+            return  (n0 * moment.m3) /
             ((n0 - 1) * (n0 -2) * Math.sqrt(variance) * variance);
         }
-        return skewness;
     }
 
     /**

Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Max.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Max.java?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Max.java
(original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Max.java
Sat Oct 15 20:29:14 2005
@@ -112,7 +112,9 @@
         if (test(values, begin, length)) {
             max = values[begin];
             for (int i = begin; i < begin + length; i++) {
-                max = (max > values[i]) ? max : values[i];
+                if (!Double.isNaN(values[i])) {
+                    max = (max > values[i]) ? max : values[i];
+                }
             }
         }
         return max;

Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Min.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Min.java?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Min.java
(original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Min.java
Sat Oct 15 20:29:14 2005
@@ -114,7 +114,9 @@
         if (test(values, begin, length)) {
             min = values[begin];
             for (int i = begin; i < begin + length; i++) {
-                min = (min < values[i]) ? min : values[i];
+                if (!Double.isNaN(values[i])) {
+                    min = (min < values[i]) ? min : values[i];
+                }
             }
         }
         return min;

Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java
(original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java
Sat Oct 15 20:29:14 2005
@@ -186,13 +186,13 @@
         if ((p > 100) || (p <= 0)) {
             throw new IllegalArgumentException("invalid quantile value: " + p);
         }
-        double n = (double) length;
-        if (n == 0) {
+        if (length == 0) {
             return Double.NaN;
         }
-        if (n == 1) {
+        if (length == 1) {
             return values[begin]; // always return single value for n = 1
         }
+        double n = (double) length;
         double pos = p * (n + 1) / 100;
         double fpos = Math.floor(pos);
         int intPos = (int) fpos;

Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java
(original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java
Sat Oct 15 20:29:14 2005
@@ -733,7 +733,7 @@
     public static int subAndCheck(int x, int y) {
         long s = (long)x - (long)y;
         if (s < Integer.MIN_VALUE || s > Integer.MAX_VALUE) {
-            throw new ArithmeticException("overflow: add");
+            throw new ArithmeticException("overflow: subtract");
         }
         return (int)s;
     }

Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/ResizableDoubleArray.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/ResizableDoubleArray.java?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/ResizableDoubleArray.java
(original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/ResizableDoubleArray.java
Sat Oct 15 20:29:14 2005
@@ -451,21 +451,19 @@
      * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than
      *         zero or is greater than <code>getNumElements() - 1</code>.
      */
-    public double getElement(int index) {
-        double value = Double.NaN;
+    public synchronized double getElement(int index) {
         if (index >= numElements) {
             String msg =
                 "The index specified: " + index +
                 " is larger than the current number of elements";
             throw new ArrayIndexOutOfBoundsException(msg);
         } else if (index >= 0) {
-            value = internalArray[startIndex + index];
+            return internalArray[startIndex + index];
         } else {
             String msg =
                 "Elements cannot be retrieved from a negative array index";
             throw new ArrayIndexOutOfBoundsException(msg);
         }
-        return value;
     }
     
      /**
@@ -475,7 +473,7 @@
      *  array have no effect on this <code>ResizableArray.</code>
      * @return the double array.
      */
-    public double[] getElements() {
+    public synchronized double[] getElements() {
         double[] elementArray = new double[numElements];
         System.arraycopy( internalArray, startIndex, elementArray, 0,
                 numElements);
@@ -517,7 +515,7 @@
      * 
      * @return the length of the internal storage array.
      */
-    int getInternalLength() {
+    synchronized int getInternalLength() {
         return (internalArray.length);
     }
 
@@ -527,7 +525,7 @@
      *
      * @return number of elements
      */
-    public int getNumElements() {
+    public synchronized int getNumElements() {
         return (numElements);
     }
     
@@ -542,7 +540,7 @@
      * 
      * @return the internal storage array used by this object
      */
-    public double[] getValues() {
+    public synchronized double[] getValues() {
         return (internalArray);
     }
 
@@ -683,7 +681,7 @@
      *
      * @return starting index
      */
-    public int start() {
+    public synchronized int start() {
         return startIndex;
     }
 

Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java
(original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java
Sat Oct 15 20:29:14 2005
@@ -161,4 +161,25 @@
         Complex y = new Complex(0.0, 0.0 + Double.MIN_VALUE);
         assertFalse(x.equals(y));
     }
+    
+    public void testEqualsNaN() {
+        Complex realNaN = new Complex(Double.NaN, 0.0);
+        Complex imaginaryNaN = new Complex(0.0, Double.NaN);
+        Complex complexNaN = Complex.NaN;
+        assertTrue(realNaN.equals(imaginaryNaN));
+        assertTrue(imaginaryNaN.equals(complexNaN));
+        assertTrue(realNaN.equals(complexNaN));
+    }
+    
+    public void testHashCode() {
+        Complex x = new Complex(0.0, 0.0);
+        Complex y = new Complex(0.0, 0.0 + Double.MIN_VALUE);
+        assertFalse(x.hashCode()==y.hashCode());
+        y = new Complex(0.0 + Double.MIN_VALUE, 0.0);
+        assertFalse(x.hashCode()==y.hashCode());
+        Complex realNaN = new Complex(Double.NaN, 0.0);
+        Complex imaginaryNaN = new Complex(0.0, Double.NaN);
+        assertEquals(realNaN.hashCode(), imaginaryNaN.hashCode());
+        assertEquals(imaginaryNaN.hashCode(), Complex.NaN.hashCode());
+    }
 }

Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/StatUtilsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/StatUtilsTest.java?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/StatUtilsTest.java
(original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/StatUtilsTest.java
Sat Oct 15 20:29:14 2005
@@ -42,6 +42,7 @@
     private double skewness = 0;
     private double kurtosis = 0.5;
     private double tolerance = 10E-15;
+    private double nan = Double.NaN;
 
     public StatUtilsTest(String name) {
         super(name);
@@ -296,6 +297,22 @@
         // test many
         x = new double[] {one, two, two, three};
         TestUtils.assertEquals(three, StatUtils.max(x, 1, 3), tolerance);
+
+        // test first nan is ignored
+        x = new double[] {nan, two, three};
+        TestUtils.assertEquals(three, StatUtils.max(x), tolerance);
+
+        // test middle nan is ignored
+        x = new double[] {one, nan, three};
+        TestUtils.assertEquals(three, StatUtils.max(x), tolerance);
+        
+        // test last nan is ignored
+        x = new double[] {one, two, nan};
+        TestUtils.assertEquals(two, StatUtils.max(x), tolerance);
+
+        // test all nan returns nan
+        x = new double[] {nan, nan, nan};
+        TestUtils.assertEquals(nan, StatUtils.max(x), tolerance);
     }
     
     public void testMin() {
@@ -319,6 +336,22 @@
         // test many
         x = new double[] {one, two, two, three};
         TestUtils.assertEquals(two, StatUtils.min(x, 1, 3), tolerance);
+
+        // test first nan is ignored
+        x = new double[] {nan, two, three};
+        TestUtils.assertEquals(two, StatUtils.min(x), tolerance);
+
+        // test middle nan is ignored
+        x = new double[] {one, nan, three};
+        TestUtils.assertEquals(one, StatUtils.min(x), tolerance);
+        
+        // test last nan is ignored
+        x = new double[] {one, two, nan};
+        TestUtils.assertEquals(one, StatUtils.min(x), tolerance);
+
+        // test all nan returns nan
+        x = new double[] {nan, nan, nan};
+        TestUtils.assertEquals(nan, StatUtils.min(x), tolerance);
     }
     
     public void testPercentile() {

Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/rank/MaxTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/rank/MaxTest.java?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/rank/MaxTest.java
(original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/rank/MaxTest.java
Sat Oct 15 20:29:14 2005
@@ -72,4 +72,13 @@
         assertEquals(Double.POSITIVE_INFINITY, max.evaluate(testArray), 0);     
     }
 
+    public void testNaNs() {
+        Max max = new Max();
+        double nan = Double.NaN;
+        assertEquals(3d, max.evaluate(new double[]{nan, 2d, 3d}), 0);     
+        assertEquals(3d, max.evaluate(new double[]{1d, nan, 3d}), 0);     
+        assertEquals(2d, max.evaluate(new double[]{1d, 2d, nan}), 0);     
+        assertTrue(Double.isNaN(max.evaluate(new double[]{nan, nan, nan})));     
+    }
+
 }

Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/rank/MinTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/rank/MinTest.java?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/rank/MinTest.java
(original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/rank/MinTest.java
Sat Oct 15 20:29:14 2005
@@ -72,4 +72,13 @@
         assertEquals(Double.NEGATIVE_INFINITY, min.evaluate(testArray), 0);     
     }
 
+    public void testNaNs() {
+        Min min = new Min();
+        double nan = Double.NaN;
+        assertEquals(2d, min.evaluate(new double[]{nan, 2d, 3d}), 0);     
+        assertEquals(1d, min.evaluate(new double[]{1d, nan, 3d}), 0);     
+        assertEquals(1d, min.evaluate(new double[]{1d, 2d, nan}), 0);     
+        assertTrue(Double.isNaN(min.evaluate(new double[]{nan, nan, nan})));     
+    }
+    
 }

Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/util/MathUtilsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/util/MathUtilsTest.java?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/util/MathUtilsTest.java
(original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/util/MathUtilsTest.java
Sat Oct 15 20:29:14 2005
@@ -46,9 +46,11 @@
         assertEquals(big, MathUtils.addAndCheck(big, 0));
         try {
             int res = MathUtils.addAndCheck(big, 1);
+            fail("Expecting ArithmeticException");
         } catch (ArithmeticException ex) {}
         try {
             int res = MathUtils.addAndCheck(bigNeg, -1);
+            fail("Expecting ArithmeticException");
         } catch (ArithmeticException ex) {}
     }
     
@@ -58,9 +60,11 @@
         assertEquals(big, MathUtils.mulAndCheck(big, 1));
         try {
             int res = MathUtils.mulAndCheck(big, 2);
+            fail("Expecting ArithmeticException");
         } catch (ArithmeticException ex) {}
         try {
             int res = MathUtils.mulAndCheck(bigNeg, 2);
+            fail("Expecting ArithmeticException");
         } catch (ArithmeticException ex) {}
     }
     
@@ -70,10 +74,23 @@
         assertEquals(big, MathUtils.subAndCheck(big, 0));
         try {
             int res = MathUtils.subAndCheck(big, -1);
+            fail("Expecting ArithmeticException");
         } catch (ArithmeticException ex) {}
         try {
             int res = MathUtils.subAndCheck(bigNeg, 1);
+            fail("Expecting ArithmeticException");
         } catch (ArithmeticException ex) {}
+    }
+    
+    public void testSubAndCheckErrorMessage() {
+        int big = Integer.MAX_VALUE;
+        int bigNeg = Integer.MIN_VALUE;
+        try {
+            int res = MathUtils.subAndCheck(big, -1);
+            fail("Expecting ArithmeticException");
+        } catch (ArithmeticException ex) {
+            assertEquals("overflow: subtract", ex.getMessage());
+        }
     }
     
     public void testBinomialCoefficient() {

Modified: jakarta/commons/proper/math/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/xdocs/changes.xml?rev=322442&r1=322441&r2=322442&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/math/trunk/xdocs/changes.xml Sat Oct 15 20:29:14 2005
@@ -50,11 +50,37 @@
        and numerical utilities, and a PRNG pluggability framework making it
        possible to replace the JDK-supplied random number generator in
        commons-math (and elsewhere) with alternative PRNG implementations.">
-          <action dev="psteitz" type="fix" issue="36450" due-to="Keith McDonald">
+      <action dev="psteitz" type="fix" issue="37019" due-to="Mauro Talevi">
+        Fixed incorrect NaN handling in o.a.m.s.d.rank.Min, Max
+      </action>
+      <action dev="psteitz" type="fix" issue="36491">
+       Changed RealMatrixImpl.equals to use Double.doubleToLongBits to compare
+       corresponding matrix entries.
+      </action>
+      <action dev="psteitz" type="fix" issue="36491">
+       Eliminated floating point equals comparison in Percentile.evaluate.
+      </action>
+      <action dev="psteitz" type="fix" issue="36491">
+       Eliminated unnecessary assignment statements in Skewness.getResult
+       method.
+      </action>
+      <action dev="psteitz" type="fix" issue="36491">
+       Synchronized getters in ResizeableDoubleArray.
+      </action>
+      <action dev="psteitz" type="fix" issue="36491">
+       Eliminated unnecessary assignment statement in BisectionSolver.solve
+       method.
+      </action>
+      <action dev="psteitz" type="fix" issue="36491">
+       Implemented hashCode in the Complex class and changed the semantics of
+       equals to make all instances with real or imaginary part NaN equal.
+      </action>
+      <action dev="psteitz" type="fix" issue="36450" due-to="Keith McDonald">
 		Fixed bin index overflow problem in EmpiricalDistributionImpl.
 	  </action>
           <action dev="brentworden" type="fix" issue="36232" due-to="Xiaogang Zhang">
-		Added protection against numerical overflow and underflow in the isBracketing method.
+        Added protection against numerical overflow and underflow in the
+        isBracketing method.
 	  </action>
 	  <action dev="brentworden" type="fix" issue="36300" due-to="Nikhil Gupte">
 		Fixed division by zero error in rounding methods.



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message