9 template <
class FLAT,
class REAL>
11 typedef REAL(*math_func)(REAL);
15 rgauss(FLAT& a_flat,REAL a_mean = 0,REAL a_std_dev = 1)
26 REAL
shoot(math_func a_sqrt,math_func a_log)
const {
29 v1 = REAL(2) *
m_flat.shoot() - REAL(1);
30 v2 = REAL(2) *
m_flat.shoot() - REAL(1);
33 fac = a_sqrt(-REAL(2)*a_log(r)/r);
45 template <
class FLAT,
class REAL>
58 REAL
shoot(
const REAL& a_half_pi,REAL(*a_tan)(REAL))
const {
59 REAL rval = REAL(2) *
m_flat.shoot() - REAL(1);
60 REAL displ = (REAL(1)/REAL(2)) *
m_gamma * a_tan(rval * a_half_pi);
71 template <
class FLAT,
class REAL>
73 typedef REAL(*math_func)(REAL);
81 REAL
shoot(math_func a_log)
const {
95 template <
class FLAT,
class REAL>
104 void shoot(REAL& a_x,REAL& a_y)
const {
108 u = REAL(2) *
m_flat.shoot()-REAL(1);
109 v = REAL(2) *
m_flat.shoot()-REAL(1);
112 while ( (s > REAL(1)) || (s==REAL(0)) );
113 a_x = (u * u - v * v) / s;
114 a_y = REAL(2) * u * v / s;
122 template <
class FLAT,
class REAL>
131 void shoot(REAL& a_x,REAL& a_y,REAL& a_z,REAL(*a_sqrt)(REAL))
const {
135 a_x = REAL(2) *
m_flat.shoot() - REAL(1);
136 a_y = REAL(2) *
m_flat.shoot() - REAL(1);
137 s = (a_x) * (a_x) + (a_y) * (a_y);
140 a_z = REAL(2) * s - REAL(1);
141 REAL a = REAL(2) * a_sqrt(REAL(1) - s);
153 template <
class FLAT,
class REAL,
class UINT>
165 UINT
shoot(
const REAL& a_two_pi,REAL(*a_sqrt)(REAL),REAL(*a_log)(REAL),REAL(*a_exp)(REAL),REAL(*a_cos)(REAL))
const {
168 REAL position =
m_flat.shoot();
169 REAL poissonValue = a_exp(-
m_mean);
170 REAL poissonSum = poissonValue;
171 while(poissonSum <= position) {
173 poissonValue *=
m_mean/REAL(number);
174 poissonSum += poissonValue;
179 REAL t = a_sqrt(-REAL(2)*a_log(
m_flat.shoot()));
180 REAL y = a_two_pi*
m_flat.shoot();
183 if(
value <= REAL(0))
return UINT(0);
184 static const REAL limit = REAL(2e9);
185 if(
value >= limit)
return UINT(limit);
195 template <
class FLAT,
class REAL,
class UINT>
221 if((
m_p<REAL(0))||(REAL(1)<
m_p))
return 0;
223 for(UINT i=0;i<
m_n;i++) {