toqito.matrix_props.is_idempotent ================================= .. py:module:: toqito.matrix_props.is_idempotent .. autoapi-nested-parse:: Checks if the matrix is an idempotent matrix. Module Contents --------------- .. py:function:: is_idempotent(mat, rtol = 1e-05, atol = 1e-08) Check if matrix is the idempotent matrix [@WikiIdemPot]. 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\). .. rubric:: Examples The following is an example of a \(2 x 2\) idempotent matrix: \[ A = \begin{pmatrix} 3 & -6 \\ 1 & -2 \end{pmatrix} \] ```python exec="1" source="above" import numpy as np from toqito.matrix_props import is_idempotent mat = np.array([[3, -6], [1, -2]]) print(is_idempotent(mat)) ``` Alternatively, the following matrix \[ B = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix} \] is not idempotent. ```python exec="1" source="above" import numpy as np from toqito.matrix_props import is_idempotent mat = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) print(is_idempotent(mat)) ``` :param mat: Matrix to check. :param rtol: The relative tolerance parameter (default 1e-05). :param atol: The absolute tolerance parameter (default 1e-08). :returns: Return `True` if matrix is the idempotent matrix, and `False` otherwise.