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

#include <RandExpZiggurat.h>

Inheritance diagram for CLHEP::RandExpZiggurat:
Collaboration diagram for CLHEP::RandExpZiggurat:

Public Member Functions

 RandExpZiggurat (HepRandomEngine &anEngine, double mean=1.0)
 
 RandExpZiggurat (HepRandomEngine *anEngine, double mean=1.0)
 
virtual ~RandExpZiggurat ()
 
float fire ()
 
float fire (float mean)
 
void fireArray (const int size, float *vect)
 
void fireArray (const int size, double *vect)
 
void fireArray (const int size, float *vect, float mean)
 
void fireArray (const int size, double *vect, double mean)
 
virtual double operator() ()
 
float operator() (float mean)
 
std::ostream & put (std::ostream &os) const
 
std::istream & get (std::istream &is)
 
std::string name () const
 
HepRandomEngineengine ()
 
- 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)
 
static void shootArray (const int size, float *vect, float mean=1.0)
 
static void shootArray (const int size, double *vect, double mean=1.0)
 
static float shoot (HepRandomEngine *anEngine)
 
static float shoot (HepRandomEngine *anEngine, float mean)
 
static void shootArray (HepRandomEngine *anEngine, const int size, float *vect, float mean=1.0)
 
static void shootArray (HepRandomEngine *anEngine, const int size, double *vect, double mean=1.0)
 
static std::string distributionName ()
 
static bool ziggurat_init ()
 
- 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_REXP (HepRandomEngine *anEngine)
 
static float ziggurat_efix (unsigned long jz, HepRandomEngine *anEngine)
 

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]
 

Detailed Description

Author
ATLAS

Definition at line 36 of file RandExpZiggurat.h.

Constructor & Destructor Documentation

CLHEP::RandExpZiggurat::RandExpZiggurat ( HepRandomEngine anEngine,
double  mean = 1.0 
)
inline

Definition at line 158 of file RandExpZiggurat.h.

158  : localEngine(&anEngine, do_nothing_deleter()), defaultMean(mean)
159 {
160 }
CLHEP::RandExpZiggurat::RandExpZiggurat ( HepRandomEngine anEngine,
double  mean = 1.0 
)
inline

Definition at line 162 of file RandExpZiggurat.h.

162  : localEngine(anEngine), defaultMean(mean)
163 {
164 }
CLHEP::RandExpZiggurat::~RandExpZiggurat ( )
virtual

Definition at line 18 of file RandExpZiggurat.cc.

18  {
19 }

Member Function Documentation

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

Definition at line 109 of file RandExpZiggurat.h.

109 {return "RandExpZiggurat";}
HepRandomEngine & CLHEP::RandExpZiggurat::engine ( )
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 16 of file RandExpZiggurat.cc.

16 {return *localEngine;}
float CLHEP::RandExpZiggurat::fire ( )
inline

Definition at line 85 of file RandExpZiggurat.h.

85 {return fire(defaultMean);};

Here is the call graph for this function:

Here is the caller graph for this function:

float CLHEP::RandExpZiggurat::fire ( float  mean)
inline

Definition at line 86 of file RandExpZiggurat.h.

86 {return ziggurat_REXP(localEngine.get())*mean;};
static float ziggurat_REXP(HepRandomEngine *anEngine)

Here is the call graph for this function:

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

Definition at line 50 of file RandExpZiggurat.cc.

51 {
52  for (int i=0; i<size; ++i) vect[i] = fire( defaultMean );
53 }

Here is the call graph for this function:

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

Definition at line 55 of file RandExpZiggurat.cc.

56 {
57  for (int i=0; i<size; ++i) vect[i] = fire( defaultMean );
58 }

Here is the call graph for this function:

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

Definition at line 60 of file RandExpZiggurat.cc.

61 {
62  for (int i=0; i<size; ++i) vect[i] = fire( mean );
63 }

Here is the call graph for this function:

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

Definition at line 65 of file RandExpZiggurat.cc.

66 {
67  for (int i=0; i<size; ++i) vect[i] = fire( mean );
68 }

Here is the call graph for this function:

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

Reimplemented from CLHEP::HepRandom.

Definition at line 88 of file RandExpZiggurat.cc.

88  {
89  std::string inName;
90  is >> inName;
91  if (inName != name()) {
92  is.clear(std::ios::badbit | is.rdstate());
93  std::cerr << "Mismatch when expecting to read state of a "
94  << name() << " distribution\n"
95  << "Name found was " << inName
96  << "\nistream is left in the badbit state\n";
97  return is;
98  }
99  if (possibleKeywordInput(is, "Uvec", defaultMean)) {
100  std::vector<unsigned long> t(2);
101  is >> defaultMean >> t[0] >> t[1]; defaultMean = DoubConv::longs2double(t);
102  return is;
103  }
104  // is >> defaultMean encompassed by possibleKeywordInput
105  return is;
106 }
std::string name() const
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Definition: RandomEngine.h:167
static double longs2double(const std::vector< unsigned long > &v)
Definition: DoubConv.cc:114

