su2hmc
|
Random number generator related routines. More...
#include "coord.h"
#include "errorcodes.h"
#include "par_mpi.h"
#include "random.h"
#include "sizes.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
Go to the source code of this file.
Macros | |
#define | M_PI acos(-1) |
\(\pi\) if not defined elsewhere | |
Functions | |
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 comment it check there if you are confused about things. | |
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 range seed to 9*seed c having a range of 0*seed gave an unfortunate pattern c in the underlying value of ds(1) (it was always 10 times bigger c on the last processor). This does not appear to happen with 9. | |
double | Par_granf () |
Generates a random double which is then sent to the other ranks. | |
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-Muller Method. | |
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-Muller Method. | |
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 Method. | |
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 Method. | |
double | ran2 (long *idum) |
Generates uniformly distributed random double between zero and one as described in numerical recipes. It's also thread-safe for different seeds. | |
Variables | |
long | seed |
RAN2 seed. | |
Random number generator related routines.
Definition in file random.c.
Generates a vector of normally distributed random single precision complex numbers using the Box-Muller Method.
ps | The output array |
n | The array length |
mu | mean |
sigma | variance |
Definition at line 260 of file random.c.
References M_PI, ran2(), and seed.
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 Method.
ps | The output array |
n | The array length |
mu | mean |
sigma | variance |
Definition at line 306 of file random.c.
References M_PI, ran2(), and seed.
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 Method.
ps | The output array |
n | The array length |
mu | mean |
sigma | variance |
Definition at line 369 of file random.c.
References M_PI, ran2(), and seed.
Generates a vector of normally distributed random double precision complex numbers using the Box-Muller Method.
ps | The output array |
n | The array length |
mu | mean |
sigma | variance |
Definition at line 214 of file random.c.
References M_PI, ran2(), and seed.
double Par_granf | ( | ) |
Generates a random double which is then sent to the other ranks.
Definition at line 190 of file random.c.
References Par_dcopy(), ran2(), rank, and seed.
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 comment it check there if you are confused about things.
filename | The name of the file we're reading from |
ranval | The destination for the file's contents |
Definition at line 88 of file random.c.
References Par_dcopy(), and rank.
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 range seed to 9*seed c having a range of 0*seed gave an unfortunate pattern c in the underlying value of ds(1) (it was always 10 times bigger c on the last processor). This does not appear to happen with 9.
seed | The seed from the rank in question. |
iread | Do we read from file or not. Don't remember why it's here as it's not used |
Definition at line 135 of file random.c.
References rank, ranset(), seed, and size.
double ran2 | ( | long * | idum | ) |
Generates uniformly distributed random double between zero and one as described in numerical recipes. It's also thread-safe for different seeds.
idum | Pointer to the seed |
Definition at line 440 of file random.c.
|
inline |
Dummy seed the ran2 generator.
seed | pointer to seed |
Definition at line 74 of file random.c.
References seed.