diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2015-02-13 16:18:10 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2015-05-02 21:36:45 +0200 |
commit | b9d887fc3cd3ae26c678bf35bc90c4f1d6b03888 (patch) | |
tree | ccbe25664282dd7915c55e73e25772b8801e9088 /random.h | |
parent | a46f55e0a2c9362b7b549ead851043c7b9e2791d (diff) | |
download | pucket-b9d887fc3cd3ae26c678bf35bc90c4f1d6b03888.tar.gz pucket-b9d887fc3cd3ae26c678bf35bc90c4f1d6b03888.tar.bz2 pucket-b9d887fc3cd3ae26c678bf35bc90c4f1d6b03888.zip |
Unify prng use
Finally drop all isaac references, do not use system rng any more. Drop
rng state from flam3_frame – it was not used anyway.
Diffstat (limited to 'random.h')
-rw-r--r-- | random.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/random.h b/random.h new file mode 100644 index 0000000..4e0b8c9 --- /dev/null +++ b/random.h @@ -0,0 +1,20 @@ +#pragma once + +#include <stdint.h> + +#define XORSHIFT_S 16 + +typedef struct { + uint64_t s[XORSHIFT_S]; + int p; +} randctx; + +void rand_seed (randctx * const st); +uint64_t rand_u64 (randctx * const st); +double rand_d01 (randctx * const st); +double rand_d11 (randctx * const st); +int rand_bool (randctx * const st); + +#define rand_distrib(st,v) ((v)[rand_u64(st)%vlen(v)]) +#define rand_mod(st,max) (rand_u64(st)%(max)) + |