Skip to content

Eye

Description

Eye returns the identity matrix, which can be useful in linear algebra expressions.

Syntax

Eye(n) returns the n×nn \times n square identity matrix.

Example

Eye(4) returns the 4x4 identity matrix

Source Code

Eye = LAMBDA(n, // size (rows/columns) of the output square matrix
    MAKEARRAY(n, n, LAMBDA(numrows, numcols, IF(numrows = numcols, 1, 0)))
);