Trait ndarray::Dimension

source ·
pub unsafe trait Dimension: Clone + Eq {
    // Required method
    fn ndim(&self) -> usize;

    // Provided methods
    fn slice(&self) -> &[Ix] { ... }
    fn slice_mut(&mut self) -> &mut [Ix] { ... }
    fn size(&self) -> usize { ... }
    fn default_strides(&self) -> Self { ... }
    fn first_index(&self) -> Option<Self> { ... }
    fn next_for(&self, index: Self) -> Option<Self> { ... }
    fn stride_offset(index: &Self, strides: &Self) -> isize { ... }
    fn stride_offset_checked(
        &self,
        strides: &Self,
        index: &Self,
    ) -> Option<isize> { ... }
    fn do_slices(dim: &mut Self, strides: &mut Self, slices: &[Si]) -> isize { ... }
}
Expand description

Trait for the shape and index types of arrays.

unsafe trait due to how the assumptions in the default impls work.

Required Methods§

source

fn ndim(&self) -> usize

Provided Methods§

source

fn slice(&self) -> &[Ix]

source

fn slice_mut(&mut self) -> &mut [Ix]

source

fn size(&self) -> usize

source

fn default_strides(&self) -> Self

source

fn first_index(&self) -> Option<Self>

source

fn next_for(&self, index: Self) -> Option<Self>

Iteration – Use self as size, and return next index after index or None if there are no more.

source

fn stride_offset(index: &Self, strides: &Self) -> isize

Return stride offset for index.

source

fn stride_offset_checked(&self, strides: &Self, index: &Self) -> Option<isize>

Return stride offset for this dimension and index.

source

fn do_slices(dim: &mut Self, strides: &mut Self, slices: &[Si]) -> isize

Modify dimension, strides and return data pointer offset

Panics if slices does not correspond to the number of axes, if any stride is 0, or if any index is out of bounds.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Dimension for (Ix, Ix)

source§

fn stride_offset(index: &(Ix, Ix), strides: &(Ix, Ix)) -> isize

Self is an index, return the stride offset

source§

fn stride_offset_checked( &self, strides: &(Ix, Ix), index: &(Ix, Ix), ) -> Option<isize>

Return stride offset for this dimension and index.

source§

fn ndim(&self) -> usize

source§

fn size(&self) -> usize

source§

fn first_index(&self) -> Option<(Ix, Ix)>

source§

fn next_for(&self, index: (Ix, Ix)) -> Option<(Ix, Ix)>

source§

impl Dimension for (Ix, Ix, Ix)

source§

fn stride_offset(index: &(Ix, Ix, Ix), strides: &(Ix, Ix, Ix)) -> isize

Self is an index, return the stride offset

source§

fn ndim(&self) -> usize

source§

fn size(&self) -> usize

source§

fn next_for(&self, index: (Ix, Ix, Ix)) -> Option<(Ix, Ix, Ix)>

source§

impl Dimension for (Ix, Ix, Ix, Ix)

source§

fn ndim(&self) -> usize

source§

impl Dimension for (Ix, Ix, Ix, Ix, Ix)

source§

fn ndim(&self) -> usize

source§

impl Dimension for (Ix, Ix, Ix, Ix, Ix, Ix)

source§

fn ndim(&self) -> usize

source§

impl Dimension for (Ix, Ix, Ix, Ix, Ix, Ix, Ix)

source§

fn ndim(&self) -> usize

source§

impl Dimension for (Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix)

source§

fn ndim(&self) -> usize

source§

impl Dimension for (Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix)

source§

fn ndim(&self) -> usize

source§

impl Dimension for (Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix)

source§

fn ndim(&self) -> usize

source§

impl Dimension for (Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix)

source§

fn ndim(&self) -> usize

source§

impl Dimension for (Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix)

source§

fn ndim(&self) -> usize

source§

impl Dimension for ()

source§

fn ndim(&self) -> usize

source§

fn slice(&self) -> &[Ix]

source§

fn slice_mut(&mut self) -> &mut [Ix]

source§

impl Dimension for Vec<Ix>

source§

fn ndim(&self) -> usize

source§

fn slice(&self) -> &[Ix]

source§

fn slice_mut(&mut self) -> &mut [Ix]

Implementors§