log() passes all tests
@@ -879,6 +879,13 @@ in the
* of {@code this}.
*/
public Complex log() {
+ if (real == Double.POSITIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
+ return new Complex(Double.POSITIVE_INFINITY, Math.PI * 0.25);
+ } else if (real == Double.POSITIVE_INFINITY && Double.isNaN(imaginary)) {
+ return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
+ } else if (Double.isNaN(real) && imaginary == Double.POSITIVE_INFINITY) {
+ return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
+ }
return new Complex(Math.log(abs()),
Math.atan2(imaginary, real));
}
