65 #ifdef R__COMPLETE_MEM_TERMINATION 67 struct TRandomCleanup {
68 ~TRandomCleanup() {
delete gRandom; gRandom = 0; }
70 static TRandomCleanup gCleanupRandom;
84 SetTitle(
"Random number generator: Mersenne Twister");
104 const Int_t kM = 397;
105 const Int_t kN = 624;
106 const UInt_t kTemperingMaskB = 0x9d2c5680;
107 const UInt_t kTemperingMaskC = 0xefc60000;
108 const UInt_t kUpperMask = 0x80000000;
109 const UInt_t kLowerMask = 0x7fffffff;
110 const UInt_t kMatrixA = 0x9908b0df;
112 if (fCount624 >= kN) {
115 for (i=0; i < kN-kM; i++) {
116 y = (fMt[i] & kUpperMask) | (fMt[i+1] & kLowerMask);
117 fMt[i] = fMt[i+kM] ^ (y >> 1) ^ ((y & 0x1) ? kMatrixA : 0x0);
120 for ( ; i < kN-1 ; i++) {
121 y = (fMt[i] & kUpperMask) | (fMt[i+1] & kLowerMask);
122 fMt[i] = fMt[i+kM-kN] ^ (y >> 1) ^ ((y & 0x1) ? kMatrixA : 0x0);
125 y = (fMt[kN-1] & kUpperMask) | (fMt[0] & kLowerMask);
126 fMt[kN-1] = fMt[kM-1] ^ (y >> 1) ^ ((y & 0x1) ? kMatrixA : 0x0);
130 y = fMt[fCount624++];
132 y ^= ((y << 7 ) & kTemperingMaskB );
133 y ^= ((y << 15) & kTemperingMaskC );
137 if (y)
return ( (Double_t) y * 2.3283064365386963e-10);
146 for(Int_t i=0; i<n; i++) array[i]=(Float_t)Rndm();
158 const Int_t kM = 397;
159 const Int_t kN = 624;
160 const UInt_t kTemperingMaskB = 0x9d2c5680;
161 const UInt_t kTemperingMaskC = 0xefc60000;
162 const UInt_t kUpperMask = 0x80000000;
163 const UInt_t kLowerMask = 0x7fffffff;
164 const UInt_t kMatrixA = 0x9908b0df;
167 if (fCount624 >= kN) {
170 for (i=0; i < kN-kM; i++) {
171 y = (fMt[i] & kUpperMask) | (fMt[i+1] & kLowerMask);
172 fMt[i] = fMt[i+kM] ^ (y >> 1) ^ ((y & 0x1) ? kMatrixA : 0x0);
175 for ( ; i < kN-1 ; i++) {
176 y = (fMt[i] & kUpperMask) | (fMt[i+1] & kLowerMask);
177 fMt[i] = fMt[i+kM-kN] ^ (y >> 1) ^ ((y & 0x1) ? kMatrixA : 0x0);
180 y = (fMt[kN-1] & kUpperMask) | (fMt[0] & kLowerMask);
181 fMt[kN-1] = fMt[kM-1] ^ (y >> 1) ^ ((y & 0x1) ? kMatrixA : 0x0);
185 y = fMt[fCount624++];
187 y ^= ((y << 7 ) & kTemperingMaskB );
188 y ^= ((y << 15) & kTemperingMaskC );
192 array[k] = Double_t( y * 2.3283064365386963
e-10);
215 for(Int_t i=1; i<624; i++) {
216 fMt[i] = (1812433253 * ( fMt[i-1] ^ ( fMt[i-1] >> 30)) + i );
225 for (Int_t i = 0; i< 624; i++) {
226 fMt[i] =
static_cast<UInt_t
> (4294967296.*r.
Rndm());
229 for (Int_t i = 0; i < 10; ++i) Rndm();
238 void TRandom3::Streamer(TBuffer &R__b)
240 if (R__b.IsReading()) {
242 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
244 R__b.ReadClassBuffer(TRandom3::Class(),
this, R__v, R__s, R__c);
248 TRandom::Streamer(R__b);
249 R__b.ReadStaticArray(fMt);
251 R__b.CheckByteCount(R__s, R__c, TRandom3::IsA());
255 R__b.WriteClassBuffer(TRandom3::Class(),
this);
Random number generator class based on M.
virtual Double_t Rndm()
Machine independent random number generator.
virtual ~TRandom3()
Default destructor.
Random number generator class based on the maximally quidistributed combined Tausworthe generator by ...
virtual void SetSeed(ULong_t seed=0)
Set the random generator sequence if seed is 0 (default value) a TUUID is generated and used to fill ...
you should not use this method at all Int_t y
This is the base class for the ROOT Random number generators.
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
virtual void RndmArray(Int_t n, Float_t *array)
Return an array of n random numbers uniformly distributed in ]0,1].
virtual Double_t Rndm()
TausWorth generator from L'Ecuyer, uses as seed 3x32bits integers Use a mask of 0xffffffffUL to make ...
TRandom3(UInt_t seed=4357)
Default constructor If seed is 0, the seed is automatically computed via a TUUID object.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e