Build a block diagonal sparse matrix from provided matrices.
Parameters : | A, B, ... : sequence of matrices
format : str, optional
dtype : dtype specifier, optional
|
---|---|
Returns : | res : sparse matrix |
Examples
>>> A = coo_matrix([[1, 2], [3, 4]])
>>> B = coo_matrix([[5], [6]])
>>> C = coo_matrix([[7]])
>>> block_diag((A, B, C)).todense()
matrix([[1, 2, 0, 0],
[3, 4, 0, 0],
[0, 0, 5, 0],
[0, 0, 6, 0],
[0, 0, 0, 7]])