This commit is contained in:
2023-02-11 12:19:05 +06:00
parent 609dfcf3ed
commit 305854e721
77 changed files with 565 additions and 562 deletions

View File

@@ -10,8 +10,8 @@ See <http://creativecommons.org/publicdomain/zero/1.0/>. */
/*
This is xoroshiro64* 1.0, our best and fastest 32-bit small-state
generator for 32-bit floating-point numbers. We suggest to use its
upper bits for floating-point generation, as it is slightly faster than
generator for 32-bit floating-poi32 numbers. We suggest to use its
upper bits for floating-poi32 generation, as it is slightly faster than
xoroshiro64**. It passes all tests we are aware of except for linearity
tests, as the lowest six bits have low linear complexity, so if low
linear complexity is not considered an issue (as it is usually the
@@ -23,15 +23,15 @@ right shifts to extract subsets of bits.
The state must be seeded so that it is not everywhere zero.
*/
static inline uint32 rotl(const uint32 x, int k) {
static inline u32 rotl(const u32 x, i32 k) {
return (x << k) | (x >> (32 - k));
}
uint32 xoroshiro64star_next(void* _state) {
u32 xoroshiro64star_next(void* _state) {
xoroshiro64_state* state=_state;
const uint32 s0 = state->s[0];
uint32 s1 = state->s[1];
const uint32 result = s0 * 0x9E3779BB;
const u32 s0 = state->s[0];
u32 s1 = state->s[1];
const u32 result = s0 * 0x9E3779BB;
s1 ^= s0;
state->s[0] = rotl(s0, 26) ^ s1 ^ (s1 << 9); // a, b
@@ -40,7 +40,7 @@ uint32 xoroshiro64star_next(void* _state) {
return result;
}
void* xoroshiro64_init(uint64 seed){
void* xoroshiro64_init(u64 seed){
xoroshiro64_state* state=malloc(sizeof(xoroshiro64_state));
splitmix64_state* splitmix=splitmix64_init(seed);
state->merged=splitmix64_next(splitmix);