Skip to main content
`Ctrl`+`K`

# numpy.matlib.identity

matlib.identity(n, dtype=None)

  Returns the square identity matrix of given size.

  Parameters:
    n int

      Size of the returned identity matrix.

    dtype data-type, optional

      Data-type of the output. Defaults to `float`.

  Returns:
    out matrix

      n x n matrix 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=np.int_)
      matrix([[1, 0, 0],
              [0, 1, 0],
              [0, 0, 1]])