22 #include "CLHEP/Random/RandExponential.h"
23 #include "CLHEP/Random/DoubConv.h"
30 RandExponential::~RandExponential() {
33 double RandExponential::operator()() {
34 return fire( defaultMean );
37 double RandExponential::operator()(
double mean ) {
42 return -std::log(HepRandom::getTheEngine()->
flat());
46 return -std::log(HepRandom::getTheEngine()->
flat())*mean;
49 void RandExponential::shootArray(
const int size,
double* vect,
52 for(
double* v = vect; v != vect+size; ++v )
56 void RandExponential::shootArray(HepRandomEngine* anEngine,
const int size,
57 double* vect,
double mean )
59 for(
double* v = vect; v != vect+size; ++v )
60 *v =
shoot(anEngine, mean);
63 void RandExponential::fireArray(
const int size,
double* vect)
65 for(
double* v = vect; v != vect+size; ++v )
66 *v = fire( defaultMean );
69 void RandExponential::fireArray(
const int size,
double* vect,
72 for(
double* v = vect; v != vect+size; ++v )
76 std::ostream & RandExponential::put ( std::ostream & os )
const {
77 int pr=os.precision(20);
78 std::vector<unsigned long> t(2);
79 os <<
" " <<
name() <<
"\n";
81 t = DoubConv::dto2longs(defaultMean);
82 os << defaultMean <<
" " << t[0] <<
" " << t[1] <<
"\n";
87 std::istream & RandExponential::get ( std::istream & is ) {
90 if (inName !=
name()) {
91 is.clear(std::ios::badbit | is.rdstate());
92 std::cerr <<
"Mismatch when expecting to read state of a "
93 <<
name() <<
" distribution\n"
94 <<
"Name found was " << inName
95 <<
"\nistream is left in the badbit state\n";
98 if (possibleKeywordInput(is,
"Uvec", defaultMean)) {
99 std::vector<unsigned long> t(2);
100 is >> defaultMean >> t[0] >> t[1]; defaultMean = DoubConv::longs2double(t);
ThreeVector shoot(const G4int Ap, const G4int Af)
static int engine(pchar, pchar, double &, pchar &, const dic_type &)
const char * name(G4int ptype)