matrix_props.is_symmetric

Is matrix a symmetric matrix.

Module Contents

Functions

is_symmetric(mat[, rtol, atol])

Determine if a matrix is symmetric [1].

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

Determine if a matrix is symmetric [1].

The following 3x3 matrix is an example of a symmetric matrix:

\[\begin{split}\begin{pmatrix} 1 & 7 & 3 \\ 7 & 4 & -5 \\ 3 &-5 & 6 \end{pmatrix}\end{split}\]

Examples

Consider the following matrix

\[\begin{split}A = \begin{pmatrix} 1 & 7 & 3 \\ 7 & 4 & -5 \\ 3 & -5 & 6 \end{pmatrix}\end{split}\]

our function indicates that this is indeed a symmetric matrix.

>>> from toqito.matrix_props import is_symmetric
>>> import numpy as np
>>> A = np.array([[1, 7, 3], [7, 4, -5], [3, -5, 6]])
>>> is_symmetric(A)
True

Alternatively, the following example matrix \(B\) defined as

\[\begin{split}B = \begin{pmatrix} 1 & 2 \\ 4 & 5 \end{pmatrix}\end{split}\]

is not symmetric.

>>> from toqito.matrix_props import is_symmetric
>>> import numpy as np
>>> B = np.array([[1, 2], [3, 4]])
>>> is_symmetric(B)
False

References

[1] (1,2)

Wikipedia. Symmetric matrix. https://en.wikipedia.org/wiki/Symmetric_matrix.

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 symmetric and False otherwise.

Return type:

bool