Universal RNG
A collection of pseudo-random number generators (PRNGs) implemented in Rust.
This crate provides efficient implementations of various random number generation algorithms, supporting both Rust and C (via FFI).
Supported Generators
- Mersenne Twister:
mt19937::Mt19937(32-bit)mt1993764::Mt1993764(64-bit)
- PCG:
pcg32::Pcg32(Permuted Congruential Generator, PCG-XSH-RR)
- Philox (Counter-based RNGs):
philox32::Philox32(4x32)philox64::Philox64(2x64)
- Twisted GFSR:
twisted_gfsr::TwistedGFSR
- Xorshift:
xorshift32::Xorshift32xorshift64::Xorshift64xorshift128::Xorshift128
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Usage Examples
Basic Usage (Mersenne Twister)
use Mt19937;
Using Philox (Counter-based)
Philox generators produce blocks of random numbers and are suitable for parallel applications.
use Philox32;
C API
This crate exports C-compatible functions for all generators, allowing them to be used as a shared library.
Each generator exposes functions for:
- Creation (
_new) - Destruction (
_free) - Bulk generation (
_next_uXXs,_next_fXXs) - Range generation (
_rand_iXXs,_rand_fXXs)
Example signature for MT19937:
void* ;
void ;
void ;