Vous êtes un professionnel et vous avez besoin d'une formation ?
Programmation Python
Les fondamentaux
Voir le programme détaillé
Module « scipy.sparse »
Signature de la fonction block_diag
def block_diag(mats, format=None, dtype=None)
Description
help(scipy.sparse.block_diag)
Build a block diagonal sparse matrix or array from provided matrices.
Parameters
----------
mats : sequence of matrices or arrays
Input matrices or arrays.
format : str, optional
The sparse format of the result (e.g., "csr"). If not given, the result
is returned in "coo" format.
dtype : dtype specifier, optional
The data-type of the output. If not given, the dtype is
determined from that of `blocks`.
Returns
-------
res : sparse matrix or array
If at least one input is a sparse array, the output is a sparse array.
Otherwise the output is a sparse matrix.
Notes
-----
.. versionadded:: 0.11.0
See Also
--------
block_array
diags_array
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()
array([[1, 2, 0, 0],
[3, 4, 0, 0],
[0, 0, 5, 0],
[0, 0, 6, 0],
[0, 0, 0, 7]])
Vous êtes un professionnel et vous avez besoin d'une formation ?
Programmation Python
Les fondamentaux
Voir le programme détaillé
Améliorations / Corrections
Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.
Emplacement :
Description des améliorations :