From 50793e214c05ff77636addb319ccf0de864713e4 Mon Sep 17 00:00:00 2001 From: sanine Date: Fri, 24 Oct 2025 12:07:38 -0500 Subject: implement xorshift --- lichen.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lichen.h') diff --git a/lichen.h b/lichen.h index e69de29..fe68d52 100644 --- a/lichen.h +++ b/lichen.h @@ -0,0 +1,24 @@ +#ifndef LICHEN_H +#define LICHEN_H + +#include + +// random number generation +typedef struct li_rand32_t { + uint32_t (*rand)(void *); + void *state; +} li_rand32_t; + + +struct li_xorshift32_t { + li_rand32_t generator; + uint64_t state; +}; + +// initialize an xorshift32 struct with a specific seed +void li_xorshift32_seed(struct li_xorshift32_t *xor, uint32_t seed); +// get a pseudo-random number via the xorshift algorithm +uint32_t li_xorshift32(void *s); + + +#endif -- cgit v1.2.1