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

Function rk_seed

numpy/random/src/mt19937/randomkit.c:143–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141static unsigned long rk_hash(unsigned long key);
142
143void rk_seed(unsigned long seed, rk_state *state) {
144 int pos;
145 seed &= 0xffffffffUL;
146
147 /* Knuth's PRNG as used in the Mersenne Twister reference implementation */
148 for (pos = 0; pos < RK_STATE_LEN; pos++) {
149 state->key[pos] = seed;
150 seed = (1812433253UL * (seed ^ (seed >> 30)) + pos + 1) & 0xffffffffUL;
151 }
152 state->pos = RK_STATE_LEN;
153 state->gauss = 0;
154 state->has_gauss = 0;
155 state->has_binomial = 0;
156}
157
158/* Thomas Wang 32 bits integer hash function */
159unsigned long rk_hash(unsigned long key) {

Callers 2

rk_randomseedFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by 1

mainFunction · 0.68