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

@@ -13,18 +13,18 @@ generator.
// The state can be seeded with any (upto) 64 bit integer value.
void* splitmix64_init(uint64 seed){
void* splitmix64_init(u64 seed){
splitmix64_state* state=malloc(sizeof(splitmix64_state));
*state=seed;
return state;
}
uint64 splitmix64_next(void* _state) {
u64 splitmix64_next(void* _state) {
splitmix64_state* state=_state;
// increment the state variable
*state += 0x9e3779b97f4a7c15;
// copy the state to a working variable
uint64 z = *state;
u64 z = *state;
// xor the variable with the variable right bit shifted 30 then multiply by a constant
z = (z ^ (z>>30)) * 0xbf58476d1ce4e5b9;
// xor the variable with the variable right bit shifted 27 then multiply by a constant

View File

@@ -6,13 +6,13 @@ extern "C" {
#include "../../base/base.h"
typedef uint64 splitmix64_state;
typedef u64 splitmix64_state;
typedef void* splitmix64_statePtr;
splitmix64_statePtr splitmix64_init(uint64 seed);
splitmix64_statePtr splitmix64_init(u64 seed);
static inline splitmix64_statePtr splitmix64_initFromTime(void) { return splitmix64_init(time(NULL)); }
uint64 splitmix64_next(splitmix64_statePtr);
u64 splitmix64_next(splitmix64_statePtr);
static inline void splitmix64_free(splitmix64_statePtr state) {
free(state);
}