26#define mod_diff(x,y) (((x)-(y))&(MM-1))
30#define is_odd(x) ((x)&1)
31#define evenize(x) ((x)&(MM-2))
46 for (j=0;j<
KK;j++) aa[j]=
ran_x[j];
61#define is_odd(x) ((x)&1)
72 register long ss=(
seed+2)&(
MM-2);
75 ss<<=1;
if (ss>=
MM) ss-=
MM-2;
79 for (j=
KK-1;j>0;j--) x[j+j]=x[j], x[j+j-1]=0;
84 for (j=
KK;j>0;j--) x[j]=x[j-1];
88 if (ss) ss>>=1;
else t--;
void ran_start(long seed)
Starts the generator with seed: do this before using it.
static long ran_arr_dummy
static long ran_arr_started
long ran_arr_cycle(void)
Makes a new batch of numbers and returns its first one: ran_arr_next() calls it when the batch runs o...
static void ran_array(long *aa, int n)
long * ran_arr_ptr
Points to the next number of the batch, or to -1 when the batch has run out.
static long ran_arr_buf[1009]
Knuth's random number generator, from his rng.c (The Art of Computer Programming, Volume 2,...