Logo ROOT   6.10/09
Reference Guide
TRandomGen.h
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Author: Rene Brun 04/03/99
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TRandomGen
13 #define ROOT_TRandomGen
14 
15 
16 
17 //////////////////////////////////////////////////////////////////////////
18 // //
19 // TRandomGen //
20 // //
21 // random number generator class template con the engine //
22 //
23 // //
24 //////////////////////////////////////////////////////////////////////////
25 
26 #include "TRandom.h"
27 
28 template<class Engine>
29 class TRandomGen : public TRandom {
30 
31 protected:
32 
33  Engine fEngine; // random number generator engine
34 public:
35 
36  TRandomGen(ULong_t seed=1) {
37  fEngine.SetSeed(seed);
38  SetName(TString::Format("Random_%s",fEngine.Name().c_str() ) );
39  SetTitle(TString::Format("Random number generator: %s",fEngine.Name().c_str() ));
40  }
41  virtual ~TRandomGen() {}
42  using TRandom::Rndm;
43  virtual Double_t Rndm( ) { return fEngine(); }
44  virtual void RndmArray(Int_t n, Float_t *array) {
45  for (int i = 0; i < n; ++i) array[i] = fEngine();
46  }
47  virtual void RndmArray(Int_t n, Double_t *array) {
48  for (int i = 0; i < n; ++i) array[i] = fEngine();
49  }
50  virtual void SetSeed(ULong_t seed=0) {
51  fEngine.SetSeed(seed);
52  }
53 
54  ClassDef(TRandomGen,1) //Generic Random number generator template on the Engine type
55 };
56 
57 // some useful typedef
58 #include "Math/StdEngine.h"
59 #include "Math/MixMaxEngine.h"
60 
61 // not working wight now for this classes
62 //#define DEFINE_TEMPL_INSTANCE
63 #ifdef DEFINE_TEMPL_INSTANCE
64 
65 extern template class TRandomGen<ROOT::Math::MixMaxEngine<240,0>>;
66 extern template class TRandomGen<ROOT::Math::MixMaxEngine<256,2>>;
67 extern template class TRandomGen<ROOT::Math::MixMaxEngine<256,4>>;
68 extern template class TRandomGen<ROOT::Math::MixMaxEngine<17,0>>;
69 extern template class TRandomGen<ROOT::Math::MixMaxEngine<17,1>>;
70 
73 
74 #endif
75 
81 
82 
83 #endif
virtual ~TRandomGen()
Definition: TRandomGen.h:41
float Float_t
Definition: RtypesCore.h:53
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:131
int Int_t
Definition: RtypesCore.h:41
#define ClassDef(name, id)
Definition: Rtypes.h:297
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2345
TRandomGen< ROOT::Math::MixMaxEngine< 240, 0 > > TRandomMixMax
Definition: TRandomGen.h:76
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
virtual void RndmArray(Int_t n, Float_t *array)
Return an array of n random numbers uniformly distributed in ]0,1].
Definition: TRandomGen.h:44
TRandomGen< ROOT::Math::StdEngine< std::ranlux48 > > TRandomRanlux48
Definition: TRandomGen.h:80
virtual Double_t Rndm()
Machine independent random number generator.
Definition: TRandom.cxx:512
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
Definition: TRandomGen.h:50
virtual Double_t Rndm()
Machine independent random number generator.
Definition: TRandomGen.h:43
TRandomGen< ROOT::Math::MixMaxEngine< 17, 0 > > TRandomMixMax17
Definition: TRandomGen.h:78
Engine fEngine
Definition: TRandomGen.h:33
double Double_t
Definition: RtypesCore.h:55
unsigned long ULong_t
Definition: RtypesCore.h:51
TRandomGen(ULong_t seed=1)
Definition: TRandomGen.h:36
TRandomGen< ROOT::Math::MixMaxEngine< 256, 2 > > TRandomMixMax256
Definition: TRandomGen.h:77
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:155
const Int_t n
Definition: legend1.C:16
virtual void RndmArray(Int_t n, Double_t *array)
Return an array of n random numbers uniformly distributed in ]0,1].
Definition: TRandomGen.h:47
TRandomGen< ROOT::Math::StdEngine< std::mt19937_64 > > TRandomMT64
Definition: TRandomGen.h:79