numpy
  1. numpy-numpymatlibidentity

numpy.matlib.identity() - ( Matrix Operations with NumPy )

Heading h2

Syntax

numpy.matlib.identity(n, dtype=None)

Example

import numpy.matlib 
import numpy as np 

# printing the identity matrix of size 3 
print(np.matlib.identity(3, dtype = float )) 

Output

[[1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]]

Explanation

The numpy.matlib.identity() function returns the identity matrix of the given size. An identity matrix is a square matrix with 1's on the diagonal and 0's elsewhere.

The function takes two arguments: n (integer) which denotes the number of rows and columns of the identity matrix and dtype (optional) which denotes the data type of the output.

Use

The numpy.matlib.identity() function can be used to create an identity matrix of any given size. It is widely used in linear algebra and matrix operations.

Important Points

  • The numpy.matlib.identity() function returns the identity matrix of the given size.
  • An identity matrix is a square matrix with 1's on the diagonal and 0's elsewhere.
  • The function takes two arguments: n (integer) which denotes the number of rows and columns of the identity matrix and dtype (optional) which denotes the data type of the output.

Summary

In conclusion, the numpy.matlib.identity() function is used to create an identity matrix of any given size. It returns a square matrix with 1's on the diagonal and 0's elsewhere. It is widely used in linear algebra and matrix operations and helps simplify complex mathematical computations.

Published on: