matrix_props.is_nonnegative

Checks if the matrix is nonnegative or doubly nonnegative.

Functions

is_nonnegative(input_mat[, mat_type])

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 [2], 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

print(is_nonnegative(np.eye(2)))
print(is_nonnegative(np.eye(2), "doubly"))
print(is_nonnegative(np.array([[1, -1], [1, 1]])))
True
True
False

References

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 for mat_type.

Return type:

bool