39static const unsigned long int mask_lo = 0x00ffffffUL;
40static const unsigned long int mask_hi = ~0x00ffffffUL;
41static const unsigned long int two24 = 16777216;
52 unsigned long int u[24];
63static inline unsigned long int increment_state(){
64 unsigned int i = local_ranlux_state.i;
65 unsigned int j = local_ranlux_state.j;
66 long int delta = local_ranlux_state.u[j] - local_ranlux_state.u[i]
67 - local_ranlux_state.carry;
70 local_ranlux_state.carry = 1;
73 local_ranlux_state.carry = 0;
76 local_ranlux_state.u[i] = delta;
83 local_ranlux_state.i = i;
90 local_ranlux_state.j = j;
98static void ranlux_set(
unsigned long int s){
111 unsigned long int k = seed/53668;
112 seed = 40014*(seed-k*53668)-k*12211;
116 local_ranlux_state.u[i] = seed%two24;
119 local_ranlux_state.i = 23;
120 local_ranlux_state.j = 9;
121 local_ranlux_state.n = 0;
122 local_ranlux_state.skip = 389-24;
124 if (local_ranlux_state.u[23]&mask_hi){
125 local_ranlux_state.carry = 1;
127 local_ranlux_state.carry = 0;
142unsigned long int ranlux_get(){
143 const unsigned int skip = local_ranlux_state.skip;
144 unsigned long int r = increment_state();
146 local_ranlux_state.n++;
148 if (local_ranlux_state.n == 24){
150 local_ranlux_state.n = 0;
151 for (i = 0; i < skip; i++)
160void ranlux_print_state(){
162 unsigned char *p = (
unsigned char *) (&local_ranlux_state);
163 const size_t n =
sizeof (ranlux_state_t);
167 printf(
"%.2x", *(p+i));