summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/core/src/umath/funcs.inc.src6
-rw-r--r--numpy/core/tests/test_umath.py6
2 files changed, 9 insertions, 3 deletions
diff --git a/numpy/core/src/umath/funcs.inc.src b/numpy/core/src/umath/funcs.inc.src
index 10ed66e50..397d2c1aa 100644
--- a/numpy/core/src/umath/funcs.inc.src
+++ b/numpy/core/src/umath/funcs.inc.src
@@ -360,9 +360,9 @@ nc_exp2@c@(@ctype@ *x, @ctype@ *r)
static void
nc_expm1@c@(@ctype@ *x, @ctype@ *r)
{
- @ftype@ a = npy_exp@c@(x->real);
- r->real = a*npy_cos@c@(x->imag) - 1.0@c@;
- r->imag = a*npy_sin@c@(x->imag);
+ @ftype@ a = npy_cos@c@(x->imag);
+ r->real = npy_expm1@c@(x->real) * a + (a - 1);
+ r->imag = npy_exp@c@(x->real) * npy_sin@c@(x->imag);
return;
}
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index e892e81d2..ae1090c23 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -888,6 +888,12 @@ class TestExpm1(object):
assert_equal(ncu.expm1(np.inf), np.inf)
assert_equal(ncu.expm1(-np.inf), -1.)
+ def test_complex(self):
+ x = np.asarray(1e-12)
+ assert_allclose(x, ncu.expm1(x))
+ x = x.astype(np.complex128)
+ assert_allclose(x, ncu.expm1(x))
+
class TestHypot(object):
def test_simple(self):