pub fn hstack<'a, T>(
arrays: &[&'a dyn SparseArray<T>],
format: &str,
) -> SparseResult<Box<dyn SparseArray<T>>>
Expand description
Stack sparse arrays horizontally (column 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 horizontally stacking the input arrays
§Examples
use scirs2_sparse::construct::eye_array;
use scirs2_sparse::combine::hstack;
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 = hstack(&[&*a, &*b], "csr").unwrap();
assert_eq!(c.shape(), (2, 4));
assert_eq!(c.get(0, 0), 1.0);
assert_eq!(c.get(1, 1), 1.0);
assert_eq!(c.get(0, 2), 1.0);
assert_eq!(c.get(1, 3), 1.0);