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