vstack_1d

Function vstack_1d 

Source
pub fn vstack_1d<T>(
    arrays: &[ArrayView<'_, T, Ix1>],
) -> Result<Array<T, Ix2>, &'static str>
where T: Clone + Zero,
Expand description

Stack a sequence of 1D arrays into a 2D array

§Arguments

  • arrays - A slice of 1D arrays to stack

§Returns

A 2D array where each row contains an input array

§Examples

use ndarray::array;
use scirs2_core::ndarray_ext::manipulation::vstack_1d;

let a = array![1, 2, 3];
let b = array![4, 5, 6];
let c = array![7, 8, 9];

let stacked = vstack_1d(&[a.view(), b.view(), c.view()]).unwrap();
assert_eq!(stacked.shape(), &[3, 3]);
assert_eq!(stacked, array![[1, 2, 3], [4, 5, 6], [7, 8, 9]]);