(self)
| 1943 | |
| 1944 | class TestAVXUfuncs: |
| 1945 | def test_avx_based_ufunc(self): |
| 1946 | strides = np.array([-4,-3,-2,-1,1,2,3,4]) |
| 1947 | np.random.seed(42) |
| 1948 | for func, prop in avx_ufuncs.items(): |
| 1949 | maxulperr = prop[0] |
| 1950 | minval = prop[1] |
| 1951 | maxval = prop[2] |
| 1952 | # various array sizes to ensure masking in AVX is tested |
| 1953 | for size in range(1,32): |
| 1954 | myfunc = getattr(np, func) |
| 1955 | x_f32 = np.float32(np.random.uniform(low=minval, high=maxval, |
| 1956 | size=size)) |
| 1957 | x_f64 = np.float64(x_f32) |
| 1958 | x_f128 = np.longdouble(x_f32) |
| 1959 | y_true128 = myfunc(x_f128) |
| 1960 | if maxulperr == 0: |
| 1961 | assert_equal(myfunc(x_f32), np.float32(y_true128)) |
| 1962 | assert_equal(myfunc(x_f64), np.float64(y_true128)) |
| 1963 | else: |
| 1964 | assert_array_max_ulp(myfunc(x_f32), np.float32(y_true128), |
| 1965 | maxulp=maxulperr) |
| 1966 | assert_array_max_ulp(myfunc(x_f64), np.float64(y_true128), |
| 1967 | maxulp=maxulperr) |
| 1968 | # various strides to test gather instruction |
| 1969 | if size > 1: |
| 1970 | y_true32 = myfunc(x_f32) |
| 1971 | y_true64 = myfunc(x_f64) |
| 1972 | for jj in strides: |
| 1973 | assert_equal(myfunc(x_f64[::jj]), y_true64[::jj]) |
| 1974 | assert_equal(myfunc(x_f32[::jj]), y_true32[::jj]) |
| 1975 | |
| 1976 | class TestAVXFloat32Transcendental: |
| 1977 | def test_exp_float32(self): |
nothing calls this directly
no test coverage detected