This is documentation for an old release of NumPy (version 1.7.0). Read this page in the documentation of the latest stable release (version > 1.17).
Return a matrix with ones on the diagonal and zeros elsewhere.
Parameters : | n : int
M : int, optional
k : int, optional
dtype : dtype, optional
|
---|---|
Returns : | I : matrix
|
Examples
>>> import numpy.matlib
>>> np.matlib.eye(3, k=1, dtype=float)
matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 0., 0., 0.]])