#include "TRandom2.h"
#include "TRandom3.h"
ClassImp(TRandom2)
TRandom2::TRandom2(UInt_t seed)
{
SetName("Random2");
SetTitle("Random number generator with period of about 10**26");
SetSeed(seed);
}
TRandom2::~TRandom2()
{
}
Double_t TRandom2::Rndm(Int_t)
{
#define TAUSWORTHE(s,a,b,c,d) (((s &c) <<d) & 0xffffffffUL ) ^ ((((s <<a) & 0xffffffffUL )^s) >>b)
const double kScale = 2.3283064365386963e-10;
fSeed = TAUSWORTHE (fSeed, 13, 19, 4294967294UL, 12);
fSeed1 = TAUSWORTHE (fSeed1, 2, 25, 4294967288UL, 4);
fSeed2 = TAUSWORTHE (fSeed2, 3, 11, 4294967280UL, 17);
UInt_t iy = fSeed ^ fSeed1 ^ fSeed2;
if (iy) return kScale*static_cast<Double_t>(iy);
return Rndm();
}
void TRandom2::RndmArray(Int_t n, Float_t *array)
{
const double kScale = 2.3283064365386963e-10;
UInt_t iy;
for(Int_t i=0; i<n; i++) {
fSeed = TAUSWORTHE (fSeed, 13, 19, 4294967294UL, 12);
fSeed1 = TAUSWORTHE (fSeed1, 2, 25, 4294967288UL, 4);
fSeed2 = TAUSWORTHE (fSeed2, 3, 11, 4294967280UL, 17);
iy = fSeed ^ fSeed1 ^ fSeed2;
if (iy) array[i] = (Float_t)(kScale*static_cast<Double_t>(iy));
else array[i] = Rndm();
}
}
void TRandom2::RndmArray(Int_t n, Double_t *array)
{
const double kScale = 2.3283064365386963e-10;
UInt_t iy;
for(Int_t i=0; i<n; i++) {
fSeed = TAUSWORTHE (fSeed, 13, 19, 4294967294UL, 12);
fSeed1 = TAUSWORTHE (fSeed1, 2, 25, 4294967288UL, 4);
fSeed2 = TAUSWORTHE (fSeed2, 3, 11, 4294967280UL, 17);
iy = fSeed ^ fSeed1 ^ fSeed2;
if (iy) array[i] = kScale*static_cast<Double_t>(iy);
else array[i] = Rndm();
}
}
void TRandom2::SetSeed(UInt_t seed)
{
#define LCG(n) ((69069 * n) & 0xffffffffUL) // linear congurential generator
if (seed > 0) {
fSeed = LCG (seed);
if (fSeed < 2) fSeed += 2UL;
fSeed1 = LCG (fSeed);
if (fSeed1 < 8) fSeed1 += 8UL;
fSeed2 = LCG (fSeed1);
if (fSeed2 < 16) fSeed2 += 16UL;
} else {
TRandom3 r3(0);
fSeed = static_cast<UInt_t> (4294967296.*r3.Rndm());
fSeed1 = static_cast<UInt_t> (4294967296.*r3.Rndm());
fSeed2 = static_cast<UInt_t> (4294967296.*r3.Rndm());
if (fSeed < 2) fSeed += 2UL;
if (fSeed1 < 8) fSeed1 += 8UL;
if (fSeed2 < 16) fSeed2 += 16UL;
}
for (int i = 0; i < 6; ++i)
Rndm();
return;
}
Last change: Wed Jun 25 08:52:05 2008
Last generated: 2008-06-25 08:52
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.