pub struct Dim<I: ?Sized> { /* private fields */ }Expand description
Dimension description.
Dim describes the number of axes and the length of each axis
in an array. It is also used as an index type.
See also the Dimension trait for its methods and
operations.
§Examples
To create an array with a particular dimension, you’d just pass
a tuple (in this example (3, 2) is used), which is converted to
Dim by the array constructor.
use ndarray::Array2;
use ndarray::Dim;
let mut array = Array2::zeros((3, 2));
array[[0, 0]] = 1.;
assert_eq!(array.raw_dim(), Dim([3, 2]));Implementations§
Trait Implementations§
Source§impl<'a, I> AddAssign<&'a Dim<I>> for Dim<I>
impl<'a, I> AddAssign<&'a Dim<I>> for Dim<I>
Source§fn add_assign(&mut self, rhs: &Self)
fn add_assign(&mut self, rhs: &Self)
Performs the
+= operation. Read moreSource§impl AddAssign<usize> for Dim<[Ix; 1]>
impl AddAssign<usize> for Dim<[Ix; 1]>
Source§fn add_assign(&mut self, rhs: Ix)
fn add_assign(&mut self, rhs: Ix)
Performs the
+= operation. Read moreSource§impl<I> AddAssign for Dim<I>
impl<I> AddAssign for Dim<I>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreSource§impl<'de, I> Deserialize<'de> for Dim<I>where
I: Deserialize<'de>,
Available on crate feature serde only.Requires crate feature "serde"
impl<'de, I> Deserialize<'de> for Dim<I>where
I: Deserialize<'de>,
Available on crate feature
serde only.Requires crate feature "serde"
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Dimension for Dim<[Ix; 0]>
impl Dimension for Dim<[Ix; 0]>
Source§const NDIM: Option<usize>
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.Source§fn into_pattern(self) -> Self::Pattern
fn into_pattern(self) -> Self::Pattern
Convert the dimension into a pattern matching friendly value.
Source§fn zeros(ndim: usize) -> Self
fn zeros(ndim: usize) -> Self
Creates a dimension of all zeros with the specified ndim. Read more
Source§fn size_checked(&self) -> Option<usize>
fn size_checked(&self) -> Option<usize>
Compute the size while checking for overflow.
Source§fn as_array_view(&self) -> ArrayView1<'_, Ix>
fn as_array_view(&self) -> ArrayView1<'_, Ix>
Borrow as a read-only array view.
Source§fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
Borrow as a read-write array view.
Source§impl Dimension for Dim<[Ix; 1]>
impl Dimension for Dim<[Ix; 1]>
Source§const NDIM: Option<usize>
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.Source§fn into_pattern(self) -> Self::Pattern
fn into_pattern(self) -> Self::Pattern
Convert the dimension into a pattern matching friendly value.
Source§fn zeros(ndim: usize) -> Self
fn zeros(ndim: usize) -> Self
Creates a dimension of all zeros with the specified ndim. Read more
Source§fn size_checked(&self) -> Option<usize>
fn size_checked(&self) -> Option<usize>
Compute the size while checking for overflow.
Source§fn as_array_view(&self) -> ArrayView1<'_, Ix>
fn as_array_view(&self) -> ArrayView1<'_, Ix>
Borrow as a read-only array view.
Source§fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
Borrow as a read-write array view.
Source§impl Dimension for Dim<[Ix; 2]>
impl Dimension for Dim<[Ix; 2]>
Source§const NDIM: Option<usize>
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.Source§type Pattern = (usize, usize)
type Pattern = (usize, usize)
Pattern matching friendly form of the dimension value. Read more
Source§fn into_pattern(self) -> Self::Pattern
fn into_pattern(self) -> Self::Pattern
Convert the dimension into a pattern matching friendly value.
Source§fn zeros(ndim: usize) -> Self
fn zeros(ndim: usize) -> Self
Creates a dimension of all zeros with the specified ndim. Read more
Source§fn size_checked(&self) -> Option<usize>
fn size_checked(&self) -> Option<usize>
Compute the size while checking for overflow.
Source§fn as_array_view(&self) -> ArrayView1<'_, Ix>
fn as_array_view(&self) -> ArrayView1<'_, Ix>
Borrow as a read-only array view.
Source§fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
Borrow as a read-write array view.
Source§impl Dimension for Dim<[Ix; 3]>
impl Dimension for Dim<[Ix; 3]>
Source§const NDIM: Option<usize>
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.Source§type Pattern = (usize, usize, usize)
type Pattern = (usize, usize, usize)
Pattern matching friendly form of the dimension value. Read more
Source§fn into_pattern(self) -> Self::Pattern
fn into_pattern(self) -> Self::Pattern
Convert the dimension into a pattern matching friendly value.
Source§fn zeros(ndim: usize) -> Self
fn zeros(ndim: usize) -> Self
Creates a dimension of all zeros with the specified ndim. Read more
Source§fn size_checked(&self) -> Option<usize>
fn size_checked(&self) -> Option<usize>
Compute the size while checking for overflow.
Source§fn as_array_view(&self) -> ArrayView1<'_, Ix>
fn as_array_view(&self) -> ArrayView1<'_, Ix>
Borrow as a read-only array view.
Source§fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
Borrow as a read-write array view.
Source§impl Dimension for Dim<[Ix; 4]>
impl Dimension for Dim<[Ix; 4]>
Source§const NDIM: Option<usize>
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.Source§type Pattern = (usize, usize, usize, usize)
type Pattern = (usize, usize, usize, usize)
Pattern matching friendly form of the dimension value. Read more
Source§fn into_pattern(self) -> Self::Pattern
fn into_pattern(self) -> Self::Pattern
Convert the dimension into a pattern matching friendly value.
Source§fn zeros(ndim: usize) -> Self
fn zeros(ndim: usize) -> Self
Creates a dimension of all zeros with the specified ndim. Read more
Source§fn size_checked(&self) -> Option<usize>
fn size_checked(&self) -> Option<usize>
Compute the size while checking for overflow.
Source§fn as_array_view(&self) -> ArrayView1<'_, Ix>
fn as_array_view(&self) -> ArrayView1<'_, Ix>
Borrow as a read-only array view.
Source§fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
Borrow as a read-write array view.
Source§impl Dimension for Dim<[Ix; 5]>
impl Dimension for Dim<[Ix; 5]>
Source§const NDIM: Option<usize>
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.Source§type Pattern = (usize, usize, usize, usize, usize)
type Pattern = (usize, usize, usize, usize, usize)
Pattern matching friendly form of the dimension value. Read more
Source§fn into_pattern(self) -> Self::Pattern
fn into_pattern(self) -> Self::Pattern
Convert the dimension into a pattern matching friendly value.
Source§fn zeros(ndim: usize) -> Self
fn zeros(ndim: usize) -> Self
Creates a dimension of all zeros with the specified ndim. Read more
Source§fn size_checked(&self) -> Option<usize>
fn size_checked(&self) -> Option<usize>
Compute the size while checking for overflow.
Source§fn as_array_view(&self) -> ArrayView1<'_, Ix>
fn as_array_view(&self) -> ArrayView1<'_, Ix>
Borrow as a read-only array view.
Source§fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
Borrow as a read-write array view.
Source§impl Dimension for Dim<[Ix; 6]>
impl Dimension for Dim<[Ix; 6]>
Source§const NDIM: Option<usize>
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.Source§type Pattern = (usize, usize, usize, usize, usize, usize)
type Pattern = (usize, usize, usize, usize, usize, usize)
Pattern matching friendly form of the dimension value. Read more
Source§fn into_pattern(self) -> Self::Pattern
fn into_pattern(self) -> Self::Pattern
Convert the dimension into a pattern matching friendly value.
Source§fn zeros(ndim: usize) -> Self
fn zeros(ndim: usize) -> Self
Creates a dimension of all zeros with the specified ndim. Read more
Source§fn size_checked(&self) -> Option<usize>
fn size_checked(&self) -> Option<usize>
Compute the size while checking for overflow.
Source§fn as_array_view(&self) -> ArrayView1<'_, Ix>
fn as_array_view(&self) -> ArrayView1<'_, Ix>
Borrow as a read-only array view.
Source§fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>
Borrow as a read-write array view.
Source§impl<'a, I> MulAssign<&'a Dim<I>> for Dim<I>
impl<'a, I> MulAssign<&'a Dim<I>> for Dim<I>
Source§fn mul_assign(&mut self, rhs: &Self)
fn mul_assign(&mut self, rhs: &Self)
Performs the
*= operation. Read moreSource§impl<I> MulAssign<usize> for Dim<I>
impl<I> MulAssign<usize> for Dim<I>
Source§fn mul_assign(&mut self, rhs: Ix)
fn mul_assign(&mut self, rhs: Ix)
Performs the
*= operation. Read moreSource§impl<I> MulAssign for Dim<I>
impl<I> MulAssign for Dim<I>
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*= operation. Read moreSource§impl RemoveAxis for Dim<[Ix; 1]>
impl RemoveAxis for Dim<[Ix; 1]>
Source§fn remove_axis(&self, axis: Axis) -> Ix0
fn remove_axis(&self, axis: Axis) -> Ix0
Remove the specified axis from a dimension.
Source§impl RemoveAxis for Dim<[Ix; 2]>
impl RemoveAxis for Dim<[Ix; 2]>
Source§fn remove_axis(&self, axis: Axis) -> Ix1
fn remove_axis(&self, axis: Axis) -> Ix1
Remove the specified axis from a dimension.
Source§impl RemoveAxis for Dim<[Ix; 3]>
impl RemoveAxis for Dim<[Ix; 3]>
Source§fn remove_axis(&self, axis: Axis) -> Self::Smaller
fn remove_axis(&self, axis: Axis) -> Self::Smaller
Remove the specified axis from a dimension.
Source§impl RemoveAxis for Dim<[Ix; 4]>
impl RemoveAxis for Dim<[Ix; 4]>
Source§fn remove_axis(&self, axis: Axis) -> Self::Smaller
fn remove_axis(&self, axis: Axis) -> Self::Smaller
Remove the specified axis from a dimension.
Source§impl RemoveAxis for Dim<[Ix; 5]>
impl RemoveAxis for Dim<[Ix; 5]>
Source§fn remove_axis(&self, axis: Axis) -> Self::Smaller
fn remove_axis(&self, axis: Axis) -> Self::Smaller
Remove the specified axis from a dimension.
Source§impl RemoveAxis for Dim<[Ix; 6]>
impl RemoveAxis for Dim<[Ix; 6]>
Source§fn remove_axis(&self, axis: Axis) -> Self::Smaller
fn remove_axis(&self, axis: Axis) -> Self::Smaller
Remove the specified axis from a dimension.
Source§impl RemoveAxis for Dim<IxDynImpl>
impl RemoveAxis for Dim<IxDynImpl>
Source§fn remove_axis(&self, axis: Axis) -> Self
fn remove_axis(&self, axis: Axis) -> Self
Remove the specified axis from a dimension.
Source§impl<I> Serialize for Dim<I>where
I: Serialize,
Available on crate feature serde only.Requires crate feature "serde"
impl<I> Serialize for Dim<I>where
I: Serialize,
Available on crate feature
serde only.Requires crate feature "serde"
Source§impl<'a, I> SubAssign<&'a Dim<I>> for Dim<I>
impl<'a, I> SubAssign<&'a Dim<I>> for Dim<I>
Source§fn sub_assign(&mut self, rhs: &Self)
fn sub_assign(&mut self, rhs: &Self)
Performs the
-= operation. Read moreSource§impl SubAssign<usize> for Dim<[Ix; 1]>
impl SubAssign<usize> for Dim<[Ix; 1]>
Source§fn sub_assign(&mut self, rhs: Ix)
fn sub_assign(&mut self, rhs: Ix)
Performs the
-= operation. Read moreSource§impl<I> SubAssign for Dim<I>
impl<I> SubAssign for Dim<I>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreimpl<I: Copy + ?Sized> Copy for Dim<I>
impl<I: Eq + ?Sized> Eq for Dim<I>
impl NdIndex<Dim<[usize; 0]>> for [Ix; 0]
impl NdIndex<Dim<[usize; 0]>> for ()
impl NdIndex<Dim<[usize; 1]>> for [Ix; 1]
impl NdIndex<Dim<[usize; 1]>> for Ix
impl NdIndex<Dim<[usize; 2]>> for [Ix; 2]
impl NdIndex<Dim<[usize; 2]>> for (Ix, Ix)
impl NdIndex<Dim<[usize; 3]>> for [Ix; 3]
impl NdIndex<Dim<[usize; 3]>> for (Ix, Ix, Ix)
impl NdIndex<Dim<[usize; 4]>> for [Ix; 4]
impl NdIndex<Dim<[usize; 4]>> for (Ix, Ix, Ix, Ix)
impl NdIndex<Dim<[usize; 5]>> for [Ix; 5]
impl NdIndex<Dim<[usize; 5]>> for (Ix, Ix, Ix, Ix, Ix)
impl NdIndex<Dim<[usize; 6]>> for [Ix; 6]
impl NdIndex<Dim<[usize; 6]>> for (Ix, Ix, Ix, Ix, Ix, Ix)
impl NdIndex<Dim<IxDynImpl>> for &[Ix]
impl NdIndex<Dim<IxDynImpl>> for &IxDyn
impl<const N: usize> NdIndex<Dim<IxDynImpl>> for [Ix; N]
impl<const N: usize> NdIndex<Dim<IxDynImpl>> for Dim<[Ix; N]>
impl NdIndex<Dim<IxDynImpl>> for Ix
impl<I: ?Sized> StructuralPartialEq for Dim<I>
Auto Trait Implementations§
impl<I> Freeze for Dim<I>
impl<I> RefUnwindSafe for Dim<I>where
I: RefUnwindSafe + ?Sized,
impl<I> Send for Dim<I>
impl<I> Sync for Dim<I>
impl<I> Unpin for Dim<I>
impl<I> UnwindSafe for Dim<I>where
I: UnwindSafe + ?Sized,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<D> IntoDimension for Dwhere
D: Dimension,
impl<D> IntoDimension for Dwhere
D: Dimension,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ShapeArg for Twhere
T: IntoDimension,
impl<T> ShapeArg for Twhere
T: IntoDimension,
Source§impl<T> ShapeBuilder for Twhere
T: IntoDimension,
impl<T> ShapeBuilder for Twhere
T: IntoDimension,
Source§type Dim = <T as IntoDimension>::Dim
type Dim = <T as IntoDimension>::Dim
The type that captures the built shape’s dimensionality.
Source§fn into_shape_with_order(self) -> Shape<<T as ShapeBuilder>::Dim>
fn into_shape_with_order(self) -> Shape<<T as ShapeBuilder>::Dim>
Turn into a contiguous-element
Shape.Source§fn f(self) -> Shape<<T as ShapeBuilder>::Dim>
fn f(self) -> Shape<<T as ShapeBuilder>::Dim>
Convert into a Fortran-order (a.k.a., column-order)
Shape.Source§fn set_f(self, is_f: bool) -> Shape<<T as ShapeBuilder>::Dim>
fn set_f(self, is_f: bool) -> Shape<<T as ShapeBuilder>::Dim>
Set the order of the shape to either Fortran or non-Fortran.
Source§fn strides(self, st: T) -> StrideShape<<T as ShapeBuilder>::Dim>
fn strides(self, st: T) -> StrideShape<<T as ShapeBuilder>::Dim>
Set the strides of the shape.