Lines Matching refs:state

35  * rand()/srand() like interface, this package also has a special state info
39 * much state information. Good sizes for the amount of state information are
40 * 32, 64, 128, and 256 bytes. The state can be switched by calling the
42 * By default, the package runs with 128 bytes of state information and
44 * If the amount of state information is less than 32 bytes, a simple linear
46 * Internally, the state information is treated as an array of longs; the
48 * integer); the remainder of the array is the state information for the
49 * R.N.G. Thus, 32 bytes of state information will give 7 longs worth of
50 * state information, which will allow a degree seven polynomial. (Note: the
51 * zeroeth word of state information also has some other information stored
56 * the state table will act as a linear feedback shift register, and will have
62 * state information has a vast influence on the period of the generator.
73 * break value on the amount of state information (you need at least this
74 * many bytes of state info to support this random number generator), a degree
117 * fptr and rptr are two pointers into the state info, a front and a rear
119 * cyclically through the state information. (Yes, this does mean we could get
124 * in the initialization of randtbl) because the state table pointer is set
129 * The following things are the pointer to the state information table,
133 * the state information, not the zeroeth. Hence it is valid to access
134 * state[-1], which is used to store the type of the R.N.G.
139 long *state;
149 * end up at zero; thus the zeroeth element of the state
152 * MAX_TYPES*(rptr - state) + TYPE_3 == TYPE_3.
192 * type is the trivial no-state-information type, just remember the seed.
193 * Otherwise, initializes state[] based on the given "seed" via a linear
195 * that are exactly rand_sep places apart. Lastly, it cycles the state
211 rp->state[0] = x;
213 rp->state[0] = x;
215 rp->state[i] = 1103515245*rp->state[i - 1] + 12345;
217 rp->fptr = &rp->state[rp->rand_sep];
218 rp->rptr = &rp->state[0];
228 * Initialize the state information in the given array of n bytes for
232 * then called to initialize the state information.
233 * Note that on return from srandom(), we set state[-1] to be the type
237 * Note: the first thing we do is save the current state, if any, just like
239 * Returns a pointer to the old state.
243 * arg_state: pointer to state array
244 * n: # bytes of state info
255 ostate = (char *)(&rp->state[-1]);
257 if (rp->rand_type == TYPE_0) rp->state[-1] = rp->rand_type;
258 else rp->state[-1] =
259 MAX_TYPES*(rp->rptr - rp->state) + rp->rand_type;
262 "initstate: state array too small, ignored; minimum size is %d bytes\n",
286 rp->state = &((long *)arg_state)[1]; /* first location */
287 rp->end_ptr = &rp->state[rp->rand_deg]; /* set end_ptr before srandom */
289 rp->state[-1] = (rp->rand_type == TYPE_0) ? rp->rand_type
290 : MAX_TYPES * (rp->rptr - rp->state) + rp->rand_type;
297 * Restore the state from the given state array.
299 * in the current state information, and restore the locations of the pointers
300 * from the old state information. This is done by multiplexing the pointer
301 * location into the zeroeth word of the state information.
303 * setstate() with the same state as the current state.
304 * Returns a pointer to the old state information.
321 ostate = (char *)(&rp->state[-1]);
323 rp->state[-1] = (rp->rand_type == TYPE_0) ? rp->rand_type
324 : MAX_TYPES*(rp->rptr - rp->state) + rp->rand_type;
337 fprintf(stderr, "setstate: invalid state info; not changed.\n");
339 rp->state = &new_state[1];
341 rp->rptr = &rp->state[rear];
342 rp->fptr = &rp->state[(rear + rp->rand_sep) % rp->rand_deg];
344 rp->end_ptr = &rp->state[rp->rand_deg]; /* set end_ptr too */
373 i = rp->state[0] = (rp->state[0]*1103515245 + 12345)&0x7fffffff;
378 rp->fptr = rp->state;
381 rp->rptr = rp->state;