mmc_rand_xorshift128p.h
Go to the documentation of this file.
1 /***************************************************************************/
32 /***************************************************************************/
38 #ifndef _MCEXTREME_SFMT_RAND_H
39 #define _MCEXTREME_SFMT_RAND_H
40 
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <math.h>
44 
45 #ifndef inlinefun
46  #define inlinefun static inline
47 #endif
48 
49 typedef unsigned long long RandType;
50 typedef unsigned int uint;
51 
52 #if defined(_WIN32) || defined(__APPLE__)
53  typedef unsigned long long ulong;
54 #endif
55 
56 #define MCX_RNG_NAME "xorshift128+ RNG"
57 #define RAND_BUF_LEN 2 //register arrays
58 #define RAND_SEED_WORD_LEN 4 //48 bit packed with 64bit length
59 
60 inlinefun void rng_init(RandType t[RAND_BUF_LEN], RandType tnew[RAND_BUF_LEN], uint* n_seed, int idx);
61 
62 inlinefun void rand_need_more(RandType t[RAND_BUF_LEN], RandType tbuf[RAND_BUF_LEN]);
63 // generate [0,1] random number for the next scattering length
64 inlinefun float rand_next_scatlen(RandType t[RAND_BUF_LEN]);
65 // generate [0,1] random number for the next arimuthal angle
66 inlinefun float rand_next_aangle(RandType t[RAND_BUF_LEN]);
67 // generate random number for the next zenith angle
68 inlinefun float rand_next_zangle(RandType t[RAND_BUF_LEN]);
69 inlinefun float rand_next_reflect(RandType t[RAND_BUF_LEN]);
70 inlinefun float rand_do_roulette(RandType t[RAND_BUF_LEN]);
71 
72 #ifdef MMC_USE_SSE_MATH
73  inlinefun void rand_next_aangle_sincos(RandType t[RAND_BUF_LEN], float* si, float* co);
74  inlinefun float rand_next_scatlen_ps(RandType t[RAND_BUF_LEN]);
75 #endif
76 
77 #endif
inlinefun float rand_next_reflect(RandType t[RAND_BUF_LEN])
generate random number for reflection test
Definition: mmc_rand_common.h:58
inlinefun float rand_do_roulette(RandType t[RAND_BUF_LEN])
generate random number for the next zenith angle
Definition: mmc_rand_common.h:62
inlinefun float rand_next_scatlen(RandType t[RAND_BUF_LEN])
generate [0,1] random number for the next scattering length
Definition: mmc_rand_common.h:46
inlinefun float rand_next_zangle(RandType t[RAND_BUF_LEN])
generate random number for the next zenith angle
Definition: mmc_rand_common.h:54
inlinefun float rand_next_aangle(RandType t[RAND_BUF_LEN])
generate [0,1] random number for the next arimuthal angle
Definition: mmc_rand_common.h:50