Back to Numerical Arrays (NumPy)
np.fill_diagonal
Fill the main diagonal of the given array of any dimensionality.
Syntax
np.fill_diagonal(a, val, wrap?)
Description
Fill the main diagonal of the given array of any dimensionality. For an array a with a.ndim >= 2, the diagonal is the list of locations with indices a[i, i, ..., i] all identical. This function modifies the input array in-place, it does not return a value.
Parameters
| Name | Description |
|---|---|
| a | - Array to fill (modified in-place). Must be at least 2-D. |
| val | - Value to write on the diagonal |
| wrap(optional) | - For tall matrices, whether to "wrap" after filling the main diagonal |
Returns
Promise<void>