25#if (defined USE_RAN2||(!defined __INTEL_MKL__&&!defined __RANLUX__))
28#elif defined __RANLUX__
33#elif defined __INTEL_MKL__
37VSLStreamStatePtr stream;
55#elif (defined __INTEL_MKL__&&!defined USE_RAN2)
78 ranlux_instd=gsl_rng_alloc(gsl_rng_ranlxd2);
79 gsl_rng_set(ranlux_instd,*
seed);
81#elif (defined __INTEL_MKL__&& !defined USE_RAN2)
82 vslNewStream( &stream, VSL_BRNG_MT19937, *
seed );
99 const char *funcname =
"Par_psread";
102 if(!(dest = fopen(filename,
"rb"))){
103 fprintf(stderr,
"Error %i in %s: Failed to open %s.\nExiting...\n\n", OPENERROR, funcname, filename);
105 MPI_Abort(comm,OPENERROR);
111 fread(&ranval,
sizeof(ranval), 1, dest);
119#if (defined USE_RAN2||(!defined __INTEL_MKL__&&!defined __RANLUX__))
136#elif defined __RANLUX__
153#elif (defined __INTEL_MKL__||defined __RANLUX__)
172 const char *funcname =
"Par_ranset";
175 printf(
"Master seed: %i\t",*
seed);
180 printf(
"Rank: %i\tSeed %i\n",
rank, *
seed);
184#if (defined __INTEL_MKL__||defined __RANLUX__)
198 const char *funcname =
"Par_granf";
201#if (defined USE_RAN2||(!defined __INTEL_MKL__&&!defined __RANLUX__))
203#elif defined __RANLUX__
204 ran_val = gsl_rng_uniform(ranlux_instd);
206 vdRngUniform(VSL_RNG_METHOD_UNIFORM_STD_ACCURATE, stream, 1, &ran_val, 0,1);
227 const char *funcname =
"Gauss_z";
229 fprintf(stderr,
"Error %i in %s: Array cannot have length %i.\nExiting...\n\n",
230 ARRAYLEN, funcname, n);
232 MPI_Abort(comm,ARRAYLEN);
238 for(
int i=0;i<n;i++){
250 double r =sigma*sqrt(-2*log(gsl_rng_uniform(ranlux_instd)));
251 double theta=2.0*
M_PI*gsl_rng_uniform(ranlux_instd);
253 double r =sigma*sqrt(-2*log(
ran2(&
seed)));
256 ps[i]=r*(cos(theta)+sin(theta)*I)+mu;
273 const char *funcname =
"Gauss_z";
275 fprintf(stderr,
"Error %i in %s: Array cannot have length %i.\nExiting...\n\n",
276 ARRAYLEN, funcname, n);
278 MPI_Abort(comm,ARRAYLEN);
284 for(
int i=0;i<n;i++){
296 float r =sigma*sqrt(-2*log(gsl_rng_uniform(ranlux_instd)));
297 float theta=2.0*
M_PI*gsl_rng_uniform(ranlux_instd);
299 float r =sigma*sqrt(-2*log(
ran2(&
seed)));
302 ps[i]=r*(cos(theta)+mu+sin(theta)*I)+mu;
306int Gauss_d(
double *ps,
unsigned int n,
const double mu,
const double sigma){
319 const char *funcname =
"Gauss_z";
324 fprintf(stderr,
"Error %i in %s: Array cannot have length %i.\nExiting...\n\n",
325 ARRAYLEN, funcname, n);
327 MPI_Abort(comm,ARRAYLEN);
338 r=2.0*
M_PI*gsl_rng_uniform(ranlux_instd);
339 ps[n]=sqrt(-2*log(gsl_rng_uniform(ranlux_instd)))*cos(r);
342 ps[n]=sqrt(-2*log(
ran2(&
seed)))*cos(r);
358 u=sqrt(-2*log(gsl_rng_uniform(ranlux_instd)))*sigma;
359 r=2.0*
M_PI*gsl_rng_uniform(ranlux_instd);
369int Gauss_f(
float *ps,
unsigned int n,
const float mu,
const float sigma){
382 const char *funcname =
"Gauss_z";
387 fprintf(stderr,
"Error %i in %s: Array cannot have length %i.\nExiting...\n\n",
388 ARRAYLEN, funcname, n);
390 MPI_Abort(comm,ARRAYLEN);
401 r=2.0*
M_PI*gsl_rng_uniform(ranlux_instd);
402 ps[n]=sqrt(-2*log(gsl_rng_uniform(ranlux_instd)))*cos(r);
405 ps[n]=sqrt(-2*log(
ran2(&
seed)))*cos(r);
409 r=2.0*
M_PI*gsl_rng_uniform(ranlux_instd);
410 ps[n]=sqrt(-2*log(gsl_rng_uniform(ranlux_instd)))*cos(r);
413 ps[n]=sqrt(-2*log(
ran2(&
seed)))*cos(r);
428 u=sqrt(-2*log(gsl_rng_uniform(ranlux_instd)))*sigma;
429 r=2.0*
M_PI*gsl_rng_uniform(ranlux_instd);
452 static long idum2=123456789;
454 static long iv[NTAB];
456#pragma omp threadprivate(idum2, iy, iv)
461 if (-(*idum) < 1) *idum=1;
462 else *idum = -(*idum);
466 for(j=NTAB+7;j>=0;j--) {
468 *idum=IA1*(*idum-k*IQ1)-k*IR1;
469 if (*idum < 0) *idum += IM1;
477 *idum=IA1*(*idum-k*IQ1)-k*IR1;
478 if (*idum < 0) *idum += IM1;
480 idum2=IA2*(idum2-k*IQ2)-k*IR2;
482 if (idum2 < 0) idum2 += IM2; j=iy/NDIV;
485 if (iy < 1) iy += IMM1;
486 if ((temp=AM*iy) > RNMX)
Header for routines related to lattice sites.
This header is intended to be a useful reference for error codes and their meanings.
int size
The number of MPI ranks in total.
int Par_dcopy(double *dval)
Broadcasts a double to the other processes.
int Gauss_f(float *ps, unsigned int n, const float mu, const float sigma)
Generates a vector of normally distributed random single precision numbers using the Box-Muller Metho...
int ranset(long *seed)
Dummy seed the ran2 generator.
int Par_ranread(char *filename, double *ranval)
Reads ps from a file Since this function is very similar to Par_sread, I'm not really going to commen...
int Gauss_z(Complex *ps, unsigned int n, const Complex mu, const double sigma)
Generates a vector of normally distributed random double precision complex numbers using the Box-Mull...
int Gauss_c(Complex_f *ps, unsigned int n, const Complex_f mu, const float sigma)
Generates a vector of normally distributed random single precision complex numbers using the Box-Mull...
int Gauss_d(double *ps, unsigned int n, const double mu, const double sigma)
Generates a vector of normally distributed random double precision numbers using the Box-Muller Metho...
int Par_ranset(long *seed, int iread)
Uses the rank to get a new seed. Copying from the FORTRAN description here c create new seeds in rang...
#define M_PI
if not defined elsewhere
double Par_granf()
Generates a random double which is then sent to the other ranks.
double ran2(long *idum)
Generates uniformly distributed random double between zero and one as described in numerical recipes....
Header for random number configuration.
Defines the constants of the code and other parameters for loop dimensions. Each subroutine includes ...
#define Complex
Double precision complex number.
#define Complex_f
Single precision complex number.