fix accent (TODO: fix gitweb...)
[ppam-mpi.git] / code / src / Util / rng.h
1 #ifndef PPAM_RNG_H
2 #define PPAM_RNG_H
3
4 #include <stdint.h>
5 #include "Util/types.h"
6
7 #define INV_RANDMAX 2.3283064370807974E-10 // 1/0xffffffff
8
9 // If (flag!=0), then use a random array to initialize mm[]
10 #define mix(a,b,c,d,e,f,g,h) \
11 { \
12 a^=b<<11; d+=a; b+=c; \
13 b^=c>>2; e+=b; c+=d; \
14 c^=d<<8; f+=c; d+=e; \
15 d^=e>>16; g+=d; e+=f; \
16 e^=f<<10; h+=e; f+=g; \
17 f^=g>>4; a+=f; g+=h; \
18 g^=h<<8; b+=g; h+=a; \
19 h^=a>>9; c+=h; a+=b; \
20 }
21
22 // initialize the (pseudo-)random generator
23 // NOTE: flag has only two states, active or not.
24 // flag != 0 --> "maximal randomness"
25 void init_rng(int flag);
26
27 // return a (pseudo-)random integer
28 uint32_t get_rand_int();
29
30 // return a (pseudo-)random real number in [0,1]
31 Real get_rand_real();
32
33 #endif