1 /* Written in 2018 by David Blackman and Sebastiano Vigna (vigna@acm.org)
3 To the extent possible under law, the author has dedicated all copyright
4 and related and neighboring rights to this software to the public domain
5 worldwide. This software is distributed without any warranty.
7 See <http://creativecommons.org/publicdomain/zero/1.0/>. */
12 /* This is xoshiro256** 1.0, one of our all-purpose, rock-solid
13 generators. It has excellent (sub-ns) speed, a state (256 bits) that is
14 large enough for any parallel application, and it passes all tests we
17 For generating just floating-point numbers, xoshiro256+ is even faster.
19 The state must be seeded so that it is not everywhere zero. If you have
20 a 64-bit seed, we suggest to seed a splitmix64 generator and use its
23 static inline uint64_t rotl(const uint64_t x, int k) {
24 return (x << k) | (x >> (64 - k));
27 uint64_t xoshiro(uint64_t s[4]) {
28 const uint64_t result = rotl(s[1] * 5, 7) * 9;
30 const uint64_t t = s[1] << 17;
39 s[3] = rotl(s[3], 45);