Here is the call graph for this function:

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

Reimplemented from CLHEP::HepRandom.

Definition at line 14 of file RandExpZiggurat.cc.

14 {return "RandExpZiggurat";}

Here is the caller graph for this function:

double CLHEP::RandExpZiggurat::operator() ( )
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 25 of file RandExpZiggurat.cc.

26 {
27  return fire( defaultMean );
28 }

Here is the call graph for this function:

float CLHEP::RandExpZiggurat::operator() ( float  mean)
inline

Definition at line 99 of file RandExpZiggurat.h.

99 {return fire( mean );};

Here is the call graph for this function:

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

Reimplemented from CLHEP::HepRandom.

Definition at line 70 of file RandExpZiggurat.cc.

70  {
71  int pr=os.precision(20);
72  std::vector<unsigned long> t(2);
73  os << " " << name() << "\n";
74  os << "Uvec" << "\n";
75  t = DoubConv::dto2longs(defaultMean);
76  os << defaultMean << " " << t[0] << " " << t[1] << "\n";
77  os.precision(pr);
78  return os;
79 #ifdef REMOVED
80  int pr=os.precision(20);
81  os << " " << name() << "\n";
82  os << defaultMean << "\n";
83  os.precision(pr);
84  return os;
85 #endif
86 }
std::string name() const
static std::vector< unsigned long > dto2longs(double d)
Definition: DoubConv.cc:98

Here is the call graph for this function:

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

Definition at line 56 of file RandExpZiggurat.h.

56 {return shoot(HepRandom::getTheEngine());};
static HepRandomEngine * getTheEngine()
Definition: Random.cc:265

Here is the call graph for this function:

Here is the caller graph for this function:

static float CLHEP::RandExpZiggurat::shoot ( float  mean)
inlinestatic

Definition at line 57 of file RandExpZiggurat.h.

57 {return shoot(HepRandom::getTheEngine(),mean);};
static HepRandomEngine * getTheEngine()
Definition: Random.cc:265

Here is the call graph for this function:

Here is the caller graph for this function:

static float CLHEP::RandExpZiggurat::shoot ( HepRandomEngine anEngine)
inlinestatic

Definition at line 70 of file RandExpZiggurat.h.

70 {return ziggurat_REXP(anEngine);};
static float ziggurat_REXP(HepRandomEngine *anEngine)

Here is the call graph for this function:

static float CLHEP::RandExpZiggurat::shoot ( HepRandomEngine anEngine,
float  mean 
)
inlinestatic

Definition at line 71 of file RandExpZiggurat.h.

71 {return shoot(anEngine)*mean;};

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 30 of file RandExpZiggurat.cc.

31 {
32  for (int i=0; i<size; ++i) vect[i] = shoot(mean);
33 }

Here is the call graph for this function:

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

Definition at line 35 of file RandExpZiggurat.cc.

36 {
37  for (int i=0; i<size; ++i) vect[i] = shoot(mean);
38 }

Here is the call graph for this function:

void CLHEP::RandExpZiggurat::shootArray ( HepRandomEngine anEngine,
const int  size,
float *  vect,
float  mean = 1.0 
)
static

Definition at line 40 of file RandExpZiggurat.cc.

41 {
42  for (int i=0; i<size; ++i) vect[i] = shoot(anEngine, mean);
43 }

Here is the call graph for this function:

void CLHEP::RandExpZiggurat::shootArray ( HepRandomEngine anEngine,
const int  size,
double *  vect,
double  mean = 1.0 
)
static

Definition at line 45 of file RandExpZiggurat.cc.

46 {
47  for (int i=0; i<size; ++i) vect[i] = shoot(anEngine, mean);
48 }

Here is the call graph for this function:

float CLHEP::RandExpZiggurat::ziggurat_efix ( unsigned long  jz,
HepRandomEngine anEngine 
)
staticprotected

Definition at line 109 of file RandExpZiggurat.cc.

110 {
112 
113  unsigned long iz=jz&255;
114 
115  float x;
116  for(;;)
117  {
118  if(iz==0) return (7.69711-std::log(ziggurat_UNI(anEngine))); /* iz==0 */
119  x=jz*we[iz];
120  if( fe[iz]+ziggurat_UNI(anEngine)*(fe[iz-1]-fe[iz]) < std::exp(-x) ) return (x);
121 
122  /* initiate, try to exit for(;;) loop */
123  jz=ziggurat_SHR3(anEngine);
124  iz=(jz&255);
125  if(jz<ke[iz]) return (jz*we[iz]);
126  }
127 }
static CLHEP_THREAD_LOCAL float we[256]
static unsigned long ziggurat_SHR3(HepRandomEngine *anEngine)
static float ziggurat_UNI(HepRandomEngine *anEngine)
static CLHEP_THREAD_LOCAL unsigned long ke[256]
static CLHEP_THREAD_LOCAL bool ziggurat_is_init
static CLHEP_THREAD_LOCAL float fe[256]

