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

Function normalDistributionMT

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

Source from the content-addressed store, hash-verified

364
365template<typename T>
366void normalDistributionMT(T *out, size_t elements, uint *const state,
367 const uint *const pos, const uint *const sh1,
368 const uint *const sh2, uint mask,
369 const uint *const recursion_table,
370 const uint *const temper_table) {
371 T temp[(4 * sizeof(uint)) / sizeof(T)];
372 uint l_state[STATE_SIZE];
373 uint o[4];
374 uint lpos = pos[0];
375 uint lsh1 = sh1[0];
376 uint lsh2 = sh2[0];
377
378 state_read(l_state, state);
379
380 int reset = (4 * sizeof(uint)) / sizeof(T);
381 for (int i = 0; i < (int)elements; i += reset) {
382 mersenne(o, l_state, i, lpos, lsh1, lsh2, mask, recursion_table,
383 temper_table);
384 boxMullerTransform(o, temp);
385 int lim = (reset < (int)(elements - i)) ? reset : (int)(elements - i);
386 for (int j = 0; j < lim; ++j) { out[i + j] = temp[j]; }
387 }
388
389 state_write(state, l_state);
390}
391
392template<typename T>
393void uniformDistributionCBRNG(T *out, size_t elements,

Callers

nothing calls this directly

Calls 4

mersenneFunction · 0.85
state_readFunction · 0.70
boxMullerTransformFunction · 0.70
state_writeFunction · 0.70

Tested by

no test coverage detected