bundles / scipy 1.17.1 / scipy / sparse / _construct / block_diag
function
scipy.sparse._construct:block_diag
Signature
def block_diag ( mats , format = None , dtype = None ) Summary
Build a block diagonal sparse matrix or array from provided matrices.
Parameters
mats: sequence of matrices or arraysInput matrices or arrays.
format: str, optionalThe sparse format of the result (e.g., "csr"). If not given, the result is returned in "coo" format.
dtype: dtype specifier, optionalThe data-type of the output. If not given, the dtype is determined from that of
blocks.
Returns
res: sparse matrix or arrayIf at least one input is a sparse array, the output is a sparse array. Otherwise the output is a sparse matrix.
Notes
Examples
from scipy.sparse import coo_array, block_diag A = coo_array([[1, 2], [3, 4]]) B = coo_array([[5], [6]]) C = coo_array([[7]]) block_diag((A, B, C)).toarray()✓
See also
Aliases
-
scipy.sparse.block_diag