xorbits.numpy.diagflat#
- xorbits.numpy.diagflat(v, k=0, sparse=None, gpu=None, chunk_size=None)[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-th diagonal of the output.
k (int, optional) – Diagonal to set; 0, the default, corresponds to the “main” diagonal, a positive (negative) k giving the number of the diagonal above (below) the main.
- Returns
out – The 2-D output array.
- Return type
ndarray
See also
Examples
>>> 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]])
- sparse: bool, optional
Create sparse tensor if True, False as default
- gpubool, optional
Allocate the tensor on GPU if True, False as default
- chunk_sizeint or tuple of int or tuple of ints, optional
Desired chunk size on each dimension
This docstring was copied from numpy.