Type Definition ndarray::IxDyn[][src]

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];

Implementations

impl IxDyn[src]

pub fn zeros(n: usize) -> IxDyn[src]

Create a new dimension value with n axes, all zeros

Trait Implementations

impl<'de> Deserialize<'de> for IxDyn[src]

Requires crate feature "serde"

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
    D: Deserializer<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

impl<D: Dimension> DimAdd<D> for IxDyn[src]

type Output = IxDyn

The sum of the two dimensions.

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

type Output = IxDyn

The resulting dimension type after broadcasting.

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

type Output = IxDyn

The resulting dimension type after broadcasting.

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

type Output = IxDyn

The resulting dimension type after broadcasting.

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

type Output = IxDyn

The resulting dimension type after broadcasting.

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

type Output = IxDyn

The resulting dimension type after broadcasting.

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

type Output = IxDyn

The resulting dimension type after broadcasting.

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

type Output = IxDyn

The resulting dimension type after broadcasting.

impl Dimension for IxDyn[src]

IxDyn is a “dynamic” index, pretty hard to use when indexing, and memory wasteful, but it allows an arbitrary and dynamic number of axes.

const NDIM: Option<usize>[src]

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. Read more

type Pattern = Self

Pattern matching friendly form of the dimension value. Read more

type Smaller = Self

Next smaller dimension (if applicable)

type Larger = Self

Next larger dimension

fn ndim(&self) -> usize[src]

Returns the number of dimensions (number of axes).

fn slice(&self) -> &[Ix]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

fn slice_mut(&mut self) -> &mut [Ix]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

fn into_pattern(self) -> Self::Pattern[src]

Convert the dimension into a pattern matching friendly value.

fn zeros(ndim: usize) -> Self[src]

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

fn insert_axis(&self, axis: Axis) -> Self::Larger[src]

fn try_remove_axis(&self, axis: Axis) -> Self::Smaller[src]

fn from_dimension<D2: Dimension>(d: &D2) -> Option<Self>[src]

fn into_dyn(self) -> IxDyn[src]

Convert the dimensional into a dynamic dimensional (IxDyn).

fn size(&self) -> usize[src]

Compute the size of the dimension (number of elements)

fn size_checked(&self) -> Option<usize>[src]

Compute the size while checking for overflow.

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

Borrow as a read-only array view.

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

Borrow as a read-write array view.

fn __private__(&self) -> PrivateMarker[src]

This trait is private to implement; this method exists to make it impossible to implement outside the crate. Read more

impl<'a> NdIndex<Dim<IxDynImpl>> for &'a IxDyn[src]

fn index_checked(&self, dim: &IxDyn, strides: &IxDyn) -> Option<isize>[src]

fn index_unchecked(&self, strides: &IxDyn) -> isize[src]

impl Serialize for IxDyn[src]

Requires crate feature "serde"

fn serialize<Se>(&self, serializer: Se) -> Result<Se::Ok, Se::Error> where
    Se: Serializer
[src]

Serialize this value into the given Serde serializer. Read more