Here is the call graph for this function:

Here is the caller graph for this function:

bool CLHEP::RandExpZiggurat::ziggurat_init ( )
static

Definition at line 129 of file RandExpZiggurat.cc.

130 {
131  const double rzm1 = 2147483648.0, rzm2 = 4294967296.;
132  double dn=3.442619855899,tn=dn,vn=9.91256303526217e-3, q;
133  double de=7.697117470131487, te=de, ve=3.949659822581572e-3;
134  int i;
135 
136 /* Set up tables for RNOR */
137  q=vn/std::exp(-.5*dn*dn);
138  kn[0]=(unsigned long)((dn/q)*rzm1);
139  kn[1]=0;
140 
141  wn[0]=q/rzm1;
142  wn[127]=dn/rzm1;
143 
144  fn[0]=1.;
145  fn[127]=std::exp(-.5*dn*dn);
146 
147  for(i=126;i>=1;i--) {
148  dn=std::sqrt(-2.*std::log(vn/dn+std::exp(-.5*dn*dn)));
149  kn[i+1]=(unsigned long)((dn/tn)*rzm1);
150  tn=dn;
151  fn[i]=std::exp(-.5*dn*dn);
152  wn[i]=dn/rzm1;
153  }
154 
155 /* Set up tables for REXP */
156  q = ve/std::exp(-de);
157  ke[0]=(unsigned long)((de/q)*rzm2);
158  ke[1]=0;
159 
160  we[0]=q/rzm2;
161  we[255]=de/rzm2;
162 
163  fe[0]=1.;
164  fe[255]=std::exp(-de);
165 
166  for(i=254;i>=1;i--) {
167  de=-std::log(ve/de+std::exp(-de));
168  ke[i+1]= (unsigned long)((de/te)*rzm2);
169  te=de;
170  fe[i]=std::exp(-de);
171  we[i]=de/rzm2;
172  }
173  ziggurat_is_init=true;
174  return true;
175 }
static CLHEP_THREAD_LOCAL float we[256]
static CLHEP_THREAD_LOCAL unsigned long ke[256]
static CLHEP_THREAD_LOCAL unsigned long kn[128]
static CLHEP_THREAD_LOCAL float fn[128]
static CLHEP_THREAD_LOCAL bool ziggurat_is_init
static CLHEP_THREAD_LOCAL float fe[256]
static CLHEP_THREAD_LOCAL float wn[128]

Here is the caller graph for this function:

static float CLHEP::RandExpZiggurat::ziggurat_REXP ( HepRandomEngine anEngine)
inlinestaticprotected

Definition at line 137 of file RandExpZiggurat.h.

137  {
139  unsigned long jz=ziggurat_SHR3(anEngine);
140  unsigned long iz=jz&255;
141  return (jz<ke[iz]) ? jz*we[iz] : ziggurat_efix(jz,anEngine);
142  };
static CLHEP_THREAD_LOCAL float we[256]
static unsigned long ziggurat_SHR3(HepRandomEngine *anEngine)
static CLHEP_THREAD_LOCAL unsigned long ke[256]
static float ziggurat_efix(unsigned long jz, HepRandomEngine *anEngine)
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::RandExpZiggurat::ziggurat_SHR3 ( HepRandomEngine anEngine)
inlinestaticprotected

Definition at line 135 of file RandExpZiggurat.h.

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

Here is the caller graph for this function:

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

Definition at line 136 of file RandExpZiggurat.h.

136 {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::RandExpZiggurat::fe
staticprotected

Definition at line 131 of file RandExpZiggurat.h.

CLHEP_THREAD_LOCAL float CLHEP::RandExpZiggurat::fn
staticprotected

Definition at line 131 of file RandExpZiggurat.h.

CLHEP_THREAD_LOCAL unsigned long CLHEP::RandExpZiggurat::ke
staticprotected

Definition at line 130 of file RandExpZiggurat.h.

CLHEP_THREAD_LOCAL unsigned long CLHEP::RandExpZiggurat::kn
staticprotected

Definition at line 130 of file RandExpZiggurat.h.

CLHEP_THREAD_LOCAL float CLHEP::RandExpZiggurat::we
staticprotected

Definition at line 131 of file RandExpZiggurat.h.

CLHEP_THREAD_LOCAL float CLHEP::RandExpZiggurat::wn
staticprotected

Definition at line 131 of file RandExpZiggurat.h.

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

Definition at line 133 of file RandExpZiggurat.h.


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