cupy.eye#

cupy.eye(N, M=None, k=0, dtype=<class 'float'>, order='C')[source]#

Returns a 2-D array with ones on the diagonals and zeros elsewhere.

Parameters:
  • N (int) – Number of rows.

  • M (int) – Number of columns. M == N by default.

  • k (int) – Index of the diagonal. Zero indicates the main diagonal, a positive index an upper diagonal, and a negative index a lower diagonal.

  • dtype – Data type specifier.

  • order ({'C', 'F'}) – Row-major (C-style) or column-major (Fortran-style) order.

Returns:

A 2-D array with given diagonals filled with ones and zeros elsewhere.

Return type:

cupy.ndarray

See also

numpy.eye()