Skip to main content

OptimizedArrayRandom

Trait OptimizedArrayRandom 

Source
pub trait OptimizedArrayRandom<T, D: Dimension> {
    // Required methods
    fn random_bulk<R, Dist>(
        shape: D,
        distribution: Dist,
        rng: &mut Random<R>,
    ) -> Self
       where R: Rng,
             Dist: Distribution<T> + Copy;
    fn random_using_bulk<R, F>(shape: D, rng: &mut Random<R>, f: F) -> Self
       where R: Rng,
             F: FnMut(&mut Random<R>) -> T;
}
Expand description

Trait for optimized random array generation

This trait provides bulk array generation methods that use a single RNG instance for all elements, dramatically improving performance compared to RNG-per-element approaches.

Required Methods§

Source

fn random_bulk<R, Dist>( shape: D, distribution: Dist, rng: &mut Random<R>, ) -> Self
where R: Rng, Dist: Distribution<T> + Copy,

Generate a random array using a single RNG instance (bulk operation)

Source

fn random_using_bulk<R, F>(shape: D, rng: &mut Random<R>, f: F) -> Self
where R: Rng, F: FnMut(&mut Random<R>) -> T,

Generate a random array using a closure (single RNG instance)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, D> OptimizedArrayRandom<T, D> for Array<T, D>
where D: Dimension,