Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CLHEP::RandGaussZiggurat Class Reference

#include <RandGaussZiggurat.h>

Inheritance diagram for CLHEP::RandGaussZiggurat:
Collaboration diagram for CLHEP::RandGaussZiggurat:

Public Member Functions

 RandGaussZiggurat (HepRandomEngine &anEngine, double mean=0.0, double stdDev=1.0)
 
 RandGaussZiggurat (HepRandomEngine *anEngine, double mean=0.0, double stdDev=1.0)
 
virtual ~RandGaussZiggurat ()
 
float fire ()
 
float fire (float mean, float stdDev)
 
void fireArray (const int size, float *vect)
 
void fireArray (const int size, double *vect)
 
void fireArray (const int size, float *vect, float mean, float stdDev)
 
void fireArray (const int size, double *vect, double mean, double stdDev)
 
virtual double operator() ()
 
virtual double operator() (double mean, double stdDev)
 
std::ostream & put (std::ostream &os) const
 
std::istream & get (std::istream &is)
 
std::string name () const
 
HepRandomEngineengine ()
 
- Public Member Functions inherited from CLHEP::RandGauss
 RandGauss (HepRandomEngine &anEngine, double mean=0.0, double stdDev=1.0)
 
 RandGauss (HepRandomEngine *anEngine, double mean=0.0, double stdDev=1.0)
 
virtual ~RandGauss ()
 
double fire ()
 
double fire (double mean, double stdDev)
 
void fireArray (const int size, double *vect)
 
void fireArray (const int size, double *vect, double mean, double stdDev)
 
bool getF () const
 
void setF (bool val)
 
- Public Member Functions inherited from CLHEP::HepRandom
 HepRandom ()
 
 HepRandom (long seed)
 
 HepRandom (HepRandomEngine &algorithm)
 
 HepRandom (HepRandomEngine *algorithm)
 
virtual ~HepRandom ()
 
double flat ()
 
void flatArray (const int size, double *vect)
 
double flat (HepRandomEngine *theNewEngine)
 
void flatArray (HepRandomEngine *theNewEngine, const int size, double *vect)
 

Static Public Member Functions

static float shoot ()
 
static float shoot (float mean, float stdDev)
 
static void shootArray (const int size, float *vect, float mean=0.0, float stdDev=1.0)
 
static void shootArray (const int size, double *vect, double mean=0.0, double stdDev=1.0)
 
static float shoot (HepRandomEngine *anotherEngine)
 
static float shoot (HepRandomEngine *anotherEngine, float mean, float stdDev)
 
static void shootArray (HepRandomEngine *anotherEngine, const int size, float *vect, float mean=0.0, float stdDev=1.0)
 
static void shootArray (HepRandomEngine *anotherEngine, const int size, double *vect, double mean=0.0, double stdDev=1.0)
 
static std::string distributionName ()
 
static bool ziggurat_init ()
 
- Static Public Member Functions inherited from CLHEP::RandGauss
static double shoot ()
 
static double shoot (double mean, double stdDev)
 
static void shootArray (const int size, double *vect, double mean=0.0, double stdDev=1.0)
 
static double shoot (HepRandomEngine *anEngine)
 
static double shoot (HepRandomEngine *anEngine, double mean, double stdDev)
 
static void shootArray (HepRandomEngine *anEngine, const int size, double *vect, double mean=0.0, double stdDev=1.0)
 
static std::string distributionName ()
 
static bool getFlag ()
 
static void setFlag (bool val)
 
static void saveEngineStatus (const char filename[]="Config.conf")
 
static void restoreEngineStatus (const char filename[]="Config.conf")
 
static std::ostream & saveFullState (std::ostream &os)
 
static std::istream & restoreFullState (std::istream &is)
 
static std::ostream & saveDistState (std::ostream &os)
 
static std::istream & restoreDistState (std::istream &is)
 
- Static Public Member Functions inherited from CLHEP::HepRandom
static void setTheSeed (long seed, int lux=3)
 
static long getTheSeed ()
 
static void setTheSeeds (const long *seeds, int aux=-1)
 
static const long * getTheSeeds ()
 
static void getTheTableSeeds (long *seeds, int index)
 
static HepRandomgetTheGenerator ()
 
static void setTheEngine (HepRandomEngine *theNewEngine)
 
static HepRandomEnginegetTheEngine ()
 
static void saveEngineStatus (const char filename[]="Config.conf")
 
static void restoreEngineStatus (const char filename[]="Config.conf")
 
static std::ostream & saveFullState (std::ostream &os)
 
