50#include "owl/common/math/vec.h"
56 template<
unsigned int N=4>
63 inline __both__
LCG(
unsigned int val0,
unsigned int val1)
66 inline __both__
LCG(
const vec2i &seed)
67 { init((
unsigned)seed.x,(
unsigned)seed.y); }
68 inline __both__
LCG(
const vec2ui &seed)
69 { init(seed.x,seed.y); }
71 inline __both__
void init(
unsigned int val0,
unsigned int val1)
73 unsigned int v0 = val0;
74 unsigned int v1 = val1;
77 for (
unsigned int n = 0; n < N; n++) {
79 v0 += ((v1<<4)+0xa341316c)^(v1+s0)^((v1>>5)+0xc8013ea4);
80 v1 += ((v0<<4)+0xad90777d)^(v0+s0)^((v0>>5)+0x7e95761e);
89 const uint32_t LCG_A = 1664525u;
90 const uint32_t LCG_C = 1013904223u;
91 state = (LCG_A * state + LCG_C);
92 return (state & 0x00FFFFFF) / (float) 0x01000000;
106 inline __both__
void init(
int seed = 0)
109 for (
int warmUp=0;warmUp<10;warmUp++)
116 const uint64_t a = 0x5DEECE66DULL;
117 const uint64_t c = 0xBULL;
118 const uint64_t mask = 0xFFFFFFFFFFFFULL;
120 return float(state & mask) / float(mask+1ULL);
__both__ void init(int seed=0)
Definition: random.h:106
__both__ float operator()()
Definition: random.h:114
__both__ float operator()()
Definition: random.h:87