1 |
/* RCSid $Id: pmaprand.h,v 2.4 2015/08/18 18:45:55 greg Exp $ */ |
2 |
|
3 |
/* |
4 |
================================================================== |
5 |
Random number generators for photon distribution |
6 |
|
7 |
Roland Schregle (roland.schregle@{hslu.ch, gmail.com}) |
8 |
(c) Fraunhofer Institute for Solar Energy Systems, |
9 |
(c) Lucerne University of Applied Sciences and Arts, |
10 |
supported by the Swiss National Science Foundation (SNSF, #147053) |
11 |
================================================================== |
12 |
|
13 |
$Id: pmaprand.h,v 2.3 2015/05/08 13:20:23 rschregle Exp $ |
14 |
*/ |
15 |
|
16 |
|
17 |
|
18 |
#ifndef PMAPRAND_H |
19 |
#define PMAPRAND_H |
20 |
|
21 |
/* According to the analytical validation, skipping numbers in the sequence |
22 |
introduces bias in scenes with high reflectance. We therefore use |
23 |
erand48() with separate states for photon emission, scattering, and |
24 |
russian roulette. The pmapSeed() and pmapRandom() macros can be |
25 |
adapted to other (better?) RNGs. */ |
26 |
|
27 |
#if defined(_WIN32) || defined(BSD) |
28 |
/* Assume no erand48(), so use standard RNG without explicit multistate |
29 |
control; the resulting sequences will be suboptimal */ |
30 |
#include "random.h" |
31 |
|
32 |
#define pmapSeed(seed, state) (srandom(seed)) |
33 |
#define pmapRandom(state) (frandom()) |
34 |
#else |
35 |
#define pmapSeed(seed, state) (state [0] += seed, state [1] += seed, \ |
36 |
state [2] += seed) |
37 |
#define pmapRandom(state) erand48(state) |
38 |
#endif |
39 |
|
40 |
|
41 |
extern unsigned short partState [3], emitState [3], cntState [3], |
42 |
mediumState [3], scatterState [3], rouletteState [3], |
43 |
randSeed; |
44 |
#endif |
45 |
|