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

Function getHalf01

src/backend/oneapi/kernel/random_engine_write.hpp:76–83  ·  view source on GitHub ↗

Generates rationals in (0, 1]

Source from the content-addressed store, hash-verified

74
75// Generates rationals in (0, 1]
76sycl::half getHalf01(uint num, uint index) {
77 sycl::half v = static_cast<sycl::half>(min(MAX_INT_BEFORE_INFINITY,
78 static_cast<ushort>(num >> (16U * (index & 1U)) & 0x0000ffff)));
79
80 const sycl::half half_factor{1.526e-5}; // (1 / (USHRT_MAX + 1))
81 const sycl::half half_half_factor{7.6e-6}; // (0.5 * half_factor)
82 return sycl::fma(v, half_factor, half_half_factor);
83}
84
85sycl::half oneMinusGetHalf01(uint num, uint index) {
86 return static_cast<sycl::half>(1.) - getHalf01(num, index);

Callers 3

oneMinusGetHalf01Function · 0.70

Calls 2

fmaFunction · 0.85
minFunction · 0.50

Tested by

no test coverage detected