pub struct IsaacCore { /* private fields */ }
Expand description
The core of IsaacRng
, used with BlockRng
.
Trait Implementations§
Source§impl BlockRngCore for IsaacCore
impl BlockRngCore for IsaacCore
Source§fn generate(&mut self, results: &mut IsaacArray<Self::Item>)
fn generate(&mut self, results: &mut IsaacArray<Self::Item>)
Refills the output buffer, results
. See also the pseudocode desciption
of the algorithm in the IsaacRng
documentation.
Optimisations used (similar to the reference implementation):
- The loop is unrolled 4 times, once for every constant of mix().
- The contents of the main loop are moved to a function
rngstep
, to reduce code duplication. - We use local variables for a and b, which helps with optimisations.
- We split the main loop in two, one that operates over 0..128 and one
over 128..256. This way we can optimise out the addition and modulus
from
s[i+128 mod 256]
. - We maintain one index
i
and addm
orm2
as base (m2 for thes[i+128 mod 256]
), relying on the optimizer to turn it into pointer arithmetic. - We fill
results
backwards. The reference implementation reads values fromresults
in reverse. We read them in the normal direction, to makefill_bytes
a memcopy. To maintain compatibility we fill in reverse.
Source§impl SeedableRng for IsaacCore
impl SeedableRng for IsaacCore
Source§fn seed_from_u64(seed: u64) -> Self
fn seed_from_u64(seed: u64) -> Self
Create an ISAAC random number generator using an u64
as seed.
If seed == 0
this will produce the same stream of random numbers as
the reference implementation when used unseeded.
Auto Trait Implementations§
impl Freeze for IsaacCore
impl RefUnwindSafe for IsaacCore
impl Send for IsaacCore
impl Sync for IsaacCore
impl Unpin for IsaacCore
impl UnwindSafe for IsaacCore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)