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

Function getFloat01

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

Generates rationals in [0, 1)

Source from the content-addressed store, hash-verified

50
51// Generates rationals in [0, 1)
52float getFloat01(uint *val, uint index) {
53 // Conversion to floats adapted from Random123
54 constexpr float factor =
55 ((1.0f) /
56 (static_cast<float>(std::numeric_limits<unsigned int>::max()) +
57 (1.0f)));
58 constexpr float half_factor = ((0.5f) * factor);
59 return fmaf(val[index], factor, half_factor);
60}
61
62// Generates rationals in (-1, 1]
63static float getFloatNegative11(uint *val, uint index) {

Callers 2

transform<float>Function · 0.70
boxMullerTransformFunction · 0.70

Calls 1

maxFunction · 0.50

Tested by

no test coverage detected