28 return fire( defaultMean );
33 for (
int i=0; i<size; ++i) vect[i] =
shoot(mean);
38 for (
int i=0; i<size; ++i) vect[i] =
shoot(mean);
43 for (
int i=0; i<size; ++i) vect[i] =
shoot(anEngine, mean);
48 for (
int i=0; i<size; ++i) vect[i] =
shoot(anEngine, mean);
53 for (
int i=0; i<size; ++i) vect[i] =
fire( defaultMean );
58 for (
int i=0; i<size; ++i) vect[i] =
fire( defaultMean );
63 for (
int i=0; i<size; ++i) vect[i] =
fire( mean );
68 for (
int i=0; i<size; ++i) vect[i] =
fire( mean );
72 int pr=os.precision(20);
73 std::vector<unsigned long> t(2);
74 os <<
" " <<
name() <<
"\n";
77 os << defaultMean <<
" " << t[0] <<
" " << t[1] <<
"\n";
81 int pr=os.precision(20);
82 os <<
" " <<
name() <<
"\n";
83 os << defaultMean <<
"\n";
92 if (inName !=
name()) {
93 is.clear(std::ios::badbit | is.rdstate());
94 std::cerr <<
"Mismatch when expecting to read state of a "
95 <<
name() <<
" distribution\n"
96 <<
"Name found was " << inName
97 <<
"\nistream is left in the badbit state\n";
101 std::vector<unsigned long> t(2);
114 unsigned long iz=jz&255;
119 if(iz==0)
return (7.69711-std::log(
ziggurat_UNI(anEngine)));
126 if(jz<
ke[iz])
return (jz*
we[iz]);
132 const double rzm1 = 2147483648.0, rzm2 = 4294967296.;
133 double dn=3.442619855899,tn=dn,vn=9.91256303526217e-3, q;
134 double de=7.697117470131487, te=de, ve=3.949659822581572e-3;
138 q=vn/std::exp(-.5*dn*dn);
139 kn[0]=(
unsigned long)((dn/q)*rzm1);
146 fn[127]=std::exp(-.5*dn*dn);
148 for(i=126;i>=1;i--) {
149 dn=std::sqrt(-2.*std::log(vn/dn+std::exp(-.5*dn*dn)));
150 kn[i+1]=(
unsigned long)((dn/tn)*rzm1);
152 fn[i]=std::exp(-.5*dn*dn);
157 q = ve/std::exp(-de);
158 ke[0]=(
unsigned long)((de/q)*rzm2);
165 fe[255]=std::exp(-de);
167 for(i=254;i>=1;i--) {
168 de=-std::log(ve/de+std::exp(-de));
169 ke[i+1]= (
unsigned long)((de/te)*rzm2);
static double longs2double(const std::vector< unsigned long > &v)
static std::vector< unsigned long > dto2longs(double d)
static CLHEP_THREAD_LOCAL float fn[128]
static bool ziggurat_init()
static unsigned long ziggurat_SHR3(HepRandomEngine *anEngine)
static CLHEP_THREAD_LOCAL unsigned long ke[256]
static void shootArray(const int size, float *vect, float mean=1.0)
static CLHEP_THREAD_LOCAL float fe[256]
HepRandomEngine & engine()
static float ziggurat_efix(unsigned long jz, HepRandomEngine *anEngine)
virtual ~RandExpZiggurat()
std::istream & get(std::istream &is)
static CLHEP_THREAD_LOCAL float wn[128]
RandExpZiggurat(HepRandomEngine &anEngine, double mean=1.0)
virtual double operator()()
static CLHEP_THREAD_LOCAL float we[256]
static CLHEP_THREAD_LOCAL unsigned long kn[128]
void fireArray(const int size, float *vect)
static float ziggurat_UNI(HepRandomEngine *anEngine)
static CLHEP_THREAD_LOCAL bool ziggurat_is_init
std::ostream & put(std::ostream &os) const
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
#define CLHEP_THREAD_LOCAL