toqito.matrix_props.is_positive_semidefinite

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

Check if matrix is positive semidefinite (PSD) [WikPSD].

Examples

Consider the following matrix

\[\begin{split}A = \begin{pmatrix} 1 & -1 \\ -1 & 1 \end{pmatrix}\end{split}\]

our function indicates that this is indeed a positive semidefinite matrix.

>>> from toqito.matrix_props import is_positive_semidefinite
>>> import numpy as np
>>> A = np.array([[1, -1], [-1, 1]])
>>> is_positive_semidefinite(A)
True

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

\[\begin{split}B = \begin{pmatrix} -1 & -1 \\ -1 & -1 \end{pmatrix}\end{split}\]

is not positive semidefinite.

>>> from toqito.matrix_props import is_positive_semidefinite
>>> import numpy as np
>>> B = np.array([[-1, -1], [-1, -1]])
>>> is_positive_semidefinite(B)
False

References

[WikPSD]

Wikipedia: Definiteness of a matrix. https://en.wikipedia.org/wiki/Definiteness_of_a_matrix

Parameters:
  • mat – Matrix to check.

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

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

Returns:

Return True if matrix is PSD, and False otherwise.