[][src]Struct lcg_tools::LCG

pub struct LCG {
    pub state: BigInt,
    pub a: BigInt,
    pub c: BigInt,
    pub m: BigInt,
}

Represents a linear congruential generator which can calculate both forwards and backwards

Fields

state: BigInt

Seed

a: BigInt

Multiplier

c: BigInt

Increment

m: BigInt

Modulus

Implementations

impl LCG[src]

pub fn rand(&mut self) -> BigInt[src]

Calculate the next value of the LCG

state * a + c % m

pub fn prev(&mut self) -> Option<BigInt>[src]

Calculate the previous value of the LCG

modinv(a,m) * (state - c) % m

relies on modinv(a,m) existing (aka a and m must be coprime) and will return None otherwise

Trait Implementations

impl Debug for LCG[src]

impl Eq for LCG[src]

impl Iterator for LCG[src]

type Item = BigInt

The type of the elements being iterated over.

impl PartialEq<LCG> for LCG[src]

impl StructuralEq for LCG[src]

impl StructuralPartialEq for LCG[src]

Auto Trait Implementations

impl RefUnwindSafe for LCG

impl Send for LCG

impl Sync for LCG

impl Unpin for LCG

impl UnwindSafe for LCG

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> Itertools for T where
    T: Iterator + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.