Macro ndarray::stack

source ยท
macro_rules! stack {
    ($axis:expr, $( $array:expr ),+ ,) => { ... };
    ($axis:expr, $( $array:expr ),+ ) => { ... };
}
Expand description

Stack arrays along the new axis.

Uses the stack() function, calling ArrayView::from(&a) on each argument a.

Panics if the stack function would return an error.

extern crate ndarray;

use ndarray::{arr2, arr3, stack, Axis};


let a = arr2(&[[1., 2.],
               [3., 4.]]);
assert_eq!(
    stack![Axis(0), a, a],
    arr3(&[[[1., 2.],
            [3., 4.]],
           [[1., 2.],
            [3., 4.]]]),
);
assert_eq!(
    stack![Axis(1), a, a,],
    arr3(&[[[1., 2.],
            [1., 2.]],
           [[3., 4.],
            [3., 4.]]]),
);
assert_eq!(
    stack![Axis(2), a, a],
    arr3(&[[[1., 1.],
            [2., 2.]],
           [[3., 3.],
            [4., 4.]]]),
);