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

Function gen_next

numpy/random/src/mt19937/mt19937-jump.c:23–42  ·  view source on GitHub ↗

next state generating function */

Source from the content-addressed store, hash-verified

21
22/* next state generating function */
23void gen_next(mt19937_state *state) {
24 int num;
25 unsigned long y;
26 static unsigned long mag02[2] = {0x0ul, MATRIX_A};
27
28 num = state->pos;
29 if (num < N - M) {
30 y = (state->key[num] & UPPER_MASK) | (state->key[num + 1] & LOWER_MASK);
31 state->key[num] = state->key[num + M] ^ (y >> 1) ^ mag02[y % 2];
32 state->pos++;
33 } else if (num < N - 1) {
34 y = (state->key[num] & UPPER_MASK) | (state->key[num + 1] & LOWER_MASK);
35 state->key[num] = state->key[num + (M - N)] ^ (y >> 1) ^ mag02[y % 2];
36 state->pos++;
37 } else if (num == N - 1) {
38 y = (state->key[N - 1] & UPPER_MASK) | (state->key[0] & LOWER_MASK);
39 state->key[N - 1] = state->key[M - 1] ^ (y >> 1) ^ mag02[y % 2];
40 state->pos = 0;
41 }
42}
43
44void add_state(mt19937_state *state1, mt19937_state *state2) {
45 int i, pt1 = state1->pos, pt2 = state2->pos;

Callers 1

horner1Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected