54 const int maxIndex = 215;
64 long seedlist[2]={0,0};
79 long seedlist[2]={0,0};
82 int numEngines = numberOfEngines++;
83 int cycle =
std::abs(
int(numEngines/maxIndex));
84 int curIndex =
std::abs(
int(numEngines%maxIndex));
86 long mask = ((cycle & 0x007fffff) << 8);
88 seed = seedlist[0]^
mask;
101 long seedlist[2]={0,0};
104 int cycle =
std::abs(
int(rowIndex/maxIndex));
105 int row =
std::abs(
int(rowIndex%maxIndex));
107 long mask = (( cycle & 0x000007ff ) << 20 );
109 seed = ( seedlist[
col] )^mask;
134 const int ecuyer_a = 53668;
135 const int ecuyer_b = 40014;
136 const int ecuyer_c = 12211;
137 const int ecuyer_d = 2147483563;
139 const int lux_levels[5] = {0,24,73,199,365};
141 long int_seed_table[24];
142 long next_seed =
seed;
150 if( (lux > 4)||(lux < 0) ){
154 nskip = lux_levels[3];
162 for(i = 0;i != 24;i++){
163 k_multiple = next_seed / ecuyer_a;
164 next_seed = ecuyer_b * (next_seed - k_multiple * ecuyer_a)
165 - k_multiple * ecuyer_c ;
166 if(next_seed < 0)next_seed += ecuyer_d;
170 for(i = 0;i != 24;i++)
184 const int ecuyer_a = 53668;
185 const int ecuyer_b = 40014;
186 const int ecuyer_c = 12211;
187 const int ecuyer_d = 2147483563;
189 const int lux_levels[5] = {0,24,73,199,365};
191 long int_seed_table[24];
192 long k_multiple,next_seed;
209 if( (lux > 4)||(lux < 0) ){
213 nskip = lux_levels[3];
220 for( i = 0;(i != 24)&&(*seedptr != 0);i++){
226 next_seed = int_seed_table[i-1];
228 k_multiple = next_seed / ecuyer_a;
229 next_seed = ecuyer_b * (next_seed - k_multiple * ecuyer_a)
230 - k_multiple * ecuyer_c ;
231 if(next_seed < 0)next_seed += ecuyer_d;
236 for(i = 0;i != 24;i++)
250 std::ofstream outFile( filename, std::ios::out ) ;
251 if (!outFile.bad()) {
253 std::vector<unsigned long>
v =
put();
254 for (
unsigned int i=0; i<v.size(); ++i) {
255 outFile << v[i] <<
"\n";
264 std::cerr <<
" -- Engine state remains unchanged\n";
268 std::vector<unsigned long>
v;
273 inFile.clear(std::ios::badbit | inFile.rdstate());
274 std::cerr <<
"\nRanluxEngine state (vector) description improper."
275 <<
"\nrestoreStatus has failed."
276 <<
"\nInput stream is probably mispositioned now." << std::endl;
285 if (!inFile.bad() && !inFile.eof()) {
287 for (
int i=0; i<24; ++i)
297 std::cout << std::endl;
298 std::cout <<
"--------- Ranlux engine status ---------" << std::endl;
299 std::cout <<
" Initial seed = " <<
theSeed << std::endl;
300 std::cout <<
" float_seed_table[] = ";
301 for (
int i=0; i<24; ++i)
303 std::cout << std::endl;
304 std::cout <<
" i_lag = " <<
i_lag <<
", j_lag = " <<
j_lag << std::endl;
305 std::cout <<
" carry = " <<
carry <<
", count24 = " <<
count24 << std::endl;
306 std::cout <<
" luxury = " <<
luxury <<
" nskip = " <<
nskip << std::endl;
307 std::cout <<
"----------------------------------------" << std::endl;
342 for( i = 0; i !=
nskip ; i++){
357 return (
double) next_random;
367 for (index=0; index<size; ++index) {
387 vect[index] = (double)next_random;
395 for( i = 0; i !=
nskip ; i++){
413 RanluxEngine::operator double() {
417 RanluxEngine::operator float() {
418 return float(
flat() );
421 RanluxEngine::operator
unsigned int() {
422 return ((
unsigned int)(
flat() * exponent_bit_32()) & 0xffffffff) |
423 (((
unsigned int)(float_seed_table[i_lag]*exponent_bit_32())>>16) & 0xff);
430 char beginMarker[] =
"RanluxEngine-begin";
431 os << beginMarker <<
"\nUvec\n";
432 std::vector<unsigned long>
v =
put();
433 for (
unsigned int i=0; i<v.size(); ++i) {
440 std::vector<unsigned long>
v;
441 v.push_back (engineIDulong<RanluxEngine>());
442 for (
int i=0; i<24; ++i) {
446 v.push_back(static_cast<unsigned long>(
i_lag));
447 v.push_back(static_cast<unsigned long>(
j_lag));
449 v.push_back(static_cast<unsigned long>(
count24));
450 v.push_back(static_cast<unsigned long>(
luxury));
451 v.push_back(static_cast<unsigned long>(
nskip));
463 if (strcmp(beginMarker,
"RanluxEngine-begin")) {
464 is.clear(std::ios::badbit | is.rdstate());
465 std::cerr <<
"\nInput stream mispositioned or"
466 <<
"\nRanluxEngine state description missing or"
467 <<
"\nwrong engine type found." << std::endl;
474 return "RanluxEngine-begin";
480 std::vector<unsigned long>
v;
485 is.clear(std::ios::badbit | is.rdstate());
486 std::cerr <<
"\nRanluxEngine state (vector) description improper."
487 <<
"\ngetState() has failed."
488 <<
"\nInput stream is probably mispositioned now." << std::endl;
500 for (
int i=0; i<24; ++i) {
509 if (strcmp(endMarker,
"RanluxEngine-end")) {
510 is.clear(std::ios::badbit | is.rdstate());
511 std::cerr <<
"\nRanluxEngine state description incomplete."
512 <<
"\nInput stream is probably mispositioned now." << std::endl;
519 if ((v[0] & 0xffffffffUL) != engineIDulong<RanluxEngine>()) {
521 "\nRanluxEngine get:state vector has wrong ID word - state unchanged\n";
530 "\nRanluxEngine get:state vector has wrong length - state unchanged\n";
533 for (
int i=0; i<24; ++i) {