toqito.matrix_props.is_normal
- toqito.matrix_props.is_normal(mat, rtol=1e-05, atol=1e-08)[source]
Determine if a matrix is normal [WikNormal].
A matrix is normal if it commutes with its adjoint
\[\begin{equation} [X, X^*] = 0, \end{equation}\]or, equivalently if
\[\begin{equation} X^* X = X X^* \end{equation}.\]Examples
Consider the following matrix
\[\begin{split}A = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\end{split}\]our function indicates that this is indeed a normal matrix.
>>> from toqito.matrix_props import is_normal >>> import numpy as np >>> A = np.identity(4) >>> is_normal(A) True
Alternatively, the following example matrix \(B\) defined as
\[\begin{split}B = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix}\end{split}\]is not normal.
>>> from toqito.matrix_props import is_normal >>> import numpy as np >>> B = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> is_normal(B) False
References
[WikNormal]Wikipedia: Normal matrix. https://en.wikipedia.org/wiki/Normal_matrix
- Parameters:
mat – The matrix to check.
rtol – The relative tolerance parameter (default 1e-05).
atol – The absolute tolerance parameter (default 1e-08).
- Returns:
Returns
Trueif the matrix is normal andFalseotherwise.