Commit d20dd69d authored by Robert Bradshaw's avatar Robert Bradshaw

Fix complex powers of negative real values.

Fixes GH issue #1538.
parent 320d3c44
......@@ -264,9 +264,13 @@ static {{type}} __Pyx_PyComplex_As_{{type_name}}(PyObject* o) {
if (a.imag == 0) {
if (a.real == 0) {
return a;
}
} else if (a.real > 0) {
r = a.real;
theta = 0;
} else {
r = -a.real;
theta = atan2{{m}}(0, -1);
}
} else {
r = __Pyx_c_abs{{func_suffix}}(a);
theta = atan2{{m}}(a.imag, a.real);
......
......@@ -48,6 +48,8 @@ def test_pow(double complex z, double complex w, tol=None):
True
>>> test_pow(complex(0.5, -.25), complex(3, 4), 1e-15)
True
>>> test_pow(-0.5, 1j, tol=1e-15)
True
"""
if tol is None:
return z**w
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment