13 #ifndef ROOT_Math_LCGEngine
14 #define ROOT_Math_LCGEngine
23 virtual double Rndm() = 0;
24 virtual ~TRandomEngine() {}
33 class LCGEngine :
public TRandomEngine {
38 typedef TRandomEngine BaseType;
39 typedef uint32_t Result_t;
40 typedef uint32_t StateInt_t;
42 LCGEngine() : fSeed(65539) { }
44 virtual ~LCGEngine() {}
46 void SetSeed(uint32_t seed) { fSeed = seed; }
48 virtual double Rndm() {
52 inline double operator() () {
return Rndm_impl(); }
55 fSeed = (1103515245 * fSeed + 12345) & 0x7fffffffUL;
60 static unsigned int MinInt() {
return 0; }
62 static unsigned int MaxInt() {
return 0xffffffff; }
64 static int Size() {
return 1; }
66 static std::string Name() {
return "LCGEngine"; }
69 void SetState(
const std::vector<uint32_t> & state) {
70 assert(!state.empty());
74 void GetState(std::vector<uint32_t> & state) {
78 int Counter()
const {
return 0; }
82 const double kCONS = 4.6566128730774E-10;
83 unsigned int rndm = IntRndm();
84 if (rndm != 0)
return kCONS*rndm;