colour.algebra.is_identity#

colour.algebra.is_identity(a: ArrayLike) bool[source]#

Determine whether the specified array \(a\) is an identity matrix.

An identity matrix is a square matrix with ones on the main diagonal and zeros elsewhere, satisfying \(I \cdot A = A \cdot I = A\) for any compatible matrix \(A\).

Parameters:

a (ArrayLike) – Array \(a\) to test for identity matrix properties.

Returns:

Whether the specified array \(a\) is an identity matrix.

Return type:

bool

Examples

>>> is_identity(np.reshape(np.array([1, 0, 0, 0, 1, 0, 0, 0, 1]), (3, 3)))
True
>>> is_identity(np.reshape(np.array([1, 2, 0, 0, 1, 0, 0, 0, 1]), (3, 3)))
False