2 #include "PhotosRandom.h"
9 bool PhotosRandom::init =
false;
10 int PhotosRandom::iseed[2]= { 1802, 9373 };
11 int PhotosRandom::i97 = 96;
12 int PhotosRandom::j97 = 32;
13 double PhotosRandom::uran[97]= { 0.0 };
14 double PhotosRandom::cran = 362436.0 /16777216.0;
15 const double PhotosRandom::cdran = 7654321.0 /16777216.0;
16 const double PhotosRandom::cmran = 16777213.0/16777216.0;
18 void PhotosRandom::setSeed(
int s1,
int s2)
20 if(s1<0 || s1>31327)
Log::Fatal(
"PhotosRandom::setSeed(): Seed(1) out of range [0,31327]",8);
21 if(s2<0 || s2>30080)
Log::Fatal(
"PhotosRandom::setSeed(): Seed(2) out of range [0,30080]",9);
38 void PhotosRandom::initialize()
40 long IS1,IS2,IS3,IS4,IS5;
44 IS1=(iseed[0]/177)%177+2;
46 IS3=(iseed[1]/169)%178+1;
54 IS5=( ((IS1*IS2)%179)*IS3 )%179;
59 if( (IS4*IS5)%64>=32) S=S+T;
65 Log::Debug(0)<<
"PhotosRandom::inititalize(): seed: "<<iseed[0]<<
", "<<iseed[1]<<std::endl;
84 double PhotosRandom::randomReal()
86 if(!init)
Log::Fatal(
"PhotosRandom::randomReal(): generator not initialized",1);
90 ret = uran[i97]-uran[j97];
98 if(cran<0.0) cran+=cmran;
100 if(ret<0.0) ret+=1.0;
static ostream & Debug(unsigned short int code=0, bool count=true)
static void Fatal(string text, unsigned short int code=0)