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

Function getHalfNegative11

src/backend/cpu/kernel/random_engine.hpp:81–89  ·  view source on GitHub ↗

Generates rationals in (-1, 1]

Source from the content-addressed store, hash-verified

79
80// Generates rationals in (-1, 1]
81static arrayfire::common::half getHalfNegative11(uint *val, uint index) {
82 float v = val[index >> 1U] >> (16U * (index & 1U)) & 0x0000ffff;
83 // Conversion to half adapted from Random123
84 constexpr float factor =
85 ((1.0f) / (std::numeric_limits<short>::max() + (1.0f)));
86 constexpr float half_factor = ((0.5f) * factor);
87
88 return static_cast<arrayfire::common::half>(fmaf(v, factor, half_factor));
89}
90
91// Generates rationals in [0, 1)
92double getDouble01(uint *val, uint index) {

Callers 1

boxMullerTransformFunction · 0.70

Calls 1

maxFunction · 0.50

Tested by

no test coverage detected