MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / testRandomEngineUniform

Function testRandomEngineUniform

test/random.cpp:306–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304
305template<typename T>
306void 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
331template<typename T>
332void testRandomEngineNormal(randomEngineType type) {

Callers

nothing calls this directly

Calls 4

randuFunction · 0.85
isDoubleAvailableFunction · 0.85
getDeviceFunction · 0.85
asMethod · 0.80

Tested by

no test coverage detected