![]() |
VOOZH | about |
numpy.identity() function is used to create an identity matrix which is used to make identity matrix. This is commonly used in linear algebra and numerical computations. It has the following properties:
Syntax: numpy.identity(n, dtype=None)
where:
In the below example we use numpy.identity() to create identity matrices of size 2x2 and 4x4 with 1s on the diagonal and 0s elsewhere. The dtype=float specifies that the matrix elements should be float type.
Output :
It is useful for linear algebra operations like matrix multiplication, transformations and solving equations.