- eye(n_rows: int, n_cols: Optional[int] = None, /, *, k: int = 0, dtype: Optional[dtype] = None, device: Optional[device] = None) array ¶
Returns a two-dimensional array with ones on the
kh diagonal and zeros elsewhere.
n_rows (int) – number of rows in the output array.
n_cols (Optional[int]) – number of columns in the output array. If
None, the default number of columns in the output array is equal to
k (int) – index of the diagonal. A positive value refers to an upper diagonal, a negative value to a lower diagonal, and
0to the main diagonal. Default:
dtype (Optional[dtype]) – output array data type. If
None, the output array data type must be the default floating-point data type. Default:
device (Optional[device]) – device on which to place the created array. Default:
out (array) – an array where all elements are equal to zero, except for the
kh diagonal, whose values are equal to one.