kron
- sparse.kron(a, b)[source]
Kronecker product of 2 sparse arrays.
- Parameters:
a (SparseArray, scipy.sparse.spmatrix, or np.ndarray) – The arrays over which to compute the Kronecker product.
b (SparseArray, scipy.sparse.spmatrix, or np.ndarray) – The arrays over which to compute the Kronecker product.
- Returns:
res – The kronecker product
- Return type:
- Raises:
ValueError – If all arguments are dense or arguments have nonzero fill-values.
Examples
>>> from sparse import eye >>> a = eye(3, dtype="i8") >>> b = np.array([1, 2, 3], dtype="i8") >>> res = kron(a, b) >>> res.todense() array([[1, 2, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 2, 3, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 2, 3]], dtype=int64)