commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r1164923 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/complex/Complex.java test/java/org/apache/commons/math/complex/ComplexTest.java
Date Sat, 03 Sep 2011 20:06:24 GMT
Author: psteitz
Date: Sat Sep  3 20:06:24 2011
New Revision: 1164923

URL: http://svn.apache.org/viewvc?rev=1164923&view=rev
Log:
Completed reversion of r1164756 changes (for now).

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/complex/ComplexTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java?rev=1164923&r1=1164922&r2=1164923&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java Sat
Sep  3 20:06:24 2011
@@ -78,8 +78,6 @@ public class Complex implements FieldEle
     private final transient boolean isNaN;
     /** Record whether this complex number is infinite. */
     private final transient boolean isInfinite;
-    /** Record whether this complex number is zero. */
-    private final transient boolean isZero;
 
     /**
      * Create a complex number given only the real part.
@@ -103,7 +101,6 @@ public class Complex implements FieldEle
         isNaN = Double.isNaN(real) || Double.isNaN(imaginary);
         isInfinite = !isNaN &&
             (Double.isInfinite(real) || Double.isInfinite(imaginary));
-        isZero = real == 0 && imaginary == 0;
     }
 
     /**
@@ -225,10 +222,7 @@ public class Complex implements FieldEle
      *  <li>If either {@code this} or {@code divisor} has a {@code NaN} value
      *   in either part, {@link #NaN} is returned.
      *  </li>
-     *  <li>If {@code this} and {@code divisor} are both {@link #ZERO},
-     *   {@link #NaN} is returned.
-     *  </li>
-     *  <li>If {@code divisor} equals {@link #ZERO}, {@link #INF} is returned.
+     *  <li>If {@code divisor} equals {@link #ZERO}, {@link #NaN} is returned.
      *  </li>
      *  <li>If {@code this} and {@code divisor} are both infinite,
      *   {@link #NaN} is returned.
@@ -255,8 +249,9 @@ public class Complex implements FieldEle
             return NaN;
         }
 
-        if (divisor.isZero) {
-            // return isZero ? NaN : INF; // See MATH-657
+        final double c = divisor.getReal();
+        final double d = divisor.getImaginary();
+        if (c == 0.0 && d == 0.0) {
             return NaN;
         }
 
@@ -264,9 +259,6 @@ public class Complex implements FieldEle
             return ZERO;
         }
 
-        final double c = divisor.getReal();
-        final double d = divisor.getImaginary();
-
         if (FastMath.abs(c) < FastMath.abs(d)) {
             double q = c / d;
             double denominator = c * q + d;
@@ -293,7 +285,6 @@ public class Complex implements FieldEle
             return NaN;
         }
         if (divisor == 0d) {
-            // return isZero ? NaN : INF; // See MATH-657
             return NaN;
         }
         if (Double.isInfinite(divisor)) {

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/complex/ComplexTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/complex/ComplexTest.java?rev=1164923&r1=1164922&r2=1164923&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/complex/ComplexTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/complex/ComplexTest.java
Sat Sep  3 20:06:24 2011
@@ -229,14 +229,6 @@ public class ComplexTest {
     public void testDivideZero() {
         Complex x = new Complex(3.0, 4.0);
         Complex z = x.divide(Complex.ZERO);
-        // Assert.assertEquals(z, Complex.INF); // See MATH-657
-        Assert.assertEquals(z, Complex.NaN);
-    }
-
-    @Test
-    public void testDivideZeroZero() {
-        Complex x = new Complex(0.0, 0.0);
-        Complex z = x.divide(Complex.ZERO);
         Assert.assertEquals(z, Complex.NaN);
     }
 
@@ -357,13 +349,13 @@ public class ComplexTest {
 
     @Test
     public void testScalarMultiplyInf() {
-        Complex x = new Complex(1, 1);
+        Complex x = new Complex(1,1);
         double yDouble = Double.POSITIVE_INFINITY;
         Complex yComplex = new Complex(yDouble);
         Assert.assertEquals(x.multiply(yComplex), x.multiply(yDouble));
         
         yDouble = Double.NEGATIVE_INFINITY;
-        yComplex = new Complex(yDouble);
+         yComplex = new Complex(yDouble);
         Assert.assertEquals(x.multiply(yComplex), x.multiply(yDouble));
     }
 
@@ -573,13 +565,9 @@ public class ComplexTest {
     }
 
     @Test
-    public void testAtanI() {
-        Assert.assertTrue(Complex.I.atan().isNaN());
-    }
-
-    @Test
     public void testAtanNaN() {
         Assert.assertTrue(Complex.NaN.atan().isNaN());
+        Assert.assertTrue(Complex.I.atan().isNaN());
     }
 
     @Test



Mime
View raw message