Skip to main content

Reindexing4

Struct Reindexing4 

Source
pub struct Reindexing4 { /* private fields */ }
Expand description

A type representing an immutable mapping from a quadruple of integer intervals 0..input0_bound, 0..input1_bound, 0..input2_bound, and 0..input3_bound to integer interval 0..output_bound.

Mathematically this encodes a function 0..input0_bound × 0..input1_bound × 0..input2_bound × 0..input3_bound → 0..output_bound.

Implementations§

Source§

impl Reindexing4

Source

pub fn new( input0_bound: usize, input1_bound: usize, input2_bound: usize, input3_bound: usize, output_bound: usize, f: impl FnMut(usize, usize, usize, usize) -> usize, ) -> Self

Creates a new Reindexing4 from a function f: (usize, usize, usize, usize) -> usize and bounds on the input and output intervals. The function f is evaluated at each quadruple of integers from 0 to input0_bound - 1, 0 to input1_bound - 1, 0 to input2_bound - 1, and 0 to input3_bound - 1, and the results are reduced modulo output_bound to produce the reindexing. If any of input0_bound, input1_bound, input2_bound, or input3_bound is zero, the resulting reindexing is empty and the function f is not evaluated at all. If output_bound is zero, the function panics. The resulting reindexing is immutable and guarantees that for each quadruple (i0, i1, i2, i3) in 0..input0_bound × 0..input1_bound × 0..input2_bound × 0..input3_bound, the value of reindexing[i0, i1, i2, i3] is in 0..output_bound.

Source

pub fn shuffle( input0_bound: usize, input1_bound: usize, input2_bound: usize, input3_bound: usize, rand: &mut impl Rng, ) -> Self

Creates a random permutation reindexing of the product domain 0..input0_bound × 0..input1_bound × 0..input2_bound × 0..input3_bound. The output range is 0..(input0_bound * input1_bound * input2_bound * input3_bound).

Source

pub fn input_shape(&self) -> (usize, usize, usize, usize)

Returns the shape of the input domain as a 4-tuple.

Source

pub fn output_bound(&self) -> usize

Returns the bound of the output interval.

Trait Implementations§

Source§

impl AsRef<[usize]> for Reindexing4

Source§

fn as_ref(&self) -> &[usize]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Drop for Reindexing4

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Index<(usize, usize, usize, usize)> for Reindexing4

Source§

type Output = usize

The returned type after indexing.
Source§

fn index(&self, index: (usize, usize, usize, usize)) -> &Self::Output

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V