Return a 2-D array with ones on the diagonal and zeros elsewhere.
Parameters : | N : int
M : int, optional
k : int, optional
dtype : data-type, optional
|
---|---|
Returns : | I : ndarray of shape (N,M)
|
See also
Examples
>>> np.eye(2, dtype=int)
array([[1, 0],
[0, 1]])
>>> np.eye(3, k=1)
array([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 0., 0., 0.]])