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
impl Reindexing4
Sourcepub 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
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.
Sourcepub fn shuffle(
input0_bound: usize,
input1_bound: usize,
input2_bound: usize,
input3_bound: usize,
rand: &mut impl Rng,
) -> Self
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).
Sourcepub fn input_shape(&self) -> (usize, usize, usize, usize)
pub fn input_shape(&self) -> (usize, usize, usize, usize)
Returns the shape of the input domain as a 4-tuple.
Sourcepub fn output_bound(&self) -> usize
pub fn output_bound(&self) -> usize
Returns the bound of the output interval.