Skip to content

pymath.identity

Daniel Flassig edited this page Jun 24, 2026 · 1 revision

Creates the n × n identity matrix.

This function is located in the pymath module. See pymath for the matrix representation.

I = pymath.identity(n)
Parameter Type Description
n integer The size of the (square) identity matrix. Must be ≥ 1.

Return value

Type Description
I A new n × n identity matrix (1 on the diagonal, 0 elsewhere).

Notes:

  • For n ≤ 10 a dense matrix is returned. For larger n a sparse matrix is returned (a size field plus one entry per row); both forms are accepted as input by the other pymath functions.

Example:

local I = pymath.identity(3)
-- I == {{1, 0, 0},
--       {0, 1, 0},
--       {0, 0, 1}}

Version Support:

Minimum PYTHA Version: V27

See also:

pymath, pymath.dot, pymath.inverse

Clone this wiki locally