matrix_props.is_nonnegative¶
Checks if the matrix is nonnegative or doubly nonnegative.
Functions¶
|
Check if the matrix is nonnegative. |
Module Contents¶
- matrix_props.is_nonnegative.is_nonnegative(input_mat, mat_type='nonnegative')¶
Check if the matrix is nonnegative.
When all the entries in the matrix are larger than or equal to zero the matrix of interest is a nonnegative matrix [1].
When a matrix is nonegative and positive semidefinite [1], the matrix is doubly nonnegative.
Examples
We expect an identity matrix to be nonnegative.
>>> import numpy as np >>> from toqito.matrix_props import is_nonnegative >>> is_nonnegative(np.identity(3)) True >>> is_nonnegative(np.identity(3), "doubly") True >>> is_nonnegative(np.identity(3), "nonnegative") True
References
[1]Wikipedia. Nonnegative matrix. URL: https://en.wikipedia.org/wiki/Nonnegative_matrix.
[2]Wikipedia. Definite matrix. URL: https://en.wikipedia.org/wiki/Definite_matrix.
- Parameters:
input_mat (numpy.ndarray) – np.ndarray Matrix of interest.
mat_type (str) – Type of nonnegative matrix.
"nonnegative"
for a nonnegative matrix and"doubly"
for a doubly nonnegative matrix.
- Raises:
TypeError – If something other than
"doubly"`or :code:
”nonnegative”` is used format_type
.- Return type:
bool