diff options
| author | sanine <sanine.not@pm.me> | 2025-10-24 12:07:38 -0500 | 
|---|---|---|
| committer | sanine <sanine.not@pm.me> | 2025-10-24 12:07:38 -0500 | 
| commit | 50793e214c05ff77636addb319ccf0de864713e4 (patch) | |
| tree | 21e6642ded86528b54fc530f9a5ec337a5900dcb /lichen.h | |
| parent | 6547ddfe210f06ab584a6781a06b9c844b6eaf7c (diff) | |
implement xorshift
Diffstat (limited to 'lichen.h')
| -rw-r--r-- | lichen.h | 24 | 
1 files changed, 24 insertions, 0 deletions
| @@ -0,0 +1,24 @@ +#ifndef LICHEN_H +#define LICHEN_H + +#include <stdint.h> + +// 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 | 
