[−][src]Trait tract_hir::prelude::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
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
Pattern matching friendly form of the dimension value.
- For
Ix1
:usize
, - For
Ix2
:(usize, usize)
- and so on..
- For
IxDyn
:IxDyn
type Smaller: Dimension
Next smaller dimension (if applicable)
type Larger: Dimension
Next larger dimension
Associated Constants
const NDIM: Option<usize>
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
fn ndim(&self) -> usize
Returns the number of dimensions (number of axes).
fn into_pattern(self) -> Self::Pattern
Convert the dimension into a pattern matching friendly value.
fn zeros(ndim: usize) -> Self
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
.
fn __private__(&self) -> PrivateMarker
This trait is private to implement; this method exists to make it impossible to implement outside the crate.
Provided methods
fn size(&self) -> usize
Compute the size of the dimension (number of elements)
fn size_checked(&self) -> Option<usize>
Compute the size while checking for overflow.
fn as_array_view(&self) -> ArrayBase<ViewRepr<&usize>, Dim<[usize; 1]>>
Borrow as a read-only array view.
fn as_array_view_mut(
&mut self
) -> ArrayBase<ViewRepr<&mut usize>, Dim<[usize; 1]>>
&mut self
) -> ArrayBase<ViewRepr<&mut usize>, Dim<[usize; 1]>>
Borrow as a read-write array view.
fn into_dyn(self) -> Dim<IxDynImpl>
Convert the dimensional into a dynamic dimensional (IxDyn).
Implementors
impl Dimension for Dim<[usize; 0]>
[src]
const NDIM: Option<usize>
[src]
type SliceArg = [SliceOrIndex; 0]
type Pattern = ()
type Smaller = Dim<[usize; 0]>
type Larger = Dim<[usize; 1]>
fn ndim(&self) -> usize
[src]
fn slice(&self) -> &[usize]ⓘ
[src]
fn slice_mut(&mut self) -> &mut [usize]ⓘ
[src]
fn _fastest_varying_stride_order(&self) -> Dim<[usize; 0]>
[src]
fn into_pattern(self) -> <Dim<[usize; 0]> as Dimension>::Pattern
[src]
fn zeros(ndim: usize) -> Dim<[usize; 0]>
[src]
fn next_for(&self, _index: Dim<[usize; 0]>) -> Option<Dim<[usize; 0]>>
[src]
fn insert_axis(&self, axis: Axis) -> <Dim<[usize; 0]> as Dimension>::Larger
[src]
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]
const NDIM: Option<usize>
[src]
type SliceArg = [SliceOrIndex; 1]
type Pattern = usize
type Smaller = Dim<[usize; 0]>
type Larger = Dim<[usize; 2]>
fn ndim(&self) -> usize
[src]
fn slice(&self) -> &[usize]ⓘ
[src]
fn slice_mut(&mut self) -> &mut [usize]ⓘ
[src]
fn into_pattern(self) -> <Dim<[usize; 1]> as Dimension>::Pattern
[src]
fn zeros(ndim: usize) -> Dim<[usize; 1]>
[src]
fn next_for(&self, index: Dim<[usize; 1]>) -> Option<Dim<[usize; 1]>>
[src]
fn equal(&self, rhs: &Dim<[usize; 1]>) -> bool
[src]
fn size(&self) -> usize
[src]
fn size_checked(&self) -> Option<usize>
[src]
fn default_strides(&self) -> Dim<[usize; 1]>
[src]
fn _fastest_varying_stride_order(&self) -> Dim<[usize; 1]>
[src]
fn min_stride_axis(&self, &Dim<[usize; 1]>) -> Axis
[src]
fn max_stride_axis(&self, &Dim<[usize; 1]>) -> Axis
[src]
fn first_index(&self) -> Option<Dim<[usize; 1]>>
[src]
fn stride_offset(index: &Dim<[usize; 1]>, stride: &Dim<[usize; 1]>) -> isize
[src]
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>
fn insert_axis(&self, axis: Axis) -> <Dim<[usize; 1]> as Dimension>::Larger
[src]
fn try_remove_axis(&self, axis: Axis) -> <Dim<[usize; 1]> as Dimension>::Smaller
[src]
impl Dimension for Dim<[usize; 2]>
[src]
const NDIM: Option<usize>
[src]
type SliceArg = [SliceOrIndex; 2]
type Pattern = (usize, usize)
type Smaller = Dim<[usize; 1]>
type Larger = Dim<[usize; 3]>
fn ndim(&self) -> usize
[src]
fn into_pattern(self) -> <Dim<[usize; 2]> as Dimension>::Pattern
[src]
fn slice(&self) -> &[usize]ⓘ
[src]
fn slice_mut(&mut self) -> &mut [usize]ⓘ
[src]
fn zeros(ndim: usize) -> Dim<[usize; 2]>
[src]
fn next_for(&self, index: Dim<[usize; 2]>) -> Option<Dim<[usize; 2]>>
[src]
fn equal(&self, rhs: &Dim<[usize; 2]>) -> bool
[src]
fn size(&self) -> usize
[src]
fn size_checked(&self) -> Option<usize>
[src]
fn last_elem(&self) -> usize
[src]
fn set_last_elem(&mut self, i: usize)
[src]
fn default_strides(&self) -> Dim<[usize; 2]>
[src]
fn fortran_strides(&self) -> Dim<[usize; 2]>
[src]
fn _fastest_varying_stride_order(&self) -> Dim<[usize; 2]>
[src]
fn min_stride_axis(&self, strides: &Dim<[usize; 2]>) -> Axis
[src]
fn first_index(&self) -> Option<Dim<[usize; 2]>>
[src]
fn stride_offset(index: &Dim<[usize; 2]>, strides: &Dim<[usize; 2]>) -> isize
[src]
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>
fn insert_axis(&self, axis: Axis) -> <Dim<[usize; 2]> as Dimension>::Larger
[src]
fn try_remove_axis(&self, axis: Axis) -> <Dim<[usize; 2]> as Dimension>::Smaller
[src]
impl Dimension for Dim<[usize; 3]>
[src]
const NDIM: Option<usize>
[src]
type SliceArg = [SliceOrIndex; 3]
type Pattern = (usize, usize, usize)
type Smaller = Dim<[usize; 2]>
type Larger = Dim<[usize; 4]>
fn ndim(&self) -> usize
[src]
fn into_pattern(self) -> <Dim<[usize; 3]> as Dimension>::Pattern
[src]
fn slice(&self) -> &[usize]ⓘ
[src]
fn slice_mut(&mut self) -> &mut [usize]ⓘ
[src]
fn size(&self) -> usize
[src]
fn zeros(ndim: usize) -> Dim<[usize; 3]>
[src]
fn next_for(&self, index: Dim<[usize; 3]>) -> Option<Dim<[usize; 3]>>
[src]
fn stride_offset(index: &Dim<[usize; 3]>, strides: &Dim<[usize; 3]>) -> isize
[src]
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>
fn _fastest_varying_stride_order(&self) -> Dim<[usize; 3]>
[src]
fn insert_axis(&self, axis: Axis) -> <Dim<[usize; 3]> as Dimension>::Larger
[src]
fn try_remove_axis(&self, axis: Axis) -> <Dim<[usize; 3]> as Dimension>::Smaller
[src]
impl Dimension for Dim<[usize; 4]>
[src]
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]>
fn ndim(&self) -> usize
[src]
fn into_pattern(self) -> <Dim<[usize; 4]> as Dimension>::Pattern
[src]
fn slice(&self) -> &[usize]ⓘ
[src]
fn slice_mut(&mut self) -> &mut [usize]ⓘ
[src]
fn zeros(ndim: usize) -> Dim<[usize; 4]>
[src]
fn insert_axis(&self, axis: Axis) -> <Dim<[usize; 4]> as Dimension>::Larger
[src]
fn try_remove_axis(&self, axis: Axis) -> <Dim<[usize; 4]> as Dimension>::Smaller
[src]
impl Dimension for Dim<[usize; 5]>
[src]
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]>
fn ndim(&self) -> usize
[src]
fn into_pattern(self) -> <Dim<[usize; 5]> as Dimension>::Pattern
[src]
fn slice(&self) -> &[usize]ⓘ
[src]
fn slice_mut(&mut self) -> &mut [usize]ⓘ
[src]
fn zeros(ndim: usize) -> Dim<[usize; 5]>
[src]
fn insert_axis(&self, axis: Axis) -> <Dim<[usize; 5]> as Dimension>::Larger
[src]
fn try_remove_axis(&self, axis: Axis) -> <Dim<[usize; 5]> as Dimension>::Smaller
[src]
impl Dimension for Dim<[usize; 6]>
[src]
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>
fn ndim(&self) -> usize
[src]
fn into_pattern(self) -> <Dim<[usize; 6]> as Dimension>::Pattern
[src]
fn slice(&self) -> &[usize]ⓘ
[src]
fn slice_mut(&mut self) -> &mut [usize]ⓘ
[src]
fn zeros(ndim: usize) -> Dim<[usize; 6]>
[src]
fn insert_axis(&self, axis: Axis) -> <Dim<[usize; 6]> as Dimension>::Larger
[src]
fn try_remove_axis(&self, axis: Axis) -> <Dim<[usize; 6]> as Dimension>::Smaller
[src]
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.
const NDIM: Option<usize>
[src]
type SliceArg = [SliceOrIndex]
type Pattern = Dim<IxDynImpl>
type Smaller = Dim<IxDynImpl>
type Larger = Dim<IxDynImpl>
fn ndim(&self) -> usize
[src]
fn slice(&self) -> &[usize]ⓘ
[src]
fn slice_mut(&mut self) -> &mut [usize]ⓘ
[src]
fn into_pattern(self) -> <Dim<IxDynImpl> as Dimension>::Pattern
[src]
fn zeros(ndim: usize) -> Dim<IxDynImpl>
[src]
fn insert_axis(&self, axis: Axis) -> <Dim<IxDynImpl> as Dimension>::Larger
[src]
fn try_remove_axis(&self, axis: Axis) -> <Dim<IxDynImpl> as Dimension>::Smaller
[src]
fn from_dimension<D2>(d: &D2) -> Option<Dim<IxDynImpl>> where
D2: Dimension,
[src]
D2: Dimension,