18#include "CLHEP/Random/defs.h"
19#include "CLHEP/Random/RandChiSquare.h"
20#include "CLHEP/Random/DoubConv.h"
21#include "CLHEP/Utility/thread_local.h"
36 return genChiSquare( anEngine, a );
41 return genChiSquare( anEngine, a );
45 return genChiSquare( localEngine.get(), a );
50 for(
double* v = vect; v != vect+size; ++v )
55 const int size,
double* vect,
58 for(
double* v = vect; v != vect+size; ++v )
59 *v =
shoot(anEngine,a);
63 for(
double* v = vect; v != vect+size; ++v )
69 for(
double* v = vect; v != vect+size; ++v )
92 static CLHEP_THREAD_LOCAL
double a_in = -1.0,b,vm,vp,vd;
97 if( a < 1 )
return (-1.0);
103 u = anEngine->
flat();
104 v = anEngine->
flat() * 0.857763884960707;
109 if (z < 0.0) r = r + zz * z / (3.0 * z);
110 if (u < r * 0.3894003915)
return(z*z);
111 if (zz > (1.036961043 / u + 1.4))
continue;
112 if (2 * std::log(u) < (- zz * 0.5 ))
return(z*z);
119 b = std::sqrt(a - 1.0);
120 vm = - 0.6065306597 * (1.0 - 0.25 / (b * b + 1.0));
121 vm = (-b > vm)? -b : vm;
122 vp = 0.6065306597 * (0.7071067812 + b) / (0.5 + b);
128 u = anEngine->
flat();
129 v = anEngine->
flat() * vd + vm;
131 if (z < -b)
continue;
134 if (z < 0.0) r = r + zz * z / (3.0 * (z + b));
135 if (u < r * 0.3894003915)
return((z + b)*(z + b));
136 if (zz > (1.036961043 / u + 1.4))
continue;
137 if (2 * std::log(u) < (std::log(1.0 + z / b) * b * b - zz * 0.5 - z * b))
return((z + b)*(z + b));
143 long pr=os.precision(20);
144 std::vector<unsigned long> t(2);
145 os <<
" " <<
name() <<
"\n";
146 os <<
"Uvec" <<
"\n";
148 os << defaultA <<
" " << t[0] <<
" " << t[1] <<
"\n";
152 long pr=os.precision(20);
153 os <<
" " <<
name() <<
"\n";
154 os << defaultA <<
"\n";
163 if (inName !=
name()) {
164 is.clear(std::ios::badbit | is.rdstate());
165 std::cerr <<
"Mismatch when expecting to read state of a "
166 <<
name() <<
" distribution\n"
167 <<
"Name found was " << inName
168 <<
"\nistream is left in the badbit state\n";
172 std::vector<unsigned long> t(2);
static double longs2double(const std::vector< unsigned long > &v)
static std::vector< unsigned long > dto2longs(double d)
static HepRandomEngine * getTheEngine()
void fireArray(const int size, double *vect)
std::istream & get(std::istream &is)
HepRandomEngine & engine()
static void shootArray(const int size, double *vect, double a=1.0)
std::ostream & put(std::ostream &os) const
bool possibleKeywordInput(IS &is, const std::string &key, T &t)