Skip to content
cet-tPublic

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

splitmix

Minimal, dependency-free implementations of SplitMix32 and SplitMix64 in Rust.

no_std compatible, with no allocation or external dependencies.

Features

  • SplitMix32 (u32) and SplitMix64 (u64)
  • Simple new() and next() API
  • No external dependencies
  • no_std compatible
  • No allocation

Usage

use splitmix::{SplitMix32, SplitMix64};

let mut sm32 = SplitMix32::new(42);
let mut sm64 = SplitMix64::new(42);

let a: u32 = sm32.next();
let b: u64 = sm64.next();

Seed Generation

SplitMix is particularly useful for expanding a single seed into multiple values for initializing other pseudorandom number generators.

use splitmix::SplitMix64;

let mut sm = SplitMix64::new(42);

let state = [
    sm.next(),
    sm.next(),
    sm.next(),
    sm.next(),
];

Notes

  • All seeds are valid, including zero.
  • The same seed produces the same sequence.
  • SplitMix is not cryptographically secure.
  • SplitMix32 and SplitMix64 have only 32-bit and 64-bit internal states, respectively. They are primarily intended for seed initialization rather than applications requiring large state spaces or cryptographic security.

Releases

Packages

Contributors

Languages