static std::istream & restoreFullState (std::istream &is)
 
static std::ostream & saveDistState (std::ostream &os)
 
static std::istream & restoreDistState (std::istream &is)
 
static std::ostream & saveStaticRandomStates (std::ostream &os)
 
static std::istream & restoreStaticRandomStates (std::istream &is)
 
static void showEngineStatus ()
 
static int createInstance ()
 
static std::string distributionName ()
 

Static Protected Member Functions

static unsigned long ziggurat_SHR3 (HepRandomEngine *anEngine)
 
static float ziggurat_UNI (HepRandomEngine *anEngine)
 
static float ziggurat_RNOR (HepRandomEngine *anEngine)
 
static float ziggurat_nfix (long hz, HepRandomEngine *anEngine)
 
- Static Protected Member Functions inherited from CLHEP::RandGauss
static double getVal ()
 
static void setVal (double nextVal)
 

Static Protected Attributes

static CLHEP_THREAD_LOCAL
unsigned long 
kn [128]
 
static CLHEP_THREAD_LOCAL
unsigned long 
ke [256]
 
static CLHEP_THREAD_LOCAL float wn [128]
 
static CLHEP_THREAD_LOCAL float fn [128]
 
static CLHEP_THREAD_LOCAL float we [256]
 
static CLHEP_THREAD_LOCAL float fe [256]
 
static CLHEP_THREAD_LOCAL bool ziggurat_is_init = false
 
- Static Protected Attributes inherited from CLHEP::HepRandom
static const long seedTable [215][2]
 

Additional Inherited Members

- Protected Member Functions inherited from CLHEP::RandGauss
double normal ()
 
- Protected Attributes inherited from CLHEP::RandGauss
double defaultMean
 
double defaultStdDev
 
std::shared_ptr< HepRandomEnginelocalEngine
 

Detailed Description

Author
ATLAS

Definition at line 37 of file RandGaussZiggurat.h.

Constructor & Destructor Documentation

CLHEP::RandGaussZiggurat::RandGaussZiggurat ( HepRandomEngine anEngine,
double  mean = 0.0,
double  stdDev = 1.0 
)
inline

Definition at line 137 of file RandGaussZiggurat.h.

137  : RandGauss(anEngine, mean, stdDev)
138 {
139 }
RandGauss(HepRandomEngine &anEngine, double mean=0.0, double stdDev=1.0)
CLHEP::RandGaussZiggurat::RandGaussZiggurat ( HepRandomEngine anEngine,
double  mean = 0.0,
double  stdDev = 1.0 
)
inline

Definition at line 141 of file RandGaussZiggurat.h.

141  : RandGauss(anEngine, mean, stdDev)
142 {
143 }
RandGauss(HepRandomEngine &anEngine, double mean=0.0, double stdDev=1.0)
CLHEP::RandGaussZiggurat::~RandGaussZiggurat ( )
virtual

Definition at line 14 of file RandGaussZiggurat.cc.

14  {
15 }

Member Function Documentation

static std::string CLHEP::RandGaussZiggurat::distributionName ( )
inlinestatic

Definition at line 87 of file RandGaussZiggurat.h.

87 {return "RandGaussZiggurat";}
HepRandomEngine & CLHEP::RandGaussZiggurat::engine ( )
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 12 of file RandGaussZiggurat.cc.

12 {return RandGauss::engine();}
HepRandomEngine & engine()
Definition: RandGauss.cc:43

Here is the call graph for this function:

float CLHEP::RandGaussZiggurat::fire ( )
inline

Definition at line 67 of file RandGaussZiggurat.h.

double defaultStdDev
Definition: RandGauss.h:153
std::shared_ptr< HepRandomEngine > localEngine
Definition: RandGauss.h:155
double defaultMean
Definition: RandGauss.h:152
static float ziggurat_RNOR(HepRandomEngine *anEngine)

Here is the call graph for this function:

Here is the caller graph for this function:

float CLHEP::RandGaussZiggurat::fire ( float  mean,
float  stdDev 
)
inline

Definition at line 69 of file RandGaussZiggurat.h.

69 {return ziggurat_RNOR(localEngine.get()) * stdDev + mean;};
std::shared_ptr< HepRandomEngine > localEngine
Definition: RandGauss.h:155
static float ziggurat_RNOR(HepRandomEngine *anEngine)

Here is the call graph for this function:

void CLHEP::RandGaussZiggurat::fireArray ( const int  size,
float *  vect 
)

Definition at line 137 of file RandGaussZiggurat.cc.

