This is a pre-release version (2.5.0.dev0+git20251130.2de293a). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / matlib / identity

function

numpy.matlib:identity

source: build-install/usr/lib/python3.14/site-packages/numpy/matlib.py :155

Signature

def   identity ( n dtype = None )

Summary

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.

Examples

import numpy.matlib
np.matlib.identity(3, dtype=int)

See also

matlib.eye

More general matrix identity function.

numpy.identity

Equivalent array function.

Aliases

  • numpy.matlib.identity