identity

Generates an identity matrix of the specified size.

An identity matrix is a square matrix with ones on the diagonal and zeros elsewhere.

Return

A square matrix of size n x n, where all diagonal elements are 1 and all non-diagonal elements are 0.

Parameters

n

The size of the identity matrix (number of rows and columns). Must be a positive integer.