pub enum Steps {
Stride {
start: usize,
len: usize,
step: isize,
},
Padded {
start: i128,
len: usize,
size: usize,
stride: usize,
edge: Edge,
},
Rotated {
shift: usize,
len: usize,
stride: usize,
},
Table(Table),
}Expand description
The source offsets of one result axis. Regular patterns need no position table; a missing offset reads fill.
Variants§
Stride
Consecutive offsets with a signed step.
Padded
Positions along one source axis, reading past its ends under the edge mode.
Rotated
A whole source axis beginning at the shift and wrapping to the start.
Table(Table)
Explicit source offsets.
Implementations§
Source§impl Steps
impl Steps
Sourcepub fn along(len: usize, stride: usize) -> Self
pub fn along(len: usize, stride: usize) -> Self
Every position of an axis of len items with stride, in order.
Sourcepub fn row_major(
lens: &[usize],
scale: usize,
start: usize,
) -> impl Iterator<Item = Self> + '_
pub fn row_major( lens: &[usize], scale: usize, start: usize, ) -> impl Iterator<Item = Self> + '_
One entry for each of lens, reading an array of those lengths in row-major order from position start, with every stride multiplied by scale.
Sourcepub fn table(offsets: Vec<usize>) -> Self
pub fn table(offsets: Vec<usize>) -> Self
A table of offsets, with Steps::FILL where a fill goes.
Sourcepub fn scaled(self, k: usize) -> Self
pub fn scaled(self, k: usize) -> Self
This entry with its offsets k times as far apart, as where each position it reads is a cell of k items.
Sourcepub fn padded(
start: i128,
len: usize,
size: usize,
stride: usize,
edge: Edge,
) -> Self
pub fn padded( start: i128, len: usize, size: usize, stride: usize, edge: Edge, ) -> Self
len positions from start along an axis of size items with stride, read past the axis’s ends by edge: a Padded entry where a position falls outside the axis, the Rotated entry for a wrapped stretch as long as the axis, a Stride of step 0 for an axis of one item that an edge other than Fill reads, and otherwise the Stride that reads the same offsets.
Sourcepub fn clipped(start: i128, len: usize, size: usize, stride: usize) -> Self
pub fn clipped(start: i128, len: usize, size: usize, stride: usize) -> Self
padded with a fill past the axis’s ends.
Sourcepub fn rotated(shift: usize, len: usize, stride: usize) -> Self
pub fn rotated(shift: usize, len: usize, stride: usize) -> Self
All len positions of an axis with stride, from position shift, wrapping round: a Rotated entry, or the Stride that reads the same offsets where the shift is a whole turn.
Sourcepub fn footprint(&self) -> usize
pub fn footprint(&self) -> usize
The bytes this entry takes: itself, and a table’s listed offsets.
Sourcepub fn offsets(&self) -> impl ExactSizeIterator<Item = Option<usize>> + '_
pub fn offsets(&self) -> impl ExactSizeIterator<Item = Option<usize>> + '_
Every offset, in order, None for a fill.
Sourcepub fn for_each(&self, each: impl FnMut(usize, Option<usize>))
pub fn for_each(&self, each: impl FnMut(usize, Option<usize>))
Calls each with each position along this axis and its offset, or None where it gives a fill. It matches the kind of step once, before its loop. A loop through Steps::offsets or Steps::get matches it at every position, and makes a call there wherever LLVM keeps get out of line, as it can despite #[inline].
Sourcepub fn count(steps: &[impl Borrow<Self>]) -> usize
pub fn count(steps: &[impl Borrow<Self>]) -> usize
How many positions steps reach: the product of their lengths.
Sourcepub fn combined(base: usize, steps: &[impl Borrow<Self>]) -> Vec<usize>
pub fn combined(base: usize, steps: &[impl Borrow<Self>]) -> Vec<usize>
The offset of every position that steps reach from base, in the order that walk visits them, with Steps::FILL where a fill goes. Steps::reach gives one of them.
Sourcepub fn reach(
base: usize,
steps: &[impl Borrow<Self>],
i: usize,
) -> Option<usize>
pub fn reach( base: usize, steps: &[impl Borrow<Self>], i: usize, ) -> Option<usize>
The offset that steps, one entry for each axis, outermost first, reach from base for item i of their frame, or None for a fill.
Sourcepub fn furthest(base: usize, steps: &[impl Borrow<Self>]) -> Option<usize>
pub fn furthest(base: usize, steps: &[impl Borrow<Self>]) -> Option<usize>
An offset that no item of steps passes from base: base plus each entry’s furthest offset, where a fill reaches none and a padded entry stops at the end of its axis. Indexed tables use their axis bounds; listed tables read their offsets. None where an entry has no items, so the walk reads nothing.
Sourcepub fn run(
base: usize,
steps: &[impl Borrow<Self>],
start: usize,
n: usize,
) -> Option<(usize, isize)>
pub fn run( base: usize, steps: &[impl Borrow<Self>], start: usize, n: usize, ) -> Option<(usize, isize)>
The first source offset and stride of items start..start + n, where they form one regular run. Singleton axes disappear and neighbouring strides can form one run. Padded and rotated reads must stay within their valid, unwrapped part.
Sourcepub fn regular(steps: &[Self]) -> (usize, isize)
pub fn regular(steps: &[Self]) -> (usize, isize)
The innermost stretch of the frame whose items read at one regular stride, as its length and that stride: the product of the lengths of the innermost axes, outward, while each axis steps on from the ones inside it. Edges of padded and rotated axes don’t count, because only the runs that cross them copy. A run reads through run only where it lies inside one such stretch.
Sourcepub fn contiguous(steps: &[Self]) -> usize
pub fn contiguous(steps: &[Self]) -> usize
How many consecutive items of the frame read adjacent offsets: the stretch that regular gives where its stride is 1. A run reads in place only inside one such stretch, so a frame whose stretches are shorter than its blocks copies every block.
Sourcepub fn skips(&self) -> bool
pub fn skips(&self) -> bool
Whether this entry reads items that aren’t adjacent: a step or stride of more than 1, as a transpose’s innermost axis has.
Sourcepub fn fills(&self) -> bool
pub fn fills(&self) -> bool
Whether this entry gives a fill at some position: a Padded entry does where its edge mode is fill, and a table does where it holds Steps::FILL.
Sourcepub fn affine(&self) -> Option<(usize, isize)>
pub fn affine(&self) -> Option<(usize, isize)>
This entry’s first offset and step, where it reads its whole axis as one regular run with no fill: a Stride, or a Rotated entry that doesn’t rotate.
Sourcepub fn in_order(tables: &[Self]) -> bool
pub fn in_order(tables: &[Self]) -> bool
Whether a walk through tables reads offsets 0, 1, 2 and so on, in order. A copy through such tables of a source with as many items as the walk reads is the source unchanged. Only Stride entries that start at 0 qualify, and tables whose offsets run 0, 1, 2 and so on at their axis’s stride.
Sourcepub fn spreads(&self) -> bool
pub fn spreads(&self) -> bool
Whether this entry repeats an offset or gives a fill. Applying an element-wise function to the items it reads, in place of reading the function’s results, would then compute an item more than once, or apply the function to a fill.
Sourcepub fn per_axis(tables: &[Self], shape: &[usize]) -> Option<(usize, Vec<Self>)>
pub fn per_axis(tables: &[Self], shape: &[usize]) -> Option<(usize, Vec<Self>)>
tables, a walk’s entries for a result of shape, as one entry for each axis of shape, with the offset of each entry of one item moved into the base. Neighbouring entries that step as one axis merge first (simplify), so that one axis of shape can read several of them, as a view that merges axes does. An entry over several axes splits into one Stride for each. None where an entry that isn’t a Stride covers several axes, or where one axis of shape reads entries that don’t merge.
Sourcepub fn with_base(base: usize, steps: Vec<Self>) -> Vec<Self>
pub fn with_base(base: usize, steps: Vec<Self>) -> Vec<Self>
The tables of a walk from base whose entries are steps: steps, after an entry of one item at base where base isn’t 0. per_axis splits such tables back into base and steps.
Sourcepub fn through(
outer: &[Self],
shape: &[usize],
base: usize,
inner: &[Self],
) -> Option<(usize, Vec<Self>)>
pub fn through( outer: &[Self], shape: &[usize], base: usize, inner: &[Self], ) -> Option<(usize, Vec<Self>)>
outer’s reads of an array of shape, composed with inner, which maps the positions along each axis of shape to offsets from base, with the new base. Walking the result reads what walking inner and then outer reads. Where an entry of outer walks several whole axes of shape, as a reshape of a view reads them, the walk splits it into one entry for each of those axes (by_axes), and the result holds one entry for each. None where outer’s entries don’t each walk one axis of shape even so (Walk::new), where two entries walk one axis that inner doesn’t map by a Stride, or where an entry reads part of an axis that inner rotates or clips. Callers then force the copy that inner describes, in one walk.
Trait Implementations§
impl Eq for Steps
impl StructuralPartialEq for Steps
Auto Trait Implementations§
impl !RefUnwindSafe for Steps
impl !UnwindSafe for Steps
impl Forget for Steps
impl Freeze for Steps
impl Send for Steps
impl Sync for Steps
impl Unpin for Steps
impl UnsafeUnpin for Steps
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more