matrix_props.is_diagonally_dominant¶
Checks if the matrix is diagonally dominant.
Functions¶
|
Check if matrix is diagnal dominant (DD) [1]. |
Module Contents¶
- matrix_props.is_diagonally_dominant.is_diagonally_dominant(mat, is_strict=True)¶
Check if matrix is diagnal dominant (DD) [1].
A matrix is diagonally dominant if the matrix is square and if for every row of the matrix, the magnitude of the diagonal entry in a row is greater than or equal to the sum of the magnitudes of all the other (non-diagonal) entries in that row.
Examples
The following is an example of a 3-by-3 diagonal matrix:
\[\begin{split}A = \begin{pmatrix} 2 & -1 & 0 \\ 0 & 2 & -1 \\ 0 & -1 & 2 \end{pmatrix}\end{split}\]our function indicates that this is indeed a diagonally dominant matrix.
>>> from toqito.matrix_props import is_diagonally_dominant >>> import numpy as np >>> A = np.array([[2, -1, 0], [0, 2, -1], [0, -1, 2]]) >>> is_diagonally_dominant(A) np.True_
Alternatively, the following example matrix \(B\) defined as
\[\begin{split}B = \begin{pmatrix} -1 & 2 \\ -1 & -1 \end{pmatrix}\end{split}\]is not diagonally dominant.
>>> from toqito.matrix_props import is_diagonally_dominant >>> import numpy as np >>> B = np.array([[-1, 2], [-1, -1]]) >>> is_diagonally_dominant(B) np.False_
References
[1] (1,2)Wikipedia. Diagonally dominant matrix. URL: https://en.wikipedia.org/wiki/Diagonally_dominant_matrix.
- Parameters:
mat (numpy.ndarray) – Matrix to check.
is_strict (bool) – Whether the inequality is strict.
- Returns:
Return
True
if matrix is diagnally dominant, andFalse
otherwise.- Return type:
bool