diff options
author | Gengxin Xie <gengxin.xie@intel.com> | 2020-04-08 10:02:19 +0800 |
---|---|---|
committer | Gengxin Xie <gengxin.xie@intel.com> | 2020-04-08 10:02:19 +0800 |
commit | d47b21df04d862f2a9da98f2ac935242cd10638d (patch) | |
tree | f8ff595a11c6b929d42cd33fe33502d0cbd410dd | |
parent | 1cabf5bf7d494c02e019a77049614a45beae6bdc (diff) | |
download | numpy-d47b21df04d862f2a9da98f2ac935242cd10638d.tar.gz |
MAINT: Add test case of strides input & more comments
-rw-r--r-- | numpy/core/src/umath/simd.inc.src | 5 | ||||
-rw-r--r-- | numpy/core/tests/test_umath.py | 10 |
2 files changed, 13 insertions, 2 deletions
diff --git a/numpy/core/src/umath/simd.inc.src b/numpy/core/src/umath/simd.inc.src index 501100465..106c7e7c9 100644 --- a/numpy/core/src/umath/simd.inc.src +++ b/numpy/core/src/umath/simd.inc.src @@ -2699,9 +2699,10 @@ static NPY_GCC_OPT_3 NPY_GCC_TARGET_@ISA@ void * 1) if x > mTH_max or x is INF; return INF (overflow) * 2) if x < mTH_min; return 0.0f (underflow) * 3) if abs(x) < mTH_nearzero; return 1.0f + x - * 4) Range reduction: + * 4) if x is Nan; return Nan + * 5) Range reduction: * x = (32m + j)ln2 / 32 + r; r in [-ln2/64, ln2/64] - * 5) exp(r) - 1 is approximated by a polynomial function p(r) + * 6) exp(r) - 1 is approximated by a polynomial function p(r) * exp(x) = 2^m(2^(j/32) + 2^(j/32)p(r)); */ #if defined HAVE_ATTRIBUTE_TARGET_AVX512F_WITH_INTRINSICS diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index f8a57d2c2..60c9fe437 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -640,6 +640,16 @@ class TestExp: yf = np.array(y, dtype=dt)*log2_ assert_almost_equal(np.exp(yf), xf) + def test_exp_strides(self): + np.random.seed(42) + strides = np.array([-4,-3,-2,-1,1,2,3,4]) + sizes = np.arange(2,100) + for ii in sizes: + x_f64 = np.float64(np.random.uniform(low=0.01, high=709.1,size=ii)) + y_true = np.exp(x_f64) + for jj in strides: + assert_array_almost_equal_nulp(np.exp(x_f64[::jj]), y_true[::jj], nulp=2) + class TestSpecialFloats: def test_exp_values(self): x = [np.nan, np.nan, np.inf, 0.] |