toqito.matrix_props.is_normal

Checks if the matrix is a normal matrix.

Module Contents

toqito.matrix_props.is_normal.is_normal(mat, rtol=1e-05, atol=1e-08)[source]

Determine if a matrix is normal [@WikiNorm].

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

[
A = begin{pmatrix}

1 & 0 & 0 & 0 \ 0 & 1 & 0 & 0 \ 0 & 0 & 1 & 0 \ 0 & 0 & 0 & 1

end{pmatrix}

]

our function indicates that this is indeed a normal matrix.

```python exec=”1” source=”above” import numpy as np from toqito.matrix_props import is_normal

A = np.identity(4)

print(is_normal(A)) ```

Alternatively, the following example matrix (B) defined as

[
B = begin{pmatrix}

1 & 2 & 3 \ 4 & 5 & 6 \ 7 & 8 & 9

end{pmatrix}

]

is not normal.

```python exec=”1” source=”above” import numpy as np from toqito.matrix_props import is_normal

B = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

print(is_normal(B)) ```

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

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

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

Returns:

Returns True if the matrix is normal and False otherwise.

Return type:

bool