47 #include "RandGauss.h"
49 RandGauss::~RandGauss() {
50 if ( deleteEngine )
delete localEngine;
53 HepDouble RandGauss::operator()() {
57 HepDouble RandGauss::shoot()
68 HepDouble v1,v2,fac,val;
71 v1 = 2.0 * HepRandom::getTheGenerator()->flat() - 1.0;
72 v2 = 2.0 * HepRandom::getTheGenerator()->flat() - 1.0;
76 fac = ::sqrt(-2.0*::log(r)/r);
83 void RandGauss::shootArray(
const HepInt size, HepDouble* vect,
84 HepDouble mean, HepDouble stdDev )
88 for (i=0; i<size; ++i)
89 vect[i] = shoot(mean,stdDev);
93 #ifndef ST_NO_TEMPLATE_DEF_ARGS
94 RandGauss::shootArray( vector<HepDouble>& vec,
95 HepDouble mean, HepDouble stdDev )
97 RandGauss::shootArray( vector<HepDouble,allocator<HepDouble> >& vec,
98 HepDouble mean, HepDouble stdDev )
101 for (
unsigned int i=0; i<vec.size(); ++i)
102 vec[i] = shoot(mean,stdDev);
116 HepDouble v1,v2,fac,val;
119 v1 = 2.0 * anEngine->flat() - 1.0;
120 v2 = 2.0 * anEngine->flat() - 1.0;
124 fac = ::sqrt( -2.0*::log(r)/r);
132 const HepInt size, HepDouble* vect,
133 HepDouble mean, HepDouble stdDev )
137 for (i=0; i<size; ++i)
138 vect[i] = shoot(anEngine,mean,stdDev);
142 #ifndef ST_NO_TEMPLATE_DEF_ARGS
144 vector<HepDouble>& vec,
145 HepDouble mean, HepDouble stdDev )
148 vector<HepDouble,allocator<HepDouble> >& vec,
149 HepDouble mean, HepDouble stdDev )
152 for (
unsigned int i=0; i<vec.size(); ++i)
153 vec[i] = shoot(anEngine,mean,stdDev);
157 HepDouble RandGauss::fire()
168 HepDouble v1,v2,fac,val;
171 v1 = 2.0 * localEngine->flat() - 1.0;
172 v2 = 2.0 * localEngine->flat() - 1.0;
176 fac = ::sqrt(-2.0*::log(r)/r);
183 void RandGauss::fireArray(
const HepInt size, HepDouble* vect,
184 HepDouble mean, HepDouble stdDev )
188 for (i=0; i<size; ++i)
189 vect[i] = fire(mean,stdDev);
193 #ifndef ST_NO_TEMPLATE_DEF_ARGS
194 RandGauss::fireArray( vector<HepDouble>& vec,
195 HepDouble mean, HepDouble stdDev )
197 RandGauss::fireArray( vector<HepDouble,allocator<HepDouble> >& vec,
198 HepDouble mean, HepDouble stdDev )
201 for (
unsigned int i=0; i<vec.size(); ++i)
202 vec[i] = fire(mean,stdDev);