27 return fire( defaultMean );
32 for (
int i=0; i<size; ++i) vect[i] =
shoot(mean);
37 for (
int i=0; i<size; ++i) vect[i] =
shoot(mean);
42 for (
int i=0; i<size; ++i) vect[i] =
shoot(anEngine, mean);
47 for (
int i=0; i<size; ++i) vect[i] =
shoot(anEngine, mean);
52 for (
int i=0; i<size; ++i) vect[i] =
fire( defaultMean );
57 for (
int i=0; i<size; ++i) vect[i] =
fire( defaultMean );
62 for (
int i=0; i<size; ++i) vect[i] =
fire( mean );
67 for (
int i=0; i<size; ++i) vect[i] =
fire( mean );
71 int pr=os.precision(20);
72 std::vector<unsigned long> t(2);
73 os <<
" " <<
name() <<
"\n";
76 os << defaultMean <<
" " << t[0] <<
" " << t[1] <<
"\n";
80 int pr=os.precision(20);
81 os <<
" " <<
name() <<
"\n";
82 os << defaultMean <<
"\n";
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";
100 std::vector<unsigned long> t(2);
113 unsigned long iz=jz&255;
118 if(iz==0)
return (7.69711-std::log(
ziggurat_UNI(anEngine)));
125 if(jz<
ke[iz])
return (jz*we[iz]);
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;
137 q=vn/std::exp(-.5*dn*dn);
138 kn[0]=(
unsigned long)((dn/q)*rzm1);
145 fn[127]=std::exp(-.5*dn*dn);
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);
151 fn[i]=std::exp(-.5*dn*dn);
156 q = ve/std::exp(-de);
157 ke[0]=(
unsigned long)((de/q)*rzm2);
164 fe[255]=std::exp(-de);
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);
static CLHEP_THREAD_LOCAL float we[256]
static unsigned long ziggurat_SHR3(HepRandomEngine *anEngine)
std::istream & get(std::istream &is)
virtual double operator()()
virtual ~RandExpZiggurat()
static float ziggurat_UNI(HepRandomEngine *anEngine)
static CLHEP_THREAD_LOCAL unsigned long ke[256]
static float ziggurat_efix(unsigned long jz, HepRandomEngine *anEngine)
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
#define CLHEP_THREAD_LOCAL
static void shootArray(const int size, float *vect, float mean=1.0)
static std::vector< unsigned long > dto2longs(double d)
static CLHEP_THREAD_LOCAL unsigned long kn[128]
static CLHEP_THREAD_LOCAL float fn[128]
RandExpZiggurat(HepRandomEngine &anEngine, double mean=1.0)
static CLHEP_THREAD_LOCAL bool ziggurat_is_init
void fireArray(const int size, float *vect)
std::ostream & put(std::ostream &os) const
HepRandomEngine & engine()
static bool ziggurat_init()
static CLHEP_THREAD_LOCAL float fe[256]
static double longs2double(const std::vector< unsigned long > &v)
static CLHEP_THREAD_LOCAL float wn[128]