commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r690314 - in /commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math: geometry/Vector3D.java linear/RealMatrixImpl.java linear/RealVectorImpl.java
Date Fri, 29 Aug 2008 16:17:33 GMT
Author: luc
Date: Fri Aug 29 09:17:33 2008
New Revision: 690314

URL: http://svn.apache.org/viewvc?rev=690314&view=rev
Log:
Changed the equals() methods from RealMatrixImpl, RealVectorImpl and Vector3D
so that they consider +0 and -0 are equal, as required by IEEE-754 standard.
These were bugs similar to MATH-221 for Complex.

Modified:
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3D.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorImpl.java

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3D.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3D.java?rev=690314&r1=690313&r2=690314&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3D.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3D.java
Fri Aug 29 09:17:33 2008
@@ -403,14 +403,12 @@
 
     try {
 
-        Vector3D rhs = (Vector3D)other;
+      final Vector3D rhs = (Vector3D)other;
       if (rhs.isNaN()) {
           return this.isNaN();
       }
 
-      return (Double.doubleToRawLongBits(x) == Double.doubleToRawLongBits(rhs.x)) &&
-             (Double.doubleToRawLongBits(y) == Double.doubleToRawLongBits(rhs.y)) &&
-             (Double.doubleToRawLongBits(z) == Double.doubleToRawLongBits(rhs.z)); 
+      return (x == rhs.x) && (y == rhs.y) && (z == rhs.z); 
 
     } catch (ClassCastException ex) {
         // ignore exception

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java?rev=690314&r1=690313&r2=690314&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
Fri Aug 29 09:17:33 2008
@@ -1192,8 +1192,7 @@
     /**
      * 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.  Corresponding entries
-     * are compared using {@link java.lang.Double#doubleToLongBits(double)}
+     * and all corresponding matrix entries are equal.
      * 
      * @param object the object to test equality against.
      * @return true if object equals this
@@ -1214,8 +1213,7 @@
         for (int row = 0; row < nRows; row++) {
             final double[] dataRow = data[row];
             for (int col = 0; col < nCols; col++) {
-                if (Double.doubleToLongBits(dataRow[col]) != 
-                    Double.doubleToLongBits(m.getEntry(row, col))) {
+                if (dataRow[col] != m.getEntry(row, col)) {
                     return false;
                 }
             }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorImpl.java?rev=690314&r1=690313&r2=690314&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorImpl.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorImpl.java
Fri Aug 29 09:17:33 2008
@@ -1266,8 +1266,7 @@
           }
 
           for (int i = 0; i < data.length; ++i) {
-              if (Double.doubleToRawLongBits(data[i]) !=
-                  Double.doubleToRawLongBits(rhs.getEntry(i))) {
+              if (data[i] != rhs.getEntry(i)) {
                   return false;
               }
           }



Mime
View raw message