File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -360,9 +360,9 @@ nc_exp2@c@(@ctype@ *x, @ctype@ *r)
360
360
static void
361
361
nc_expm1 @c @(@ctype @ * x , @ctype @ * r )
362
362
{
363
- @ftype @ a = npy_exp @c @(x -> real );
364
- r -> real = a * npy_cos @c @(x -> imag ) - 1.0 @ c @ ;
365
- r -> imag = a * npy_sin @c @(x -> imag );
363
+ @ftype @ a = npy_sin @c @(x -> imag / 2 );
364
+ r -> real = npy_expm1 @ c @( x -> real ) * npy_cos @c @(x -> imag ) - 2 * a * a ;
365
+ r -> imag = npy_exp @ c @( x -> real ) * npy_sin @c @(x -> imag );
366
366
return ;
367
367
}
368
368
Original file line number Diff line number Diff line change @@ -888,6 +888,12 @@ def test_special(self):
888
888
assert_equal (ncu .expm1 (np .inf ), np .inf )
889
889
assert_equal (ncu .expm1 (- np .inf ), - 1. )
890
890
891
+ def test_complex (self ):
892
+ x = np .asarray (1e-12 )
893
+ assert_allclose (x , ncu .expm1 (x ))
894
+ x = x .astype (np .complex128 )
895
+ assert_allclose (x , ncu .expm1 (x ))
896
+
891
897
892
898
class TestHypot (object ):
893
899
def test_simple (self ):
You can’t perform that action at this time.
0 commit comments