Trait ndarray::Dimension
[−]
[src]
pub unsafe trait Dimension: Clone + Eq { type SliceArg: ?Sized + AsRef<[Si]>; fn ndim(&self) -> usize; 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: &Self::SliceArg) -> isize { ... } }
Trait for the shape and index types of arrays.
unsafe
because of the assumptions in the default methods.
Don't implement this trait, it's internal to the crate and will evolve at will.
Associated Types
type SliceArg: ?Sized + AsRef<[Si]>
SliceArg
is the type which is used to specify slicing for this
dimension.
For the fixed size dimensions (tuples) it is a fixed size array
of the correct size, which you pass by reference. For the Vec
dimension it is a slice.
- For
Ix
:[Si; 1]
- For
(Ix, Ix)
:[Si; 2]
- and so on..
- For
Vec<Ix>
:[Si]
The easiest way to create a &SliceArg
is using the macro
s![]
.
Required Methods
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>
Iteration -- Use self as size, and return next index after index
or None if there are no more.
fn stride_offset(index: &Self, strides: &Self) -> isize
Return stride offset for index.
fn stride_offset_checked(&self, strides: &Self, index: &Self) -> Option<isize>
Return stride offset for this dimension and index.
fn do_slices(dim: &mut Self, strides: &mut Self, slices: &Self::SliceArg) -> 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.
Implementors
impl Dimension for ()
impl Dimension for Ix
impl Dimension for (Ix, Ix)
impl Dimension for (Ix, Ix, Ix)
impl Dimension for (Ix, Ix, Ix, Ix)
impl Dimension for (Ix, Ix, Ix, Ix, Ix)
impl Dimension for (Ix, Ix, Ix, Ix, Ix, Ix)
impl Dimension for (Ix, Ix, Ix, Ix, Ix, Ix, Ix)
impl Dimension for (Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix)
impl Dimension for (Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix)
impl Dimension for (Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix)
impl Dimension for (Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix)
impl Dimension for (Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix, Ix)
impl Dimension for Vec<Ix>