138 {
139  for (int i=0; i<size; ++i) {
140  vect[i] = fire( defaultMean, defaultStdDev );
141  }
142 }
double defaultStdDev
Definition: RandGauss.h:153
double defaultMean
Definition: RandGauss.h:152

Here is the call graph for this function:

void CLHEP::RandGaussZiggurat::fireArray ( const int  size,
double *  vect 
)

Definition at line 144 of file RandGaussZiggurat.cc.

145 {
146  for (int i=0; i<size; ++i) {
147  vect[i] = fire( defaultMean, defaultStdDev );
148  }
149 }
double defaultStdDev
Definition: RandGauss.h:153
double defaultMean
Definition: RandGauss.h:152

Here is the call graph for this function:

void CLHEP::RandGaussZiggurat::fireArray ( const int  size,
float *  vect,
float  mean,
float  stdDev 
)

Definition at line 151 of file RandGaussZiggurat.cc.

152 {
153  for (int i=0; i<size; ++i) {
154  vect[i] = fire( mean, stdDev );
155  }
156 }

Here is the call graph for this function:

void CLHEP::RandGaussZiggurat::fireArray ( const int  size,
double *  vect,
double  mean,
double  stdDev 
)

Definition at line 158 of file RandGaussZiggurat.cc.

159 {
160  for (int i=0; i<size; ++i) {
161  vect[i] = fire( mean, stdDev );
162  }
163 }

Here is the call graph for this function:

std::istream & CLHEP::RandGaussZiggurat::get ( std::istream &  is)
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 173 of file RandGaussZiggurat.cc.

173  {
174  std::string inName;
175  is >> inName;
176  if (inName != name()) {
177  is.clear(std::ios::badbit | is.rdstate());
178  std::cerr << "Mismatch when expecting to read state of a "
179  << name() << " distribution\n"
180  << "Name found was " << inName
181  << "\nistream is left in the badbit state\n";
182  return is;
183  }
184  RandGauss::get(is);
185  return is;
186 }
std::istream & get(std::istream &is)
Definition: RandGauss.cc:275
std::string name() const

Here is the call graph for this function:

std::string CLHEP::RandGaussZiggurat::name ( ) const
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 17 of file RandGaussZiggurat.cc.

18 {
19  return "RandGaussZiggurat";
20 }

Here is the caller graph for this function:

double CLHEP::RandGaussZiggurat::operator() ( )
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 101 of file RandGaussZiggurat.cc.

101  {
103 }
double defaultStdDev
Definition: RandGauss.h:153
std::shared_ptr< HepRandomEngine > localEngine
Definition: RandGauss.h:155
double defaultMean
Definition: RandGauss.h:152
static float ziggurat_RNOR(HepRandomEngine *anEngine)

Here is the call graph for this function:

double CLHEP::RandGaussZiggurat::operator() ( double  mean,
double  stdDev 
)
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 105 of file RandGaussZiggurat.cc.

105  {
106  return ziggurat_RNOR(localEngine.get()) * stdDev + mean;
107 }
std::shared_ptr< HepRandomEngine > localEngine
Definition: RandGauss.h:155
static float ziggurat_RNOR(HepRandomEngine *anEngine)

Here is the call graph for this function:

std::ostream & CLHEP::RandGaussZiggurat::put ( std::ostream &  os) const
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 165 of file RandGaussZiggurat.cc.

165  {
166  int pr=os.precision(20);
167  os << " " << name() << "\n";
168  RandGauss::put(os);
169  os.precision(pr);
170  return os;
171 }
std::string name() const
std::ostream & put(std::ostream &os) const
Definition: RandGauss.cc:256

Here is the call graph for this function:

static float CLHEP::RandGaussZiggurat::shoot ( )
inlinestatic

Definition at line 49 of file RandGaussZiggurat.h.

static HepRandomEngine * getTheEngine()
Definition: Random.cc:265
static float ziggurat_RNOR(HepRandomEngine *anEngine)

Here is the call graph for this function:

Here is the caller graph for this function:

static float CLHEP::RandGaussZiggurat::shoot ( float  mean,
float  stdDev 
)
inlinestatic

Definition at line 50 of file RandGaussZiggurat.h.

50 {return shoot()*stdDev + mean;};

Here is the call graph for this function:

Here is the caller graph for this function:

static float CLHEP::RandGaussZiggurat::shoot ( HepRandomEngine anotherEngine)
inlinestatic

Definition at line 58 of file RandGaussZiggurat.h.

58 {return ziggurat_RNOR(anotherEngine);};
static float ziggurat_RNOR(HepRandomEngine *anEngine)

