logo
pub fn stack<A, D>(
    axis: Axis,
    arrays: &[ArrayBase<ViewRepr<&A>, D>]
) -> Result<ArrayBase<OwnedRepr<A>, <D as Dimension>::Larger>, ShapeError> where
    A: Clone,
    D: Dimension,
    <D as Dimension>::Larger: RemoveAxis
Expand description

Stack arrays along the new axis.

Errors if the arrays have mismatching shapes. Errors if arrays is empty, if axis is out of bounds, if the result is larger than is possible to represent.

extern crate ndarray;

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


let a = arr2(&[[2., 2.],
               [3., 3.]]);
assert!(
    stack(Axis(0), &[a.view(), a.view()])
    == Ok(arr3(&[[[2., 2.],
                  [3., 3.]],
                 [[2., 2.],
                  [3., 3.]]]))
);