[go: up one dir, main page]

randomize 2.2.0

A dead simple to use randomization library for rust.
Documentation
//! PCG related things.
//!
//! The basic form of PCG is the `Pick` flavor. There's also `Mem` and `Phantom`
//! versions which are the same general idea, but get the stream selection value
//! comes from some place other than being stored in the generator itself.
//!
//! Unlike the normal PCGs, where the output permutation is fixed as part of the
//! generator and so the generator name is based on the _output size_, these
//! PCGs offer more than one output permutation, so their names are based on
//! their _state size_.

use super::*;

pub mod mem;
pub use self::mem::*;

pub mod permutations;
pub use self::permutations::*;

pub mod phantom;
pub use self::phantom::*;

pub mod pick;
pub use self::pick::*;

// Default Constants

// Note(Lokathor): Changing these values can cause the MCG to trigger UB!! They
// must always be odd values. That's not a big deal, since any good LCG
// multiplier will be odd anyway, but you have been warned.

/// The default PCG multiplier for 8 bits of state
pub const PCG_DEFAULT_MULTIPLIER_8: u8 = 141;

/// The default PCG multiplier for 16 bits of state
pub const PCG_DEFAULT_MULTIPLIER_16: u16 = 12829;

/// The default PCG multiplier for 32 bits of state
pub const PCG_DEFAULT_MULTIPLIER_32: u32 = 747796405;

/// The default PCG multiplier for 64 bits of state
pub const PCG_DEFAULT_MULTIPLIER_64: u64 = 6364136223846793005;

/// The default PCG multiplier for 128 bits of state
pub const PCG_DEFAULT_MULTIPLIER_128: u128 = 47026247687942121848144207491837523525;

/// The default PCG increment for 8 bits of state
pub const PCG_DEFAULT_INCREMENT_8: NonZeroU8 = unsafe { NonZeroU8::new_unchecked(77) };

/// The default PCG increment for 16 bits of state
pub const PCG_DEFAULT_INCREMENT_16: NonZeroU16 = unsafe { NonZeroU16::new_unchecked(47989) };

/// The default PCG increment for 32 bits of state
pub const PCG_DEFAULT_INCREMENT_32: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(2891336453) };

/// The default PCG increment for 64 bits of state
pub const PCG_DEFAULT_INCREMENT_64: NonZeroU64 = unsafe { NonZeroU64::new_unchecked(1442695040888963407) };

/// The default PCG increment for 128 bits of state
pub const PCG_DEFAULT_INCREMENT_128: NonZeroU128 = unsafe { NonZeroU128::new_unchecked(117397592171526113268558934119004209487) };