Struct Lcg128CmDxsm64
struct Lcg128CmDxsm64 { ... }
A PCG random number generator (CM DXSM 128/64 (LCG) variant).
Permuted Congruential Generator with 128-bit state, internal Linear Congruential Generator, and 64-bit output via "double xorshift multiply" output function.
This is a 128-bit LCG with explicitly chosen stream with the PCG-DXSM
output function. This corresponds to pcg_engines::cm_setseq_dxsm_128_64
from pcg_cpp and PCG64DXSM from NumPy.
Despite the name, this implementation uses 32 bytes (256 bit) space
comprising 128 bits of state and 128 bits stream selector. These are both
set by SeedableRng, using a 256-bit seed.
Note that while two generators with different stream parameter may be closely correlated, this is mitigated by the DXSM output function.
Implementations
impl Lcg128CmDxsm64
fn advance(self: &mut Self, delta: u128)Multi-step advance functions (jump-ahead, jump-back)
The method used here is based on Brown, "Random Number Generation with Arbitrary Stride,", Transactions of the American Nuclear Society (Nov. 1994). The algorithm is very similar to fast exponentiation.
Even though delta is an unsigned integer, we can pass a signed integer to go backwards, it just goes "the long way round".
Using this function is equivalent to calling
next_64()deltanumber of times.fn new(state: u128, stream: u128) -> SelfConstruct an instance compatible with PCG seed and stream.
Note that the highest bit of the
streamparameter is discarded to simplify upholding internal invariants.Note that while two generators with different stream parameter may be closely correlated, this is mitigated by the DXSM output function.
PCG specifies the following default values for both parameters:
state = 0xcafef00dd15ea5e5stream = 0xa02bdbf7bb3c0a7ac28fa16a64abf96
impl Clone for Lcg128CmDxsm64
fn clone(self: &Self) -> Lcg128CmDxsm64
impl Debug for Lcg128CmDxsm64
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Eq for Lcg128CmDxsm64
impl Freeze for Lcg128CmDxsm64
impl PartialEq for Lcg128CmDxsm64
fn eq(self: &Self, other: &Lcg128CmDxsm64) -> bool
impl RefUnwindSafe for Lcg128CmDxsm64
impl RngCore for Lcg128CmDxsm64
fn next_u32(self: &mut Self) -> u32fn next_u64(self: &mut Self) -> u64fn fill_bytes(self: &mut Self, dest: &mut [u8])
impl SeedableRng for Lcg128CmDxsm64
fn from_seed(seed: <Self as >::Seed) -> SelfWe use a single 255-bit seed to initialise the state and select a stream. One
seedbit (lowest bit ofseed[8]) is ignored.
impl Send for Lcg128CmDxsm64
impl Serialize for Lcg128CmDxsm64
fn serialize<__S>(self: &Self, __serializer: __S) -> Result<<__S as >::Ok, <__S as >::Error> where __S: Serializer
impl StructuralPartialEq for Lcg128CmDxsm64
impl Sync for Lcg128CmDxsm64
impl Unpin for Lcg128CmDxsm64
impl UnsafeUnpin for Lcg128CmDxsm64
impl UnwindSafe for Lcg128CmDxsm64
impl<'de> Deserialize for Lcg128CmDxsm64
fn deserialize<__D>(__deserializer: __D) -> Result<Self, <__D as >::Error> where __D: Deserializer<'de>
impl<R> TryRngCore for Lcg128CmDxsm64
fn try_next_u32(self: &mut Self) -> Result<u32, <R as TryRngCore>::Error>fn try_next_u64(self: &mut Self) -> Result<u64, <R as TryRngCore>::Error>fn try_fill_bytes(self: &mut Self, dst: &mut [u8]) -> Result<(), <R as TryRngCore>::Error>
impl<T> Any for Lcg128CmDxsm64
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Lcg128CmDxsm64
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Lcg128CmDxsm64
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Lcg128CmDxsm64
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> DeserializeOwned for Lcg128CmDxsm64
impl<T> From for Lcg128CmDxsm64
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Lcg128CmDxsm64
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for Lcg128CmDxsm64
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Lcg128CmDxsm64
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Lcg128CmDxsm64
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>