pub struct Strides { /* private fields */ }Expand description
Stride values (element-offset per index step) for each dimension.
A stride of 0 means broadcast: the same element is reused across that axis.
This struct is Send and Sync because all its components (usize and smallvec::SmallVec) are Send and Sync.
Implementations§
Source§impl Strides
impl Strides
Sourcepub fn get(&self, dim: usize) -> Option<usize>
pub fn get(&self, dim: usize) -> Option<usize>
Returns the stride for the given dimension index.
Sourcepub fn checked_flat_index(&self, idx: &[usize]) -> Option<usize>
pub fn checked_flat_index(&self, idx: &[usize]) -> Option<usize>
Computes a flat element index from a multi-dimensional index.
Returns Some(flat_index) if the calculation does not overflow usize,
None otherwise.
Sourcepub fn flat_index(&self, idx: &[usize]) -> usize
pub fn flat_index(&self, idx: &[usize]) -> usize
Computes a flat element index from a multi-dimensional index.
§Panics
Panics if idx.len() != strides.len() (rank mismatch) or if the flat index calculation overflows usize.
Sourcepub fn max_flat_index(&self, shape: &Shape) -> usize
pub fn max_flat_index(&self, shape: &Shape) -> usize
Calculates the maximum possible flat index for these strides given a shape.
Returns the maximum flat index. Panics if the calculation overflows usize.
§Panics
Panics if the rank of self and shape do not match.
Panics if the maximum flat index calculation overflows usize.
Trait Implementations§
impl Eq for Strides
impl StructuralPartialEq for Strides
Auto Trait Implementations§
impl Freeze for Strides
impl RefUnwindSafe for Strides
impl Send for Strides
impl Sync for Strides
impl Unpin for Strides
impl UnsafeUnpin for Strides
impl UnwindSafe for Strides
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
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§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.