static int flip_cycle(RNG *rand) { /* this is an auxiliary routine to do 55 more steps of the basic recurrence, at high speed, and to reset fptr */ int *ii, *jj; for (ii = &A[1], jj = &A[32]; jj <= &A[55]; ii++, jj++) *ii = mod_diff(*ii, *jj); for (jj = &A[1]; ii <= &A[55]; ii++, jj++) *ii = mod_diff(*ii, *jj); fptr = &A[54]; return A[55]; }
int gb_flip_cycle() { register int*ii,*jj; for(ii= &A[1],jj= &A[32];jj<=&A[55];ii++,jj++) *ii= mod_diff(*ii,*jj); for(jj= &A[1];ii<=&A[55];ii++,jj++) *ii= mod_diff(*ii,*jj); gb_fptr= &A[54]; return A[55]; }
void rng_init_rand(RNG *rand, int seed) { int i; int prev = seed, next = 1; seed = prev = mod_diff(prev, 0); A[55] = prev; for (i = 21; i; i = (i + 21) % 55) { A[i] = next; next = mod_diff(prev, next); if (seed & 1) seed = 0x40000000 + (seed >> 1); else seed >>= 1; next = mod_diff(next, seed); prev = A[i]; }
void gb_init_rand(long seed) { register long i; register long prev= seed,next= 1; seed= prev= mod_diff(prev,0); A[55]= prev; for(i= 21;i;i= (i+21)%55){ A[i]= next; next= mod_diff(prev,next); if(seed&1)seed= 0x40000000+(seed>>1); else seed>>= 1; next= mod_diff(next,seed); prev= A[i]; }