Here is the call graph for this function:

static float CLHEP::RandGaussZiggurat::shoot ( HepRandomEngine anotherEngine,
float  mean,
float  stdDev 
)
inlinestatic

Definition at line 59 of file RandGaussZiggurat.h.

59 {return shoot(anotherEngine)*stdDev + mean;};

Here is the call graph for this function:

Here is the caller graph for this function:

void CLHEP::RandGaussZiggurat::shootArray ( const int  size,
float *  vect,
float  mean = 0.0,
float  stdDev = 1.0 
)
static

Definition at line 109 of file RandGaussZiggurat.cc.

110 {
111  for (int i=0; i<size; ++i) {
112  vect[i] = shoot(mean,stdDev);
113  }
114 }

Here is the call graph for this function:

void CLHEP::RandGaussZiggurat::shootArray ( const int  size,
double *  vect,
double  mean = 0.0,
double  stdDev = 1.0 
)
static

Definition at line 116 of file RandGaussZiggurat.cc.

117 {
118  for (int i=0; i<size; ++i) {
119  vect[i] = shoot(mean,stdDev);
120  }
121 }

Here is the call graph for this function:

void CLHEP::RandGaussZiggurat::shootArray ( HepRandomEngine anotherEngine,
const int  size,
float *  vect,
float  mean = 0.0,
float  stdDev = 1.0 
)
static

Definition at line 123 of file RandGaussZiggurat.cc.

124 {
125  for (int i=0; i<size; ++i) {
126  vect[i] = shoot(anEngine,mean,stdDev);
127  }
128 }

Here is the call graph for this function:

void CLHEP::RandGaussZiggurat::shootArray ( HepRandomEngine anotherEngine,
const int  size,
double *  vect,
double  mean = 0.0,
double  stdDev = 1.0 
)
static

Definition at line 130 of file RandGaussZiggurat.cc.

131 {
132  for (int i=0; i<size; ++i) {
133  vect[i] = shoot(anEngine,mean,stdDev);
134  }
135 }

Here is the call graph for this function:

bool CLHEP::RandGaussZiggurat::ziggurat_init ( )
static

Definition at line 22 of file RandGaussZiggurat.cc.

23 {
24  const double rzm1 = 2147483648.0, rzm2 = 4294967296.;
25  double dn=3.442619855899,tn=dn,vn=9.91256303526217e-3, q;
26  double de=7.697117470131487, te=de, ve=3.949659822581572e-3;
27  int i;
28 
29 /* Set up tables for RNOR */
30  q=vn/std::exp(-.5*dn*dn);
31  kn[0]=(unsigned long)((dn/q)*rzm1);
32  kn[1]=0;
33 
34  wn[0]=q/rzm1;
35  wn[127]=dn/rzm1;
36 
37  fn[0]=1.;
38  fn[127]=std::exp(-.5*dn*dn);
39 
40  for(i=126;i>=1;i--) {
41  dn=std::sqrt(-2.*std::log(vn/dn+std::exp(-.5*dn*dn)));
42  kn[i+1]=(unsigned long)((dn/tn)*rzm1);
43  tn=dn;
44  fn[i]=std::exp(-.5*dn*dn);
45  wn[i]=dn/rzm1;
46  }
47 
48 /* Set up tables for REXP */
49  q = ve/std::exp(-de);
50  ke[0]=(unsigned long)((de/q)*rzm2);
51  ke[1]=0;
52 
53  we[0]=q/rzm2;
54  we[255]=de/rzm2;
55 
56  fe[0]=1.;
57  fe[255]=std::exp(-de);
58 
59  for(i=254;i>=1;i--) {
60  de=-std::log(ve/de+std::exp(-de));
61  ke[i+1]= (unsigned long)((de/te)*rzm2);
62  te=de;
63  fe[i]=std::exp(-de);
64  we[i]=de/rzm2;
65  }
66  ziggurat_is_init=true;
67 
68  //std::cout<<"Done RandGaussZiggurat::ziggurat_init()"<<std::endl;
69 
70  return true;
71 }
static CLHEP_THREAD_LOCAL float fe[256]
static CLHEP_THREAD_LOCAL float wn[128]
static CLHEP_THREAD_LOCAL unsigned long kn[128]
static CLHEP_THREAD_LOCAL unsigned long ke[256]
static CLHEP_THREAD_LOCAL float fn[128]
static CLHEP_THREAD_LOCAL bool ziggurat_is_init
static CLHEP_THREAD_LOCAL float we[256]

Here is the caller graph for this function:

