| 304 | |
| 305 | template<typename T> |
| 306 | void testRandomEngineUniform(randomEngineType type) { |
| 307 | SUPPORTED_TYPE_CHECK(T); |
| 308 | dtype ty = (dtype)dtype_traits<T>::af_type; |
| 309 | |
| 310 | int elem = 16 * 1024 * 1024; |
| 311 | randomEngine r(type, 0); |
| 312 | array A = randu(elem, ty, r); |
| 313 | |
| 314 | // If double precision is available then perform the mean calculation using |
| 315 | // double because the A array is large and causes accuracy issues when using |
| 316 | // certain compiler flags (i.e. --march=native) |
| 317 | if (af::isDoubleAvailable(af::getDevice())) { |
| 318 | array Ad = A.as(f64); |
| 319 | double m = mean<double>(Ad); |
| 320 | double s = stdev<double>(Ad, AF_VARIANCE_POPULATION); |
| 321 | ASSERT_NEAR(m, 0.5, 1e-3); |
| 322 | ASSERT_NEAR(s, 0.2887, 1e-2); |
| 323 | } else { |
| 324 | T m = mean<T>(A); |
| 325 | T s = stdev<T>(A, AF_VARIANCE_POPULATION); |
| 326 | ASSERT_NEAR(m, 0.5, 1e-3); |
| 327 | ASSERT_NEAR(s, 0.2887, 1e-2); |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | template<typename T> |
| 332 | void testRandomEngineNormal(randomEngineType type) { |
nothing calls this directly
no test coverage detected