11 vslNewStream(&
rdata->r, RANDOM_MKL_RNG, seed);
16 vdRngUniform(VSL_RNG_METHOD_UNIFORM_STD,
rdata->r, 1, &r, 0.0, 1.0);
22 vdRngGaussian(VSL_RNG_METHOD_GAUSSIAN_BOXMULLER,
rdata->r, 1, &r, 0.0, 1.0);
27 vdRngUniform(VSL_RNG_METHOD_UNIFORM_STD,
rdata->r, n, r, 0.0, 1.0);
31 vdRngGaussian(VSL_RNG_METHOD_GAUSSIAN_BOXMULLER2,
rdata->r, n, r, 0.0, 1.0);
35#elif defined(RANDOM_GSL)
37#include <gsl/gsl_rng.h>
41 rdata->r = gsl_rng_alloc(gsl_rng_mt19937);
42 gsl_rng_set(
rdata->r, seed);
46 return gsl_rng_uniform(
rdata->r);
50 return gsl_ran_gaussian(
rdata->r, 1.0);
55 for(
int i = 0; i < n; i++) {
56 r[i] = gsl_rng_uniform(
rdata->r);
62 for(
int i = 0; i < n; i++) {
63 r[i] = gsl_ran_gaussian(
rdata->r, 1.0);
68#elif defined(RANDOM_LCG)
82 uint64_t a = 2862933555777941757;
83 uint64_t b = 3037000493;
90 random_lcg_uniform_simd(
rdata, 1, &r);
96 random_lcg_normal_simd(
rdata, 1, &r);
104 for(
int i = 0; i < n; i++) {
105 r[i] = (double) random_lcg_integer(
rdata) / UINT64_MAX;
111 int isEven = (n+1) % 2;
114#if A5_CCOL_USE_GEOBM == 1
116 GPU_PARALLEL_LOOP_ALL_LEVELS
117 for(
int i = 0; i < n; i=i+2) {
120 x1 = 2*random_lcg_uniform(
rdata)-1;
121 x2 = 2*random_lcg_uniform(
rdata)-1;
125 w = sqrt( (-2 * log( w ) ) / w );
127 if((i < n-2) || (isEven > 0)) {
134 GPU_PARALLEL_LOOP_ALL_LEVELS
135 for(
int i = 0; i < n; i=i+2) {
136 x1 = random_lcg_uniform(
rdata);
137 x2 = random_lcg_uniform(
rdata);
138 w = sqrt(-2*log(x1));
141 if((i < n-2) || (isEven > 0) ) {
143 r[i+1] = w*sqrt(1-s*s);
146 r[i+1] = -w*sqrt(1-s*s);
182 for(
int i = 0; i < n; i++) {
197 int isEven = (n+1) % 2;
200#if A5_CCOL_USE_GEOBM == 1
203 for(
int i = 0; i < n; i=i+2) {
211 w = sqrt( (-2 * log( w ) ) / w );
213 if((i < n-2) || (isEven > 0)) {
221 for(
int i = 0; i < n; i=i+2) {
224 w = sqrt(-2*log(x1));
227 if((i < n-2) || (isEven > 0) ) {
229 r[i+1] = w*sqrt(1-s*s);
232 r[i+1] = -w*sqrt(1-s*s);
Main header file for ASCOT5.
Header file containing physical and mathematical constants.
void random_drand48_uniform_simd(int n, double *r)
Vectorised sampling from uniform distribution.
double random_drand48_normal()
Initialize random generator which uses the linear congruential algorithm and 48-bit integer arithmeti...
void random_drand48_normal_simd(int n, double *r)
Vectorised sampling from normal distribution.
Header file for random.c.