code wiki / (root) / xoshiro.nx

xoshiro.nx

buildroot/runtime/xoshiro.nx

3597 B106 linesdepth 4pulls 4 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

xoshiro.nx -- xoshiro256++ pseudorandom number generator. David Blackman + Sebastiano Vigna 2018. 256-bit state, 64-bit output per step, period 2^256 - 1. Passes BigCrush statistical tests. Used by: Rust `rand` standard generator, Lua 5.4, GNU FORTRAN, .NET 6+. NOT cryptographically secure -- an attacker who observes enough output can reconstruct state. For crypto use rand.nx (/dev/urandom) or HMAC-DRBG (pending). Used for: simulation, deterministic test data, sampling, fuzzing. When you need REPRODUCIBLE pseudorandom from a seed. Invariants: X1 64-bit output per step; full state advances. X2 Same seed -> same output sequence forever. X3 All-zeros state forbidden (would produce all zeros). seed_with implements the SplitMix64 trick to safely initialise from any 64-bit seed including 0.

dependencies 2 imports · 1 importers

syscalls.nx nx_bits.nx xoshiro.nx proptest.nx

imports: syscalls.nxnx_bits.nx

imported by: proptest.nx

structs

25struct Xoshiro {

consts

none

functions

35func xs_rotl(x: i64, k: i64) -> i64 {
42func xs_splitmix(state_p: *i64) -> i64 {
51func xoshiro_seed(rng: *Xoshiro, seed: i64) -> i64 {
63func xoshiro_new(seed: i64) -> *Xoshiro {
72func xoshiro_next(rng: *Xoshiro) -> i64 {
86func xoshiro_bounded(rng: *Xoshiro, bound: i64) -> i64 {
97func main() -> i64 {