numpy.diagflat(v, k=0) [source]
Create a two-dimensional array with the flattened input as a diagonal.
| Parameters: |
v : array_like Input data, which is flattened and set as the k : int, optional Diagonal to set; 0, the default, corresponds to the “main” diagonal, a positive (negative) |
|---|---|
| Returns: |
out : ndarray The 2-D output array. |
See also
>>> np.diagflat([[1,2], [3,4]])
array([[1, 0, 0, 0],
[0, 2, 0, 0],
[0, 0, 3, 0],
[0, 0, 0, 4]])
>>> np.diagflat([1,2], 1)
array([[0, 1, 0],
[0, 0, 2],
[0, 0, 0]])
© 2008–2017 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.14.2/reference/generated/numpy.diagflat.html