Completed reversion of r1164756 changes (for now).

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1164923 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Phil Steitz 2011-09-03 20:06:24 +00:00
parent 97b440fc8e
commit 7dabaab113
2 changed files with 7 additions and 28 deletions

View File

@ -78,8 +78,6 @@ public class Complex implements FieldElement<Complex>, Serializable {
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 FieldElement<Complex>, Serializable {
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 FieldElement<Complex>, Serializable {
* <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 FieldElement<Complex>, Serializable {
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 FieldElement<Complex>, Serializable {
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 FieldElement<Complex>, Serializable {
return NaN;
}
if (divisor == 0d) {
// return isZero ? NaN : INF; // See MATH-657
return NaN;
}
if (Double.isInfinite(divisor)) {

View File

@ -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));
}
@ -572,14 +564,10 @@ public class ComplexTest {
TestUtils.assertSame(Complex.NaN, negInfNegInf.atan());
}
@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