Lines Matching defs:state

76  * rand()/srand() like interface, this package also has a special state info
80 * that much state information. Good sizes for the amount of state
81 * information are 32, 64, 128, and 256 bytes. The state can be switched by
83 * with initstate(). By default, the package runs with 128 bytes of state
85 * congruential generator. If the amount of state information is less than
88 * Internally, the state information is treated as an array of ints; the
90 * integer); the remainder of the array is the state information for the
91 * R.N.G. Thus, 32 bytes of state information will give 7 ints worth of
92 * state information, which will allow a degree seven polynomial. (Note:
93 * the zeroeth word of state information also has some other information
99 * the state table will act as a linear feedback shift register, and will
105 * the amount of state information has a vast influence on the period of the
124 * state information and generates far better random numbers than a linear
125 * congruential generator. If the amount of state information is less than
138 * break value on the amount of state information (you need at least this
139 * many bytes of state info to support this random number generator), a degree
185 * element of the state information, which contains info about the current
188 * MAX_TYPES * (rptr - state) + TYPE_3 == TYPE_3.
222 * fptr and rptr are two pointers into the state info, a front and a rear
224 * cycle cyclically through the state information. (Yes, this does mean we
232 * in the initialization of randtbl) because the state table pointer is set
239 * The following things are the pointer to the state information table, the
242 * of random(), we remember the first location of the state information, not
243 * the zeroeth. Hence it is valid to access state[-1], which is used to
248 static int *state = &randtbl[1];
258 * type is the trivial no-state-information type, just remember the seed.
259 * Otherwise, initializes state[] based on the given "seed" via a linear
261 * that are exactly rand_sep places apart. Lastly, it cycles the state
272 state[0] = x;
274 state[0] = x;
286 x1 = state[i - 1];
292 state[i] = t;
294 state[i] = 1103515245 * state[i - 1] + 12345;
297 fptr = &state[rand_sep];
298 rptr = &state[0];
316 * Initialize the state information in the given array of n bytes for future
320 * initialize the state information.
322 * Note that on return from srandom(), we set state[-1] to be the type
327 * Note: the first thing we do is save the current state, if any, just like
330 * Returns a pointer to the old state.
339 char *arg_state, /* pointer to state array */
340 size_t n) /* # bytes of state info */
342 void *ostate = (void *)(&state[-1]);
351 state[-1] = rand_type;
353 state[-1] = MAX_TYPES * (int)(rptr - state) + rand_type;
378 state = (int *) (int_arg_state + 1); /* first location */
379 end_ptr = &state[rand_deg]; /* must set end_ptr before srandom */
384 int_arg_state[0] = MAX_TYPES * (int)(rptr - state) + rand_type;
392 * Restore the state from the given state array.
395 * in the current state information, and restore the locations of the pointers
396 * from the old state information. This is done by multiplexing the pointer
397 * location into the zeroeth word of the state information.
400 * setstate() with the same state as the current state.
402 * Returns a pointer to the old state information.
409 setstate(char *arg_state) /* pointer to state array */
414 void *ostate = (void *)(&state[-1]);
424 state[-1] = rand_type;
426 state[-1] = MAX_TYPES * (int)(rptr - state) + rand_type;
441 state = (int *) (new_state + 1);
443 rptr = &state[rear];
444 fptr = &state[(rear + rand_sep) % rand_deg];
446 end_ptr = &state[rand_deg]; /* set end_ptr too */
475 i = state[0];
476 state[0] = i = (i * 1103515245 + 12345) & 0x7fffffff;
486 f = state;
490 r = state;