summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorRaghuveer Devulapalli <raghuveer.devulapalli@intel.com>2019-05-20 10:13:08 -0700
committerRaghuveer Devulapalli <raghuveer.devulapalli@intel.com>2019-08-03 10:50:04 -0700
commitbca96282530fc15dc86c78b640a7b87581885513 (patch)
treeeb9c88f12d5b111815d659d77ab40a01ab92df42 /numpy
parentd56fbfda94a689e855ce8679c5828f7a729d777a (diff)
downloadnumpy-bca96282530fc15dc86c78b640a7b87581885513.tar.gz
TEST: adding tests to validate AVX sin/cos implementation
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/umath/simd.inc.src2
-rw-r--r--numpy/core/tests/test_umath.py15
2 files changed, 14 insertions, 3 deletions
diff --git a/numpy/core/src/umath/simd.inc.src b/numpy/core/src/umath/simd.inc.src
index 7bd5aa2b5..07a3c19a4 100644
--- a/numpy/core/src/umath/simd.inc.src
+++ b/numpy/core/src/umath/simd.inc.src
@@ -164,7 +164,7 @@ run_unary_@isa@_@func@_FLOAT(char **args, npy_intp *dimensions, npy_intp *steps)
#if defined HAVE_ATTRIBUTE_TARGET_@ISA@_WITH_INTRINSICS && defined NPY_HAVE_SSE2_INTRINSICS
static NPY_INLINE void
-@ISA@_sincos_FLOAT(npy_float *, npy_float *, const npy_int n, char*);
+@ISA@_sincos_FLOAT(npy_float *, npy_float *, const npy_intp n, char*);
#endif
/**end repeat**/
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index 0948cbfe6..747d893c2 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -695,7 +695,7 @@ class TestSpecialFloats(object):
assert_raises(FloatingPointError, np.cos, np.float32(np.inf))
-class TestExpLogFloat32(object):
+class TestSIMDFloat32(object):
def test_exp_float32(self):
np.random.seed(42)
x_f32 = np.float32(np.random.uniform(low=0.0,high=88.1,size=1000000))
@@ -708,7 +708,14 @@ class TestExpLogFloat32(object):
x_f64 = np.float64(x_f32)
assert_array_max_ulp(np.log(x_f32), np.float32(np.log(x_f64)), maxulp=3.9)
- def test_strided_exp_log_float32(self):
+ def test_sincos_float32(self):
+ np.random.seed(42)
+ x_f32 = np.float32(np.random.uniform(low=-100.,high=100.,size=1000000))
+ x_f64 = np.float64(x_f32)
+ assert_array_max_ulp(np.sin(x_f32), np.float32(np.sin(x_f64)), maxulp=1.5)
+ assert_array_max_ulp(np.cos(x_f32), np.float32(np.cos(x_f64)), maxulp=1.5)
+
+ def test_strided_float32(self):
np.random.seed(42)
strides = np.random.randint(low=-100, high=100, size=100)
sizes = np.random.randint(low=1, high=2000, size=100)
@@ -716,9 +723,13 @@ class TestExpLogFloat32(object):
x_f32 = np.float32(np.random.uniform(low=0.01,high=88.1,size=ii))
exp_true = np.exp(x_f32)
log_true = np.log(x_f32)
+ sin_true = np.sin(x_f32)
+ cos_true = np.cos(x_f32)
for jj in strides:
assert_array_almost_equal_nulp(np.exp(x_f32[::jj]), exp_true[::jj], nulp=2)
assert_array_almost_equal_nulp(np.log(x_f32[::jj]), log_true[::jj], nulp=2)
+ assert_array_almost_equal_nulp(np.sin(x_f32[::jj]), sin_true[::jj], nulp=2)
+ assert_array_almost_equal_nulp(np.cos(x_f32[::jj]), cos_true[::jj], nulp=2)
class TestLogAddExp(_FilterInvalids):
def test_logaddexp_values(self):