cupyx.scipy.sparse.hstack#
- cupyx.scipy.sparse.hstack(blocks, format=None, dtype=None)[source]#
Stacks sparse arrays/matrices horizontally (column wise).
- Parameters:
blocks (sequence of cupyx.scipy.sparse) – sparse objects to stack.
format (str) – sparse format of the result (e.g.
'csr'). By default an appropriate sparse format is returned. This choice is subject to change.dtype (dtype, optional) – The data-type of the output. If not given, the dtype is determined from that of
blocks.
- Returns:
The stacked sparse object. Returns a sparse array when any input is a sparse array, else a sparse matrix (matches scipy).
- Return type:
cupyx.scipy.sparse
See also
Examples
>>> from cupy import array >>> from cupyx.scipy.sparse import csr_matrix, hstack >>> A = csr_matrix(array([[1., 2.], [3., 4.]])) >>> B = csr_matrix(array([[5.], [6.]])) >>> hstack([A, B]).toarray() array([[1., 2., 5.], [3., 4., 6.]])