Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //The following RNG is based on code for the xorshift* RNG by Sebastiano Vigna
- //Parameters are chosen from the original paper such to
- typedef struct
- {
- uint64_t w, x;
- } XorShift128rm_state;
- const uint64_t p1 = 0x243f6a8885a308d3;
- const uint64_t p2 = 0x13198a2e03707345;
- static uint64_t rotl(uint64_t x, uint8_t r)
- {
- return (x << r) | (x >> (64-r));
- }
- uint64_t XorShift128rm(XorShift128rm_state *s)
- {
- uint64_t t = s->w;
- s->w = s->x;
- s->x = t;
- s->x ^= s->x << 16;
- s->x ^= (s->x >> 21) ^ s->w ^ (s->w >> 1);
- return rotl(s->x*p1, 16)*p2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement