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

Function threefryUniform

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

Source from the content-addressed store, hash-verified

237
238template<typename T>
239void threefryUniform(T *out, size_t elements, const uintl seed, uintl counter) {
240 uint hi = seed >> 32;
241 uint lo = seed;
242 uint hic = counter >> 32;
243 uint loc = counter;
244 uint key[2] = {lo, hi};
245 uint ctr[2] = {loc, hic};
246 uint val[2];
247
248 int reset = (2 * sizeof(uint)) / sizeof(T);
249 for (int i = 0; i < (int)elements; i += reset) {
250 threefry(key, ctr, val);
251 ++ctr[0];
252 ctr[1] += (ctr[0] == 0);
253 int lim = (reset < (int)(elements - i)) ? reset : (int)(elements - i);
254 for (int j = 0; j < lim; ++j) { out[i + j] = transform<T>(val, j); }
255 }
256}
257
258template<typename T>
259void boxMullerTransform(data_t<T> *const out1, data_t<T> *const out2,

Callers 1

uniformDistributionCBRNGFunction · 0.85

Calls 1

threefryFunction · 0.70

Tested by

no test coverage detected