Macro ndarray::prelude::array

source ·
macro_rules! array {
    ($([$([$($x:expr),* $(,)*]),+ $(,)*]),+ $(,)*) => { ... };
    ($([$($x:expr),* $(,)*]),+ $(,)*) => { ... };
    ($($x:expr),* $(,)*) => { ... };
}
Expand description

Create an Array with one, two or three dimensions.

use ndarray::array;
let a1 = array![1, 2, 3, 4];

let a2 = array![[1, 2],
                [3, 4]];

let a3 = array![[[1, 2], [3, 4]],
                [[5, 6], [7, 8]]];

assert_eq!(a1.shape(), &[4]);
assert_eq!(a2.shape(), &[2, 2]);
assert_eq!(a3.shape(), &[2, 2, 2]);

This macro uses vec![], and has the same ownership semantics; elements are moved into the resulting Array.

Use array![...].into_shared() to create an ArcArray.