Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
rnorm.h File Reference

Go to the source code of this file.

Classes

class  GausState
 

Functions

double rnorm_improved (void)
 
void rnorm_double (double r1, double r2, double &x1, double &x2)
 
void rnorm_float (float r1, float r2, float &x1, float &x2)
 

Variables

GausState gaus_state
 

Function Documentation

◆ rnorm_double()

void rnorm_double ( double  r1,
double  r2,
double &  x1,
double &  x2 
)

Definition at line 36 of file rnorm.cpp.

36 {
37 double r = sqrt(-2.0 * log(r1));
38 double fi = 2.0 * M_PI * r2;
39 x1 = r * cos(fi);
40 x2 = r * sin(fi);
41}
DoubleAc cos(const DoubleAc &f)
Definition: DoubleAc.cpp:431
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:313
DoubleAc sin(const DoubleAc &f)
Definition: DoubleAc.cpp:383

◆ rnorm_float()

void rnorm_float ( float  r1,
float  r2,
float &  x1,
float &  x2 
)

Definition at line 43 of file rnorm.cpp.

43 {
44 float r = sqrt(-2.0 * log(r1));
45 float fi = 2.0 * M_PI * r2;
46 x1 = r * cos(fi);
47 x2 = r * sin(fi);
48}

◆ rnorm_improved()

double rnorm_improved ( void  )

Definition at line 15 of file rnorm.cpp.

15 {
19 } else {
20 double x1, x2, w, y1, y2;
21 do {
22 x1 = 2.0 * SRANLUX() - 1.0;
23 x2 = 2.0 * SRANLUX() - 1.0;
24 w = x1 * x1 + x2 * x2;
25 } while (w > 1.0);
26
27 w = sqrt(-2.0 * log(w) / w);
28 y1 = x1 * w;
29 y2 = x2 * w;
32 return y1;
33 }
34}
double second_ran
Definition: rnorm.h:9
int s_inited_second_ran
Definition: rnorm.h:10
ffloat SRANLUX(void)
Definition: ranluxint.h:262
GausState gaus_state
Definition: rnorm.cpp:13

Referenced by pois().

Variable Documentation

◆ gaus_state

GausState gaus_state
extern

Definition at line 13 of file rnorm.cpp.

Referenced by rnorm_improved().