code wiki / (root) / xoshiro.nx

xoshiro.nx

buildroot/runtime/xoshiro.nx

3597 B106 linesdepth 4pulls 4 transitivereach 1 importersview sourcekind tool
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

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main xoshiro_new xoshiro_seed xs_splitmix xoshiro_next xs_rotl nx_bits_rotl64 xoshiro_bounded xoshiro_next ↻

structs

25struct Xoshiro {

consts

none

functions

35func xs_rotl(x: i64, k: i64) -> i64 {
called by 1: xoshiro_next calls 1: nx_bits_rotl64
42func xs_splitmix(state_p: *i64) -> i64 {
called by 1: xoshiro_seed
51func xoshiro_seed(rng: *Xoshiro, seed: i64) -> i64 {
called by 1: xoshiro_new calls 1: xs_splitmix
63func xoshiro_new(seed: i64) -> *Xoshiro {
called by 2: mainmain calls 1: xoshiro_seed
72func xoshiro_next(rng: *Xoshiro) -> i64 {
called by 2: xoshiro_boundedmain calls 1: xs_rotl
86func xoshiro_bounded(rng: *Xoshiro, bound: i64) -> i64 {
97func main() -> i64 {