pub type IxDyn = Dim<IxDynImpl>;
Expand description
dynamic-dimensional
You can use the IxDyn
function to create a dimension for an array with
dynamic number of dimensions. (Vec<usize>
and &[usize]
also implement
IntoDimension
to produce IxDyn
).
use ndarray::ArrayD;
use ndarray::IxDyn;
// Create a 5 × 6 × 3 × 4 array using the dynamic dimension type
let mut a = ArrayD::<f64>::zeros(IxDyn(&[5, 6, 3, 4]));
// Create a 1 × 3 × 4 array using the dynamic dimension type
let mut b = ArrayD::<f64>::zeros(IxDyn(&[1, 3, 4]));
// We can use broadcasting to add arrays of compatible shapes together:
a += &b;
// We can index into a, b using fixed size arrays:
a[[0, 0, 0, 0]] = 0.;
b[[0, 2, 3]] = a[[0, 0, 2, 3]];
// Note: indexing will panic at runtime if the number of indices given does
// not match the array.
// We can keep them in the same vector because both the arrays have
// the same type `Array<f64, IxDyn>` a.k.a `ArrayD<f64>`:
let arrays = vec![a, b];
Aliased Type§
struct IxDyn { /* private fields */ }
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: &Dim<I>)
fn add_assign(&mut self, rhs: &Dim<I>)
Performs the
+=
operation. Read moreSource§impl<I> AddAssign for Dim<I>
impl<I> AddAssign for Dim<I>
Source§fn add_assign(&mut self, rhs: Dim<I>)
fn add_assign(&mut self, rhs: Dim<I>)
Performs the
+=
operation. Read moreSource§impl Dimension for Dim<IxDynImpl>
impl Dimension for Dim<IxDynImpl>
IxDyn is a “dynamic” index, pretty hard to use when indexing, and memory wasteful, but it allows an arbitrary and dynamic number of axes.
Source§const NDIM: Option<usize> = None
const NDIM: Option<usize> = None
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 = Dim<IxDynImpl>
type Pattern = Dim<IxDynImpl>
Pattern matching friendly form of the dimension value. Read more
Source§fn into_pattern(self) -> <Dim<IxDynImpl> as Dimension>::Pattern
fn into_pattern(self) -> <Dim<IxDynImpl> as Dimension>::Pattern
Convert the dimension into a pattern matching friendly value.
Source§fn zeros(ndim: usize) -> Dim<IxDynImpl>
fn zeros(ndim: usize) -> Dim<IxDynImpl>
Creates a dimension of all zeros with the specified ndim. Read more
Source§fn into_dyn(self) -> Dim<IxDynImpl>
fn into_dyn(self) -> Dim<IxDynImpl>
Convert the dimensional into a dynamic dimensional (IxDyn).
Source§fn size_checked(&self) -> Option<usize>
fn size_checked(&self) -> Option<usize>
Compute the size while checking for overflow.
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: &Dim<I>)
fn mul_assign(&mut self, rhs: &Dim<I>)
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: usize)
fn mul_assign(&mut self, rhs: usize)
Performs the
*=
operation. Read moreSource§impl<I> MulAssign for Dim<I>
impl<I> MulAssign for Dim<I>
Source§fn mul_assign(&mut self, rhs: Dim<I>)
fn mul_assign(&mut self, rhs: Dim<I>)
Performs the
*=
operation. Read moreSource§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: &Dim<I>)
fn sub_assign(&mut self, rhs: &Dim<I>)
Performs the
-=
operation. Read moreSource§impl<I> SubAssign for Dim<I>
impl<I> SubAssign for Dim<I>
Source§fn sub_assign(&mut self, rhs: Dim<I>)
fn sub_assign(&mut self, rhs: Dim<I>)
Performs the
-=
operation. Read more