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

Function threefryNormal

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

Source from the content-addressed store, hash-verified

314
315template<typename T>
316void threefryNormal(T *out, size_t elements, const uintl seed, uintl counter) {
317 uint hi = seed >> 32;
318 uint lo = seed;
319 uint hic = counter >> 32;
320 uint loc = counter;
321 uint key[2] = {lo, hi};
322 uint ctr[2] = {loc, hic};
323 uint val[4];
324 T temp[(4 * sizeof(uint)) / sizeof(T)];
325
326 int reset = (4 * sizeof(uint)) / sizeof(T);
327 for (int i = 0; i < (int)elements; i += reset) {
328 threefry(key, ctr, val);
329 ++ctr[0];
330 ctr[1] += (ctr[0] == 0);
331 threefry(key, ctr, val + 2);
332 ++ctr[0];
333 ctr[1] += (ctr[0] == 0);
334 boxMullerTransform(val, temp);
335 int lim = (reset < (int)(elements - i)) ? reset : (int)(elements - i);
336 for (int j = 0; j < lim; ++j) { out[i + j] = temp[j]; }
337 }
338}
339
340template<typename T>
341void uniformDistributionMT(T *out, size_t elements, uint *const state,

Callers 1

normalDistributionCBRNGFunction · 0.85

Calls 2

threefryFunction · 0.70
boxMullerTransformFunction · 0.70

Tested by

no test coverage detected