[−][src]Trait tract_core::internal::tract_ndarray::Dimension
Array shape and index trait.
This trait defines a number of methods and operations that can be used on dimensions and indices.
Note: This trait can not be implemented outside the crate
Associated Types
type SliceArg: AsRef<[SliceOrIndex]> + ?Sized[src]
SliceArg is the type which is used to specify slicing for this
dimension.
For the fixed size dimensions it is a fixed size array of the correct size, which you pass by reference. For the dynamic dimension it is a slice.
- For
Ix1:[SliceOrIndex; 1] - For
Ix2:[SliceOrIndex; 2] - and so on..
- For
IxDyn:[SliceOrIndex]
The easiest way to create a &SliceInfo<SliceArg, Do> is using the
s![] macro.
type Pattern: IntoDimension + Clone + PartialEq<Self::Pattern> + Eq + Default + Debug[src]
Pattern matching friendly form of the dimension value.
- For
Ix1:usize, - For
Ix2:(usize, usize) - and so on..
- For
IxDyn:IxDyn
type Smaller: Dimension[src]
Next smaller dimension (if applicable)
type Larger: Dimension[src]
Next larger dimension
Associated Constants
pub const NDIM: Option<usize>[src]
For fixed-size dimension representations (e.g. Ix2), this should be
Some(ndim), and for variable-size dimension representations (e.g.
IxDyn), this should be None.
Required methods
pub fn ndim(&self) -> usize[src]
Returns the number of dimensions (number of axes).
pub fn into_pattern(self) -> Self::Pattern[src]
Convert the dimension into a pattern matching friendly value.
pub fn zeros(ndim: usize) -> Self[src]
Creates a dimension of all zeros with the specified ndim.
This method is useful for generalizing over fixed-size and variable-size dimension representations.
Panics if Self has a fixed size that is not ndim.
pub fn __private__(&self) -> PrivateMarker[src]
This trait is private to implement; this method exists to make it impossible to implement outside the crate.
Provided methods
pub fn size(&self) -> usize[src]
Compute the size of the dimension (number of elements)
pub fn size_checked(&self) -> Option<usize>[src]
Compute the size while checking for overflow.
pub fn as_array_view(&self) -> ArrayBase<ViewRepr<&usize>, Dim<[usize; 1]>>[src]
Borrow as a read-only array view.
pub fn as_array_view_mut(
&mut self
) -> ArrayBase<ViewRepr<&mut usize>, Dim<[usize; 1]>>[src]
&mut self
) -> ArrayBase<ViewRepr<&mut usize>, Dim<[usize; 1]>>
Borrow as a read-write array view.
pub fn into_dyn(self) -> Dim<IxDynImpl>[src]
Convert the dimensional into a dynamic dimensional (IxDyn).
Implementors
impl Dimension for Dim<[usize; 0]>[src]
pub const NDIM: Option<usize>[src]
type SliceArg = [SliceOrIndex; 0]
type Pattern = ()
type Smaller = Dim<[usize; 0]>
type Larger = Dim<[usize; 1]>
pub fn ndim(&self) -> usize[src]
pub fn slice(&self) -> &[usize]ⓘ[src]
pub fn slice_mut(&mut self) -> &mut [usize]ⓘ[src]
pub fn _fastest_varying_stride_order(&self) -> Dim<[usize; 0]>[src]
pub fn into_pattern(self) -> <Dim<[usize; 0]> as Dimension>::Pattern[src]
pub fn zeros(ndim: usize) -> Dim<[usize; 0]>[src]
pub fn next_for(&self, _index: Dim<[usize; 0]>) -> Option<Dim<[usize; 0]>>[src]
pub fn insert_axis(&self, axis: Axis) -> <Dim<[usize; 0]> as Dimension>::Larger[src]
pub fn try_remove_axis(
&self,
_ignore: Axis
) -> <Dim<[usize; 0]> as Dimension>::Smaller[src]
&self,
_ignore: Axis
) -> <Dim<[usize; 0]> as Dimension>::Smaller
impl Dimension for Dim<[usize; 1]>[src]
pub const NDIM: Option<usize>[src]
type SliceArg = [SliceOrIndex; 1]
type Pattern = usize
type Smaller = Dim<[usize; 0]>
type Larger = Dim<[usize; 2]>
pub fn ndim(&self) -> usize[src]
pub fn slice(&self) -> &[usize]ⓘ[src]
pub fn slice_mut(&mut self) -> &mut [usize]ⓘ[src]
pub fn into_pattern(self) -> <Dim<[usize; 1]> as Dimension>::Pattern[src]
pub fn zeros(ndim: usize) -> Dim<[usize; 1]>[src]
pub fn next_for(&self, index: Dim<[usize; 1]>) -> Option<Dim<[usize; 1]>>[src]
pub fn equal(&self, rhs: &Dim<[usize; 1]>) -> bool[src]
pub fn size(&self) -> usize[src]
pub fn size_checked(&self) -> Option<usize>[src]
pub fn default_strides(&self) -> Dim<[usize; 1]>[src]
pub fn _fastest_varying_stride_order(&self) -> Dim<[usize; 1]>[src]
pub fn min_stride_axis(&self, &Dim<[usize; 1]>) -> Axis[src]
pub fn max_stride_axis(&self, &Dim<[usize; 1]>) -> Axis[src]
pub fn first_index(&self) -> Option<Dim<[usize; 1]>>[src]
pub fn stride_offset(index: &Dim<[usize; 1]>, stride: &Dim<[usize; 1]>) -> isize[src]
pub fn stride_offset_checked(
&self,
stride: &Dim<[usize; 1]>,
index: &Dim<[usize; 1]>
) -> Option<isize>[src]
&self,
stride: &Dim<[usize; 1]>,
index: &Dim<[usize; 1]>
) -> Option<isize>
pub fn insert_axis(&self, axis: Axis) -> <Dim<[usize; 1]> as Dimension>::Larger[src]
pub fn try_remove_axis(
&self,
axis: Axis
) -> <Dim<[usize; 1]> as Dimension>::Smaller[src]
&self,
axis: Axis
) -> <Dim<[usize; 1]> as Dimension>::Smaller
impl Dimension for Dim<[usize; 2]>[src]
pub const NDIM: Option<usize>[src]
type SliceArg = [SliceOrIndex; 2]
type Pattern = (usize, usize)
type Smaller = Dim<[usize; 1]>
type Larger = Dim<[usize; 3]>
pub fn ndim(&self) -> usize[src]
pub fn into_pattern(self) -> <Dim<[usize; 2]> as Dimension>::Pattern[src]
pub fn slice(&self) -> &[usize]ⓘ[src]
pub fn slice_mut(&mut self) -> &mut [usize]ⓘ[src]
pub fn zeros(ndim: usize) -> Dim<[usize; 2]>[src]
pub fn next_for(&self, index: Dim<[usize; 2]>) -> Option<Dim<[usize; 2]>>[src]
pub fn equal(&self, rhs: &Dim<[usize; 2]>) -> bool[src]
pub fn size(&self) -> usize[src]
pub fn size_checked(&self) -> Option<usize>[src]
pub fn last_elem(&self) -> usize[src]
pub fn set_last_elem(&mut self, i: usize)[src]
pub fn default_strides(&self) -> Dim<[usize; 2]>[src]
pub fn fortran_strides(&self) -> Dim<[usize; 2]>[src]
pub fn _fastest_varying_stride_order(&self) -> Dim<[usize; 2]>[src]
pub fn min_stride_axis(&self, strides: &Dim<[usize; 2]>) -> Axis[src]
pub fn first_index(&self) -> Option<Dim<[usize; 2]>>[src]
pub fn stride_offset(
index: &Dim<[usize; 2]>,
strides: &Dim<[usize; 2]>
) -> isize[src]
index: &Dim<[usize; 2]>,
strides: &Dim<[usize; 2]>
) -> isize
pub fn stride_offset_checked(
&self,
strides: &Dim<[usize; 2]>,
index: &Dim<[usize; 2]>
) -> Option<isize>[src]
&self,
strides: &Dim<[usize; 2]>,
index: &Dim<[usize; 2]>
) -> Option<isize>
pub fn insert_axis(&self, axis: Axis) -> <Dim<[usize; 2]> as Dimension>::Larger[src]
pub fn try_remove_axis(
&self,
axis: Axis
) -> <Dim<[usize; 2]> as Dimension>::Smaller[src]
&self,
axis: Axis
) -> <Dim<[usize; 2]> as Dimension>::Smaller
impl Dimension for Dim<[usize; 3]>[src]
pub const NDIM: Option<usize>[src]
type SliceArg = [SliceOrIndex; 3]
type Pattern = (usize, usize, usize)
type Smaller = Dim<[usize; 2]>
type Larger = Dim<[usize; 4]>
pub fn ndim(&self) -> usize[src]
pub fn into_pattern(self) -> <Dim<[usize; 3]> as Dimension>::Pattern[src]
pub fn slice(&self) -> &[usize]ⓘ[src]
pub fn slice_mut(&mut self) -> &mut [usize]ⓘ[src]
pub fn size(&self) -> usize[src]
pub fn zeros(ndim: usize) -> Dim<[usize; 3]>[src]
pub fn next_for(&self, index: Dim<[usize; 3]>) -> Option<Dim<[usize; 3]>>[src]
pub fn stride_offset(
index: &Dim<[usize; 3]>,
strides: &Dim<[usize; 3]>
) -> isize[src]
index: &Dim<[usize; 3]>,
strides: &Dim<[usize; 3]>
) -> isize
pub fn stride_offset_checked(
&self,
strides: &Dim<[usize; 3]>,
index: &Dim<[usize; 3]>
) -> Option<isize>[src]
&self,
strides: &Dim<[usize; 3]>,
index: &Dim<[usize; 3]>
) -> Option<isize>
pub fn _fastest_varying_stride_order(&self) -> Dim<[usize; 3]>[src]
pub fn insert_axis(&self, axis: Axis) -> <Dim<[usize; 3]> as Dimension>::Larger[src]
pub fn try_remove_axis(
&self,
axis: Axis
) -> <Dim<[usize; 3]> as Dimension>::Smaller[src]
&self,
axis: Axis
) -> <Dim<[usize; 3]> as Dimension>::Smaller
impl Dimension for Dim<[usize; 4]>[src]
pub const NDIM: Option<usize>[src]
type SliceArg = [SliceOrIndex; 4]
type Pattern = (usize, usize, usize, usize)
type Smaller = Dim<[usize; 3]>
type Larger = Dim<[usize; 5]>
pub fn ndim(&self) -> usize[src]
pub fn into_pattern(self) -> <Dim<[usize; 4]> as Dimension>::Pattern[src]
pub fn slice(&self) -> &[usize]ⓘ[src]
pub fn slice_mut(&mut self) -> &mut [usize]ⓘ[src]
pub fn zeros(ndim: usize) -> Dim<[usize; 4]>[src]
pub fn insert_axis(&self, axis: Axis) -> <Dim<[usize; 4]> as Dimension>::Larger[src]
pub fn try_remove_axis(
&self,
axis: Axis
) -> <Dim<[usize; 4]> as Dimension>::Smaller[src]
&self,
axis: Axis
) -> <Dim<[usize; 4]> as Dimension>::Smaller
impl Dimension for Dim<[usize; 5]>[src]
pub const NDIM: Option<usize>[src]
type SliceArg = [SliceOrIndex; 5]
type Pattern = (usize, usize, usize, usize, usize)
type Smaller = Dim<[usize; 4]>
type Larger = Dim<[usize; 6]>
pub fn ndim(&self) -> usize[src]
pub fn into_pattern(self) -> <Dim<[usize; 5]> as Dimension>::Pattern[src]
pub fn slice(&self) -> &[usize]ⓘ[src]
pub fn slice_mut(&mut self) -> &mut [usize]ⓘ[src]
pub fn zeros(ndim: usize) -> Dim<[usize; 5]>[src]
pub fn insert_axis(&self, axis: Axis) -> <Dim<[usize; 5]> as Dimension>::Larger[src]
pub fn try_remove_axis(
&self,
axis: Axis
) -> <Dim<[usize; 5]> as Dimension>::Smaller[src]
&self,
axis: Axis
) -> <Dim<[usize; 5]> as Dimension>::Smaller
impl Dimension for Dim<[usize; 6]>[src]
pub const NDIM: Option<usize>[src]
type SliceArg = [SliceOrIndex; 6]
type Pattern = (usize, usize, usize, usize, usize, usize)
type Smaller = Dim<[usize; 5]>
type Larger = Dim<IxDynImpl>
pub fn ndim(&self) -> usize[src]
pub fn into_pattern(self) -> <Dim<[usize; 6]> as Dimension>::Pattern[src]
pub fn slice(&self) -> &[usize]ⓘ[src]
pub fn slice_mut(&mut self) -> &mut [usize]ⓘ[src]
pub fn zeros(ndim: usize) -> Dim<[usize; 6]>[src]
pub fn insert_axis(&self, axis: Axis) -> <Dim<[usize; 6]> as Dimension>::Larger[src]
pub fn try_remove_axis(
&self,
axis: Axis
) -> <Dim<[usize; 6]> as Dimension>::Smaller[src]
&self,
axis: Axis
) -> <Dim<[usize; 6]> as Dimension>::Smaller
impl Dimension for Dim<IxDynImpl>[src]
IxDyn is a "dynamic" index, pretty hard to use when indexing, and memory wasteful, but it allows an arbitrary and dynamic number of axes.
pub const NDIM: Option<usize>[src]
type SliceArg = [SliceOrIndex]
type Pattern = Dim<IxDynImpl>
type Smaller = Dim<IxDynImpl>
type Larger = Dim<IxDynImpl>
pub fn ndim(&self) -> usize[src]
pub fn slice(&self) -> &[usize]ⓘ[src]
pub fn slice_mut(&mut self) -> &mut [usize]ⓘ[src]
pub fn into_pattern(self) -> <Dim<IxDynImpl> as Dimension>::Pattern[src]
pub fn zeros(ndim: usize) -> Dim<IxDynImpl>[src]
pub fn insert_axis(&self, axis: Axis) -> <Dim<IxDynImpl> as Dimension>::Larger[src]
pub fn try_remove_axis(
&self,
axis: Axis
) -> <Dim<IxDynImpl> as Dimension>::Smaller[src]
&self,
axis: Axis
) -> <Dim<IxDynImpl> as Dimension>::Smaller
pub fn from_dimension<D2>(d: &D2) -> Option<Dim<IxDynImpl>> where
D2: Dimension, [src]
D2: Dimension,