Lines Matching defs:state

56  * rand()/srand() like interface, this package also has a special state info
60 * that much state information. Good sizes for the amount of state
61 * information are 32, 64, 128, and 256 bytes. The state can be switched by
63 * with initstate(). By default, the package runs with 128 bytes of state
65 * congruential generator. If the amount of state information is less than
68 * Internally, the state information is treated as an array of longs; the
70 * integer); the remainder of the array is the state information for the
71 * R.N.G. Thus, 32 bytes of state information will give 7 longs worth of
72 * state information, which will allow a degree seven polynomial. (Note:
73 * the zeroeth word of state information also has some other information
79 * the state table will act as a linear feedback shift register, and will
85 * the amount of state information has a vast influence on the period of the
104 * state information and generates far better random numbers than a linear
105 * congruential generator. If the amount of state information is less than
113 * break value on the amount of state information (you need at least this
114 * many bytes of state info to support this random number generator), a degree
153 * element of the state information, which contains info about the current
156 * MAX_TYPES * (rptr - state) + TYPE_3 == TYPE_3.
181 * fptr and rptr are two pointers into the state info, a front and a rear
183 * cycle cyclically through the state information. (Yes, this does mean we
191 * in the initialization of randtbl) because the state table pointer is set
198 * The following things are the pointer to the state information table, the
201 * of random(), we remember the first location of the state information, not
202 * the zeroeth. Hence it is valid to access state[-1], which is used to
207 static unsigned long *state = &randtbl[1];
251 * type is the trivial no-state-information type, just remember the seed.
252 * Otherwise, initializes state[] based on the given "seed" via a linear
254 * that are exactly rand_sep places apart. Lastly, it cycles the state
267 state[0] = x;
269 state[0] = x;
271 state[i] = good_rand(state[i - 1]);
272 fptr = &state[rand_sep];
273 rptr = &state[0];
290 * state buffer are no longer derived from the LC algorithm applied to
327 * Initialize the state information in the given array of n bytes for future
331 * initialize the state information.
333 * Note that on return from srandom(), we set state[-1] to be the type
338 * Note: the first thing we do is save the current state, if any, just like
341 * Returns a pointer to the old state.
350 char *arg_state, /* pointer to state array */
351 long n /* # bytes of state info */
354 register char *ostate = (char *)(&state[-1]);
358 state[-1] = rand_type;
360 state[-1] = MAX_TYPES * (rptr - state) + rand_type;
363 "random: not enough state (%ld bytes); ignored.\n", n);
387 state = (unsigned long *) (long_arg_state + 1); /* first location */
388 end_ptr = &state[rand_deg]; /* must set end_ptr before srandom */
393 long_arg_state[0] = MAX_TYPES * (rptr - state) + rand_type;
400 * Restore the state from the given state array.
403 * in the current state information, and restore the locations of the pointers
404 * from the old state information. This is done by multiplexing the pointer
405 * location into the zeroeth word of the state information.
408 * setstate() with the same state as the current state.
410 * Returns a pointer to the old state information.
418 char *arg_state /* pointer to state array */
424 char *ostate = (char *)(&state[-1]);
427 state[-1] = rand_type;
429 state[-1] = MAX_TYPES * (rptr - state) + rand_type;
442 "random: state info corrupted; not changed.\n");
444 state = (new_state + 1);
446 rptr = &state[rear];
447 fptr = &state[(rear + rand_sep) % rand_deg];
449 end_ptr = &state[rand_deg]; /* set end_ptr too */
479 i = state[0];
480 state[0] = i = (good_rand(i)) & 0x7fffffff;
489 f = state;
493 r = state;