toqito.matrix_props.is_positive_definite
- toqito.matrix_props.is_positive_definite(mat, rtol=1e-05, atol=1e-08)[source]
Check if matrix is positive definite (PD) [WikPD].
Examples
Consider the following matrix
\[\begin{split}A = \begin{pmatrix} 2 & -1 & 0 \\ -1 & 2 & -1 \\ 0 & -1 & 2 \end{pmatrix}\end{split}\]our function indicates that this is indeed a positive definite matrix.
>>> from toqito.matrix_props import is_positive_definite >>> import numpy as np >>> A = np.array([[2, -1, 0], [-1, 2, -1], [0, -1, 2]]) >>> is_positive_definite(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 definite.
>>> from toqito.matrix_props import is_positive_definite >>> import numpy as np >>> B = np.array([[-1, -1], [-1, -1]]) >>> is_positive_definite(B) False
See also
References
[WikPD]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
Trueif matrix is positive definite, andFalseotherwise.