pub trait Dimension: Clone + Eq + Debug + Send + Sync + Default + IndexMut<usize, Output = usize> + Add<Self, Output = Self> + AddAssign + for<'x> AddAssign<&'x Self> + Sub<Self, Output = Self> + SubAssign + for<'x> SubAssign<&'x Self> + Mul<usize, Output = Self> + Mul<Self, Output = Self> + MulAssign + for<'x> MulAssign<&'x Self> + MulAssign<usize> {
type SliceArg: ?Sized + AsRef<[SliceOrIndex]>;
type Pattern: IntoDimension<Dim = Self>;
type Smaller: Dimension;
type Larger: Dimension;
const NDIM: Option<usize>;
fn ndim(&self) -> usize;
fn into_pattern(self) -> Self::Pattern;
fn zeros(ndim: usize) -> Self;
fn __private__(&self) -> PrivateMarker;
fn size(&self) -> usize { ... }
fn size_checked(&self) -> Option<usize> { ... }
fn as_array_view(&self) -> ArrayView1<'_, Ix> { ... }
fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix> { ... }
fn into_dyn(self) -> IxDyn { ... }
}
Expand description
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
Required Associated Types§
sourcetype SliceArg: ?Sized + AsRef<[SliceOrIndex]>
type SliceArg: ?Sized + AsRef<[SliceOrIndex]>
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.
sourcetype Pattern: IntoDimension<Dim = Self>
type Pattern: IntoDimension<Dim = Self>
Pattern matching friendly form of the dimension value.
- For
Ix1
:usize
, - For
Ix2
:(usize, usize)
- and so on..
- For
IxDyn
:IxDyn
Required Associated Constants§
Required Methods§
sourcefn into_pattern(self) -> Self::Pattern
fn into_pattern(self) -> Self::Pattern
Convert the dimension into a pattern matching friendly value.
sourcefn zeros(ndim: usize) -> Self
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
.
sourcefn __private__(&self) -> PrivateMarker
fn __private__(&self) -> PrivateMarker
This trait is private to implement; this method exists to make it impossible to implement outside the crate.
Provided Methods§
sourcefn size_checked(&self) -> Option<usize>
fn size_checked(&self) -> Option<usize>
Compute the size while checking for overflow.
sourcefn as_array_view(&self) -> ArrayView1<'_, Ix>
fn as_array_view(&self) -> ArrayView1<'_, Ix>
Borrow as a read-only array view.
sourcefn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
Borrow as a read-write array view.