initializes mt[RK_STATE_LEN] with a seed */
| 15 | |
| 16 | /* initializes mt[RK_STATE_LEN] with a seed */ |
| 17 | static 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 |
no outgoing calls
no test coverage detected