float CLHEP::RandGaussZiggurat::ziggurat_nfix ( long  hz,
HepRandomEngine anEngine 
)
staticprotected

Definition at line 73 of file RandGaussZiggurat.cc.

74 {
76  const float r = 3.442620f; /* The start of the right tail */
77  float x, y;
78  unsigned long iz=hz&127;
79  for(;;)
80  {
81  x=hz*wn[iz]; /* iz==0, handles the base strip */
82  if(iz==0) {
83  do {
84  /* change to (1.0 - UNI) as argument to std::log(), because CLHEP generates [0,1),
85  while the original UNI generates (0,1] */
86  x=-std::log(1.0 - ziggurat_UNI(anEngine))*0.2904764; /* .2904764 is 1/r */
87  y=-std::log(1.0 - ziggurat_UNI(anEngine));
88  } while(y+y<x*x);
89  return (hz>0)? r+x : -r-x;
90  }
91  /* iz>0, handle the wedges of other strips */
92  if( fn[iz]+(1.0 - ziggurat_UNI(anEngine))*(fn[iz-1]-fn[iz]) < std::exp(-.5*x*x) ) return x;
93 
94  /* initiate, try to exit for(;;) for loop*/
95  hz=(signed)ziggurat_SHR3(anEngine);
96  iz=hz&127;
97  if((unsigned long)std::abs(hz)<kn[iz]) return (hz*wn[iz]);
98  }
99 }
static CLHEP_THREAD_LOCAL float wn[128]
static float ziggurat_UNI(HepRandomEngine *anEngine)
static unsigned long ziggurat_SHR3(HepRandomEngine *anEngine)
static CLHEP_THREAD_LOCAL unsigned long kn[128]
static CLHEP_THREAD_LOCAL float fn[128]
static CLHEP_THREAD_LOCAL bool ziggurat_is_init

Here is the call graph for this function:

Here is the caller graph for this function:

static float CLHEP::RandGaussZiggurat::ziggurat_RNOR ( HepRandomEngine anEngine)
inlinestaticprotected

Definition at line 115 of file RandGaussZiggurat.h.

115  {
117  long hz=(signed)ziggurat_SHR3(anEngine);
118  unsigned long iz=hz&127;
119  return ((unsigned long)std::abs(hz)<kn[iz]) ? hz*wn[iz] : ziggurat_nfix(hz,anEngine);
120  };
static CLHEP_THREAD_LOCAL float wn[128]
static float ziggurat_nfix(long hz, HepRandomEngine *anEngine)
static unsigned long ziggurat_SHR3(HepRandomEngine *anEngine)
static CLHEP_THREAD_LOCAL unsigned long kn[128]
static CLHEP_THREAD_LOCAL bool ziggurat_is_init

Here is the call graph for this function:

Here is the caller graph for this function:

static unsigned long CLHEP::RandGaussZiggurat::ziggurat_SHR3 ( HepRandomEngine anEngine)
inlinestaticprotected

Definition at line 113 of file RandGaussZiggurat.h.

113 {return (unsigned int)(*anEngine);};

Here is the caller graph for this function:

static float CLHEP::RandGaussZiggurat::ziggurat_UNI ( HepRandomEngine anEngine)
inlinestaticprotected

Definition at line 114 of file RandGaussZiggurat.h.

114 {return anEngine->flat();};

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

CLHEP_THREAD_LOCAL float CLHEP::RandGaussZiggurat::fe
staticprotected

Definition at line 109 of file RandGaussZiggurat.h.

CLHEP_THREAD_LOCAL float CLHEP::RandGaussZiggurat::fn
staticprotected

Definition at line 109 of file RandGaussZiggurat.h.

CLHEP_THREAD_LOCAL unsigned long CLHEP::RandGaussZiggurat::ke
staticprotected

Definition at line 108 of file RandGaussZiggurat.h.

CLHEP_THREAD_LOCAL unsigned long CLHEP::RandGaussZiggurat::kn
staticprotected

Definition at line 108 of file RandGaussZiggurat.h.

CLHEP_THREAD_LOCAL float CLHEP::RandGaussZiggurat::we
staticprotected

Definition at line 109 of file RandGaussZiggurat.h.

CLHEP_THREAD_LOCAL float CLHEP::RandGaussZiggurat::wn
staticprotected

Definition at line 109 of file RandGaussZiggurat.h.

CLHEP_THREAD_LOCAL bool CLHEP::RandGaussZiggurat::ziggurat_is_init = false
staticprotected

Definition at line 111 of file RandGaussZiggurat.h.


The documentation for this class was generated from the following files: