Type Definition ndarray::IxDyn[][src]

type IxDyn = Dim<IxDynImpl>;

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

type SliceArg = [SliceOrIndex]

SliceArg is the type which is used to specify slicing for this dimension. 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

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