colour.algebra.matrix Module

Matrix Helpers

Defines matrices computation helpers objects.

colour.algebra.matrix.is_identity(x, n=3)[source]

Returns if given array_like variable \(x\) is an identity matrix.

Parameters:
  • x (array_like, (N)) – Variable \(x\) to test.
  • n (int, optional) – Matrix dimension.
Returns:

Is identity matrix.

Return type:

bool

Examples

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