Type Alias ndarray::IxDyn

source ·
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§

source§

impl IxDyn

source

pub fn zeros(n: usize) -> IxDyn

Create a new dimension value with n axes, all zeros

Trait Implementations§

source§

impl<D: Dimension> DimAdd<D> for IxDyn

§

type Output = Dim<IxDynImpl>

The sum of the two dimensions.
source§

impl DimMax<Dim<[usize; 0]>> for IxDyn

§

type Output = Dim<IxDynImpl>

The resulting dimension type after broadcasting.
source§

impl DimMax<Dim<[usize; 1]>> for IxDyn

§

type Output = Dim<IxDynImpl>

The resulting dimension type after broadcasting.
source§

impl DimMax<Dim<[usize; 2]>> for IxDyn

§

type Output = Dim<IxDynImpl>

The resulting dimension type after broadcasting.
source§

impl DimMax<Dim<[usize; 3]>> for IxDyn

§

type Output = Dim<IxDynImpl>

The resulting dimension type after broadcasting.
source§

impl DimMax<Dim<[usize; 4]>> for IxDyn

§

type Output = Dim<IxDynImpl>

The resulting dimension type after broadcasting.
source§

impl DimMax<Dim<[usize; 5]>> for IxDyn

§

type Output = Dim<IxDynImpl>

The resulting dimension type after broadcasting.
source§

impl DimMax<Dim<[usize; 6]>> for IxDyn

§

type Output = Dim<IxDynImpl>

The resulting dimension type after broadcasting.
source§

impl Dimension for IxDyn

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

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 = Dim<IxDynImpl>

Pattern matching friendly form of the dimension value. Read more
§

type Smaller = Dim<IxDynImpl>

Next smaller dimension (if applicable)
§

type Larger = Dim<IxDynImpl>

Next larger dimension
source§

fn ndim(&self) -> usize

Returns the number of dimensions (number of axes).
source§

fn into_pattern(self) -> Self::Pattern

Convert the dimension into a pattern matching friendly value.
source§

fn zeros(ndim: usize) -> Self

Creates a dimension of all zeros with the specified ndim. Read more
source§

fn into_dyn(self) -> IxDyn

Convert the dimensional into a dynamic dimensional (IxDyn).
source§

fn size(&self) -> usize

Compute the size of the dimension (number of elements)
source§

fn size_checked(&self) -> Option<usize>

Compute the size while checking for overflow.
source§

fn as_array_view(&self) -> ArrayView1<'_, Ix>

Borrow as a read-only array view.
source§

fn as_array_view_mut(&mut self) -> ArrayViewMut1<'_, Ix>

Borrow as a read-write array view.
source§

impl<'a> NdIndex<Dim<IxDynImpl>> for &'a IxDyn

source§

impl<I> Add for Dim<I>
where Dim<I>: Dimension,

§

type Output = Dim<I>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
source§

impl<'a, I> AddAssign<&'a Dim<I>> for Dim<I>
where Dim<I>: Dimension,

source§

fn add_assign(&mut self, rhs: &Self)

Performs the += operation. Read more
source§

impl<I> AddAssign for Dim<I>
where Dim<I>: Dimension,

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl<I: Clone + ?Sized> Clone for Dim<I>

source§

fn clone(&self) -> Dim<I>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<I> Debug for Dim<I>
where I: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<I: Default + ?Sized> Default for Dim<I>

source§

fn default() -> Dim<I>

Returns the “default value” for a type. Read more
source§

impl<I: Hash + ?Sized> Hash for Dim<I>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
source§

impl Index<usize> for Dim<IxDynImpl>

§

type Output = <IxDynImpl as Index<usize>>::Output

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<usize> for Dim<IxDynImpl>

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<I> Mul<usize> for Dim<I>
where Dim<I>: Dimension,

§

type Output = Dim<I>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Ix) -> Self

Performs the * operation. Read more
source§

impl<I> Mul for Dim<I>
where Dim<I>: Dimension,

§

type Output = Dim<I>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
source§

impl<'a, I> MulAssign<&'a Dim<I>> for Dim<I>
where Dim<I>: Dimension,

source§

fn mul_assign(&mut self, rhs: &Self)

Performs the *= operation. Read more
source§

impl<I> MulAssign<usize> for Dim<I>
where Dim<I>: Dimension,

source§

fn mul_assign(&mut self, rhs: Ix)

Performs the *= operation. Read more
source§

impl<I> MulAssign for Dim<I>
where Dim<I>: Dimension,

source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
source§

impl<I> PartialEq<I> for Dim<I>
where I: PartialEq + ?Sized,

source§

fn eq(&self, rhs: &I) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<I: PartialEq + ?Sized> PartialEq for Dim<I>

source§

fn eq(&self, other: &Dim<I>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl RemoveAxis for Dim<IxDynImpl>

source§

fn remove_axis(&self, axis: Axis) -> Self

source§

impl<I> Sub for Dim<I>
where Dim<I>: Dimension,

§

type Output = Dim<I>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
source§

impl<'a, I> SubAssign<&'a Dim<I>> for Dim<I>
where Dim<I>: Dimension,

source§

fn sub_assign(&mut self, rhs: &Self)

Performs the -= operation. Read more
source§

impl<I> SubAssign for Dim<I>
where Dim<I>: Dimension,

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl<I: Copy + ?Sized> Copy for Dim<I>

source§

impl<I: Eq + ?Sized> Eq for Dim<I>

source§

impl<I: ?Sized> StructuralPartialEq for Dim<I>