is_nonnegative
¶
Checks if the matrix is nonnegative or doubly nonnegative.
is_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 2, the matrix is doubly nonnegative.
Parameters:
-
input_mat(ndarray) –Matrix of interest.
-
mat_type(str, default:'nonnegative') –Type of nonnegative matrix.
"nonnegative"for a nonnegative matrix and"doubly"for a doubly nonnegative matrix.
Returns:
-
bool–Return
Trueif matrix is nonnegative (or doubly nonnegative if specified), andFalseotherwise.
Raises:
-
TypeError–If something other than
"doubly"or"nonnegative"is used format_type.
Examples:
We expect an identity matrix to be nonnegative.
import numpy as np
from toqito.matrix_props import is_nonnegative
print(is_nonnegative(np.eye(2)))
print(is_nonnegative(np.eye(2), "doubly"))
print(is_nonnegative(np.array([[1, -1], [1, 1]])))
References
1 Wikipedia. Nonnegative matrix. link.
2 Wikipedia. Definite matrix. link.