Logo ROOT   6.08/07
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 #ifndef ROOT_TRandom
27 #include "TRandom.h"
28 #endif
29 
30 template<class Engine>
31 class TRandomGen : public TRandom {
32 
33 protected:
34 
35  Engine fEngine; // random number generator engine
36 public:
37 
38  TRandomGen(ULong_t seed=1) {
39  fEngine.SetSeed(seed);
40  SetName(TString::Format("Random_%s",fEngine.Name().c_str() ) );
41  SetTitle(TString::Format("Random number generator: %s",fEngine.Name().c_str() ));
42  }
43  virtual ~TRandomGen() {}
44  using TRandom::Rndm;
45  virtual Double_t Rndm( ) { return fEngine(); }
46  virtual void RndmArray(Int_t n, Float_t *array) {
47  for (int i = 0; i < n; ++i) array[i] = fEngine();
48  }
49  virtual void RndmArray(Int_t n, Double_t *array) {
50  for (int i = 0; i < n; ++i) array[i] = fEngine();
51  }
52  virtual void SetSeed(ULong_t seed=0) {
53  fEngine.SetSeed(seed);
54  }
55 
56  ClassDef(TRandomGen,1) //Generic Random number generator template on the Engine type
57 };
58 
59 // some useful typedef
60 #include "Math/StdEngine.h"
61 #include "Math/MixMaxEngine.h"
62 
63 // not working wight now for this classes
64 //#define DEFINE_TEMPL_INSTANCE
65 #ifdef DEFINE_TEMPL_INSTANCE
66 
67 extern template class TRandomGen<ROOT::Math::MixMaxEngine<240,0>>;
68 extern template class TRandomGen<ROOT::Math::MixMaxEngine<256,2>>;
69 extern template class TRandomGen<ROOT::Math::MixMaxEngine<256,4>>;
70 extern template class TRandomGen<ROOT::Math::MixMaxEngine<17,0>>;
71 extern template class TRandomGen<ROOT::Math::MixMaxEngine<17,1>>;
72 
75 
76 #endif
77 
83 
84 
85 #endif
virtual ~TRandomGen()
Definition: TRandomGen.h:43
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:254
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:2335
TRandomGen< ROOT::Math::MixMaxEngine< 240, 0 > > TRandomMixMax
Definition: TRandomGen.h:78
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:31
virtual void RndmArray(Int_t n, Float_t *array)
Return an array of n random numbers uniformly distributed in ]0,1].
Definition: TRandomGen.h:46
TRandomGen< ROOT::Math::StdEngine< std::ranlux48 > > TRandomRanlux48
Definition: TRandomGen.h:82
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:52
virtual Double_t Rndm()
Machine independent random number generator.
Definition: TRandomGen.h:45
TRandomGen< ROOT::Math::MixMaxEngine< 17, 0 > > TRandomMixMax17
Definition: TRandomGen.h:80
Engine fEngine
Definition: TRandomGen.h:35
double Double_t
Definition: RtypesCore.h:55
unsigned long ULong_t
Definition: RtypesCore.h:51
TRandomGen(ULong_t seed=1)
Definition: TRandomGen.h:38
TRandomGen< ROOT::Math::MixMaxEngine< 256, 2 > > TRandomMixMax256
Definition: TRandomGen.h:79
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:49
TRandomGen< ROOT::Math::StdEngine< std::mt19937_64 > > TRandomMT64
Definition: TRandomGen.h:81