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>where
Dim<I>: Dimension,
impl<'a, I> AddAssign<&'a Dim<I>> for Dim<I>where Dim<I>: Dimension,
source§fn add_assign(&mut self, rhs: &Self)
fn add_assign(&mut self, rhs: &Self)
Performs the
+=
operation. Read moresource§impl<I> AddAssign<Dim<I>> for Dim<I>where
Dim<I>: Dimension,
impl<I> AddAssign<Dim<I>> for Dim<I>where Dim<I>: Dimension,
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 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§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
.§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
.§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
.§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
.§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>where
Dim<I>: Dimension,
impl<'a, I> MulAssign<&'a Dim<I>> for Dim<I>where Dim<I>: Dimension,
source§fn mul_assign(&mut self, rhs: &Self)
fn mul_assign(&mut self, rhs: &Self)
Performs the
*=
operation. Read moresource§impl<I> MulAssign<Dim<I>> for Dim<I>where
Dim<I>: Dimension,
impl<I> MulAssign<Dim<I>> for Dim<I>where Dim<I>: Dimension,
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>where
Dim<I>: Dimension,
impl<I> MulAssign<usize> for Dim<I>where Dim<I>: Dimension,
source§fn mul_assign(&mut self, rhs: Ix)
fn mul_assign(&mut self, rhs: Ix)
Performs the
*=
operation. Read moresource§impl<I: PartialEq + ?Sized> PartialEq<Dim<I>> for Dim<I>
impl<I: PartialEq + ?Sized> PartialEq<Dim<I>> for Dim<I>
source§impl RemoveAxis for Dim<IxDynImpl>
impl RemoveAxis for Dim<IxDynImpl>
fn remove_axis(&self, axis: Axis) -> Self
source§impl<T, Dout> SliceArg<Dim<[usize; 0]>> for SliceInfo<T, Ix0, Dout>where
T: AsRef<[SliceInfoElem]>,
Dout: Dimension,
impl<T, Dout> SliceArg<Dim<[usize; 0]>> for SliceInfo<T, Ix0, Dout>where T: AsRef<[SliceInfoElem]>, Dout: Dimension,
source§impl<T, Dout> SliceArg<Dim<[usize; 1]>> for SliceInfo<T, Ix1, Dout>where
T: AsRef<[SliceInfoElem]>,
Dout: Dimension,
impl<T, Dout> SliceArg<Dim<[usize; 1]>> for SliceInfo<T, Ix1, Dout>where T: AsRef<[SliceInfoElem]>, Dout: Dimension,
source§impl<T, Dout> SliceArg<Dim<[usize; 2]>> for SliceInfo<T, Ix2, Dout>where
T: AsRef<[SliceInfoElem]>,
Dout: Dimension,
impl<T, Dout> SliceArg<Dim<[usize; 2]>> for SliceInfo<T, Ix2, Dout>where T: AsRef<[SliceInfoElem]>, Dout: Dimension,
source§impl<T, Dout> SliceArg<Dim<[usize; 3]>> for SliceInfo<T, Ix3, Dout>where
T: AsRef<[SliceInfoElem]>,
Dout: Dimension,
impl<T, Dout> SliceArg<Dim<[usize; 3]>> for SliceInfo<T, Ix3, Dout>where T: AsRef<[SliceInfoElem]>, Dout: Dimension,
source§impl<T, Dout> SliceArg<Dim<[usize; 4]>> for SliceInfo<T, Ix4, Dout>where
T: AsRef<[SliceInfoElem]>,
Dout: Dimension,
impl<T, Dout> SliceArg<Dim<[usize; 4]>> for SliceInfo<T, Ix4, Dout>where T: AsRef<[SliceInfoElem]>, Dout: Dimension,
source§impl<T, Dout> SliceArg<Dim<[usize; 5]>> for SliceInfo<T, Ix5, Dout>where
T: AsRef<[SliceInfoElem]>,
Dout: Dimension,
impl<T, Dout> SliceArg<Dim<[usize; 5]>> for SliceInfo<T, Ix5, Dout>where T: AsRef<[SliceInfoElem]>, Dout: Dimension,
source§impl<T, Dout> SliceArg<Dim<[usize; 6]>> for SliceInfo<T, Ix6, Dout>where
T: AsRef<[SliceInfoElem]>,
Dout: Dimension,
impl<T, Dout> SliceArg<Dim<[usize; 6]>> for SliceInfo<T, Ix6, Dout>where T: AsRef<[SliceInfoElem]>, Dout: Dimension,
source§impl<T, Din, Dout> SliceArg<Dim<IxDynImpl>> for SliceInfo<T, Din, Dout>where
T: AsRef<[SliceInfoElem]>,
Din: Dimension,
Dout: Dimension,
impl<T, Din, Dout> SliceArg<Dim<IxDynImpl>> for SliceInfo<T, Din, Dout>where T: AsRef<[SliceInfoElem]>, Din: Dimension, Dout: Dimension,
source§impl<'a, I> SubAssign<&'a Dim<I>> for Dim<I>where
Dim<I>: Dimension,
impl<'a, I> SubAssign<&'a Dim<I>> for Dim<I>where Dim<I>: Dimension,
source§fn sub_assign(&mut self, rhs: &Self)
fn sub_assign(&mut self, rhs: &Self)
Performs the
-=
operation. Read moresource§impl<I> SubAssign<Dim<I>> for Dim<I>where
Dim<I>: Dimension,
impl<I> SubAssign<Dim<I>> for Dim<I>where Dim<I>: Dimension,
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 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<'a> NdIndex<Dim<IxDynImpl>> for &'a [Ix]
impl<'a> NdIndex<Dim<IxDynImpl>> for &'a IxDyn
impl NdIndex<Dim<IxDynImpl>> for [Ix; 0]
impl NdIndex<Dim<IxDynImpl>> for [Ix; 1]
impl NdIndex<Dim<IxDynImpl>> for [Ix; 2]
impl NdIndex<Dim<IxDynImpl>> for [Ix; 3]
impl NdIndex<Dim<IxDynImpl>> for [Ix; 4]
impl NdIndex<Dim<IxDynImpl>> for [Ix; 5]
impl NdIndex<Dim<IxDynImpl>> for [Ix; 6]
impl NdIndex<Dim<IxDynImpl>> for Dim<[Ix; 0]>
impl NdIndex<Dim<IxDynImpl>> for Dim<[Ix; 1]>
impl NdIndex<Dim<IxDynImpl>> for Dim<[Ix; 2]>
impl NdIndex<Dim<IxDynImpl>> for Dim<[Ix; 3]>
impl NdIndex<Dim<IxDynImpl>> for Dim<[Ix; 4]>
impl NdIndex<Dim<IxDynImpl>> for Dim<[Ix; 5]>
impl NdIndex<Dim<IxDynImpl>> for Dim<[Ix; 6]>
impl NdIndex<Dim<IxDynImpl>> for Ix
impl<I: ?Sized> StructuralEq for Dim<I>
impl<I: ?Sized> StructuralPartialEq for Dim<I>
Auto Trait Implementations§
impl<I: ?Sized> RefUnwindSafe for Dim<I>where I: RefUnwindSafe,
impl<I: ?Sized> Send for Dim<I>where I: Send,
impl<I: ?Sized> Sync for Dim<I>where I: Sync,
impl<I: ?Sized> Unpin for Dim<I>where I: Unpin,
impl<I: ?Sized> UnwindSafe for Dim<I>where I: UnwindSafe,
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