cupy.diag#
- cupy.diag(v, k=0)[source]#
Returns a diagonal or a diagonal array.
- Parameters:
v (array-like) – Array or array-like object.
k (int) – Index of diagonals. Zero indicates the main diagonal, a positive value an upper diagonal, and a negative value a lower diagonal.
- Returns:
If
v
indicates a 1-D array, then it returns a 2-D array with the specified diagonal filled byv
. Ifv
indicates a 2-D array, then it returns the specified diagonal ofv
. In latter case, ifv
is acupy.ndarray
object, then its view is returned.- Return type:
See also