extendr_api::prelude

Function arr3

Source
pub fn arr3<A, V, U>(xs: &[V]) -> ArrayBase<OwnedRepr<A>, Dim<[usize; 3]>>
where A: Clone, V: FixedInitializer<Elem = U> + Clone, U: FixedInitializer<Elem = A> + Clone,
Expand description

Create a three-dimensional array with elements from xs.

Panics if the slices are not all of the same length.

use ndarray::arr3;

let a = arr3(&[[[1, 2],
                [3, 4]],
               [[5, 6],
                [7, 8]],
               [[9, 0],
                [1, 2]]]);
assert!(
    a.shape() == [3, 2, 2]
);