numpy.matlib.identity
- 
matlib.identity(n, dtype=None)[source] - 
Returns the square identity matrix of given size.
- Parameters
 - 
- 
nint - 
Size of the returned identity matrix.
 - 
dtypedata-type, optional - 
Data-type of the output. Defaults to
float. 
 - 
 - Returns
 - 
- 
outmatrix - 
nxnmatrix with its main diagonal set to one, and all other elements zero. 
 - 
 
See also
- 
 
numpy.identity - 
Equivalent array function.
 - 
 
matlib.eye - 
More general matrix identity function.
 
Examples
>>> import numpy.matlib >>> np.matlib.identity(3, dtype=int) matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) 
    © 2005–2021 NumPy Developers
Licensed under the 3-clause BSD License.
    https://numpy.org/doc/1.21/reference/generated/numpy.matlib.identity.html