matrix_props.is_idempotent

Is the matrix idempotent.

Module Contents

Functions

is_idempotent(mat[, rtol, atol])

Check if matrix is the idempotent matrix [1].

matrix_props.is_idempotent.is_idempotent(mat, rtol=1e-05, atol=1e-08)

Check if matrix is the idempotent matrix [1].

An idempotent matrix is a square matrix, which, when multiplied by itself, yields itself. That is, the matrix \(A\) is idempotent if and only if \(A^2 = A\).

Examples

The following is an example of a \(2 x 2\) idempotent matrix:

\[\begin{split}A = \begin{pmatrix} 3 & -6 \\ 1 & -2 \end{pmatrix}\end{split}\]
>>> from toqito.matrix_props import is_idempotent
>>> import numpy as np
>>> mat = np.array([[3, -6], [1, -2]])
>>> is_idempotent(mat)
True

Alternatively, the following matrix

\[\begin{split}B = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix}\end{split}\]

is not idempotent.

>>> from toqito.matrix_props import is_idempotent
>>> import numpy as np
>>> mat = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> is_idempotent(mat)
False

References

[1] (1,2)

Wikipedia. Idempotent matrix. https://en.wikipedia.org/wiki/Idempotent_matrix.

Parameters:
  • mat (numpy.ndarray) – Matrix to check.

  • rtol (float) – The relative tolerance parameter (default 1e-05).

  • atol (float) – The absolute tolerance parameter (default 1e-08).

Returns:

Return True if matrix is the idempotent matrix, and False otherwise.

Return type:

bool