Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
1.2, 2.0, 2.1
-
None
-
None
Description
Why does this unit test in ComplexTest.java gives NaN?
I expected to get Complex.ZERO as the result?
public void testPowZero() {
TestUtils.assertSame(Complex.NaN,
Complex.ZERO.pow(Complex.ONE));
...
}
I would suggest something like this for the Complex#pow() method:
public Complex pow(Complex x) { if (x == null) { throw new NullPointerException(); } if (x.imaginary == 0.0) { if (real == 0.0 && imaginary == 0.0) { if (x.real == 0.0){ return Complex.ZERO; } } if (x.real == 1.0) { return this; } } return this.log().multiply(x).exp(); }