38 #ifndef _MMC_RNG_COMMON_H 39 #define _MMC_RNG_COMMON_H 41 #define TWO_PI (M_PI*2.0) 47 return -logf(rand_uniform01(t) + EPS);
51 return rand_uniform01(t);
55 return rand_uniform01(t);
59 return rand_uniform01(t);
63 return rand_uniform01(t);
65 #ifdef MMC_USE_SSE_MATH 70 inlinefun
void rand_next_aangle_sincos(RandType t[RAND_BUF_LEN],
float* si,
float* co) {
71 static __thread V4SF sine[MATH_BLOCK], cosine[MATH_BLOCK];
72 static __thread
int pos = (MATH_BLOCK << 2);
74 if (pos >= (MATH_BLOCK << 2)) {
78 for (i = 0; i < MATH_BLOCK; i++)
79 for (j = 0; j < 4; j++) {
80 ran[i].f[j] = TWO_PI * rand_uniform01(t);
83 for (i = 0; i < MATH_BLOCK; i++) {
84 sincos_ps(ran[i].v, &(sine[i].v), &(cosine[i].v));
91 *co = cosine[0].f[pos++];
95 inlinefun
float rand_next_scatlen_ps(RandType t[RAND_BUF_LEN]) {
96 static __thread V4SF logval[MATH_BLOCK];
97 static __thread
int pos = (MATH_BLOCK << 2);
100 if (pos >= (MATH_BLOCK << 2)) {
101 V4SF ran[MATH_BLOCK];
104 for (i = 0; i < MATH_BLOCK; i++)
105 for (j = 0; j < 4; j++) {
106 ran[i].f[j] = rand_uniform01(t);
109 for (i = 0; i < MATH_BLOCK; i++) {
110 logval[i].v = log_ps(ran[i].v);
116 res = ((logval[0].f[pos] != logval[0].f[pos]) ? LOG_RNG_MAX : (-logval[0].f[pos]));
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_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_reflect(RandType t[RAND_BUF_LEN])
generate random number for reflection test
Definition: mmc_rand_common.h:58
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