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

Function getDouble01

src/backend/cuda/kernel/random_engine.hpp:133–144  ·  view source on GitHub ↗

Generates rationals in (0, 1]

Source from the content-addressed store, hash-verified

131
132// Generates rationals in (0, 1]
133__device__ static double getDouble01(uint num1, uint num2) {
134 uint64_t n1 = num1;
135 uint64_t n2 = num2;
136 n1 <<= 32;
137 uint64_t num = n1 | n2;
138 constexpr double factor =
139 ((1.0) / (std::numeric_limits<unsigned long long>::max() +
140 static_cast<double>(1.0)));
141 constexpr double half_factor((0.5) * factor);
142
143 return fma(static_cast<double>(num), factor, half_factor);
144}
145
146// Conversion to doubles adapted from Random123
147constexpr double signed_factor =

Callers 4

writeOut128BytesFunction · 0.70
partialWriteOut128BytesFunction · 0.70

Calls 2

fmaFunction · 0.85
maxFunction · 0.50

Tested by

no test coverage detected