MCPcopy Create free account
hub / github.com/numpy/numpy / init_genrand

Function init_genrand

numpy/random/src/mt19937/mt19937.c:17–35  ·  view source on GitHub ↗

initializes mt[RK_STATE_LEN] with a seed */

Source from the content-addressed store, hash-verified

15
16/* initializes mt[RK_STATE_LEN] with a seed */
17static void init_genrand(mt19937_state *state, uint32_t s) {
18 int mti;
19 uint32_t *mt = state->key;
20
21 mt[0] = s & 0xffffffffUL;
22 for (mti = 1; mti < RK_STATE_LEN; mti++) {
23 /*
24 * See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier.
25 * In the previous versions, MSBs of the seed affect
26 * only MSBs of the array mt[].
27 * 2002/01/09 modified by Makoto Matsumoto
28 */
29 mt[mti] = (1812433253UL * (mt[mti - 1] ^ (mt[mti - 1] >> 30)) + mti);
30 /* for > 32 bit machines */
31 mt[mti] &= 0xffffffffUL;
32 }
33 state->pos = mti;
34 return;
35}
36
37/*
38 * initialize by an array with array-length

Callers 1

mt19937_init_by_arrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected