pub fn split_2d<T>(
array: ArrayView<'_, T, Ix2>,
indices: &[usize],
axis: usize,
) -> Result<Vec<Array<T, Ix2>>, &'static str>
Expand description
Split a 2D array into multiple sub-arrays along a given axis
§Arguments
array
- The input 2D array to splitindices
- Indices where the array should be splitaxis
- The axis along which to split (0 for rows, 1 for columns)
§Returns
A vector of arrays resulting from the split
§Examples
use ndarray::array;
use scirs2_core::ndarray_ext::split_2d;
let a = array![[1, 2, 3, 4], [5, 6, 7, 8]];
let result = split_2d(a.view(), &[2], 1).unwrap();
assert_eq!(result.len(), 2);
assert_eq!(result[0].shape(), &[2, 2]);
assert_eq!(result[1].shape(), &[2, 2]);