Struct rand_isaac::isaac64::Isaac64Core
source · pub struct Isaac64Core {
mem: [Wrapping<u64>; 256],
a: Wrapping<u64>,
b: Wrapping<u64>,
c: Wrapping<u64>,
}
Expand description
The core of Isaac64Rng
, used with BlockRng
.
Fields§
§mem: [Wrapping<u64>; 256]
§a: Wrapping<u64>
§b: Wrapping<u64>
§c: Wrapping<u64>
Implementations§
Trait Implementations§
source§impl BlockRngCore for Isaac64Core
impl BlockRngCore for Isaac64Core
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 Isaac64Rng
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§type Results = IsaacArray<<Isaac64Core as BlockRngCore>::Item>
type Results = IsaacArray<<Isaac64Core as BlockRngCore>::Item>
Results type. This is the ‘block’ an RNG implementing
BlockRngCore
generates, which will usually be an array like [u32; 16]
.source§impl Clone for Isaac64Core
impl Clone for Isaac64Core
source§fn clone(&self) -> Isaac64Core
fn clone(&self) -> Isaac64Core
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Isaac64Core
impl Debug for Isaac64Core
source§impl PartialEq for Isaac64Core
impl PartialEq for Isaac64Core
source§impl SeedableRng for Isaac64Core
impl SeedableRng for Isaac64Core
source§type Seed = [u8; 32]
type Seed = [u8; 32]
Seed type, which is restricted to types mutably-dereferenceable as
u8
arrays (we recommend [u8; N]
for some N
). Read moresource§fn seed_from_u64(seed: u64) -> Self
fn seed_from_u64(seed: u64) -> Self
Create a new PRNG using a
u64
seed. Read moresource§fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error>
fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error>
Create a new PRNG seeded from another
Rng
. Read moresource§fn from_entropy() -> Self
fn from_entropy() -> Self
impl Eq for Isaac64Core
Auto Trait Implementations§
impl Freeze for Isaac64Core
impl RefUnwindSafe for Isaac64Core
impl Send for Isaac64Core
impl Sync for Isaac64Core
impl Unpin for Isaac64Core
impl UnwindSafe for Isaac64Core
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
)