pub fn concatenate_2d<T>(
arrays: &[ArrayView<'_, T, Ix2>],
axis: usize,
) -> Result<Array<T, Ix2>, &'static str>
Expand description
Concatenate 2D arrays along a specified axis
§Arguments
arrays
- A slice of 2D arrays to concatenateaxis
- The axis along which to concatenate (0 for rows, 1 for columns)
§Returns
A new array containing the concatenated arrays
§Examples
use ndarray::array;
use scirs2_core::ndarray_ext::manipulation::concatenate_2d;
let a = array![[1, 2], [3, 4]];
let b = array![[5, 6], [7, 8]];
// Concatenate along rows (vertically)
let vertical = concatenate_2d(&[a.view(), b.view()], 0).unwrap();
assert_eq!(vertical.shape(), &[4, 2]);
assert_eq!(vertical, array![[1, 2], [3, 4], [5, 6], [7, 8]]);
// Concatenate along columns (horizontally)
let horizontal = concatenate_2d(&[a.view(), b.view()], 1).unwrap();
assert_eq!(horizontal.shape(), &[2, 4]);
assert_eq!(horizontal, array![[1, 2, 5, 6], [3, 4, 7, 8]]);