pub fn vstack<'a, T>(
arrays: &[&'a dyn SparseArray<T>],
format: &str,
) -> SparseResult<Box<dyn SparseArray<T>>>
Expand description
Stack sparse arrays vertically (row wise)
§Arguments
arrays
- A slice of sparse arrays to stackformat
- Format of the output array (“csr” or “coo”)
§Returns
A sparse array as a result of vertically stacking the input arrays
§Examples
use scirs2_sparse::construct::eye_array;
use scirs2_sparse::combine::vstack;
let a: Box<dyn scirs2_sparse::SparseArray<f64>> = eye_array(2, "csr").unwrap();
let b: Box<dyn scirs2_sparse::SparseArray<f64>> = eye_array(2, "csr").unwrap();
let c = vstack(&[&*a, &*b], "csr").unwrap();
assert_eq!(c.shape(), (4, 2));
assert_eq!(c.get(0, 0), 1.0);
assert_eq!(c.get(1, 1), 1.0);
assert_eq!(c.get(2, 0), 1.0);
assert_eq!(c.get(3, 1), 1.0);