toqito.matrix_props.is_nonnegative

Checks if the matrix is nonnegative or doubly nonnegative.

Module Contents

toqito.matrix_props.is_nonnegative.is_nonnegative(input_mat, mat_type='nonnegative')[source]

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 [@WikiNonNegative].

When a matrix is nonegative and positive semidefinite [@WikiPosDef], the matrix is doubly nonnegative.

Examples

We expect an identity matrix to be nonnegative.

```python exec=”1” source=”above” 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]]))) ```

Raises:

TypeError – If something other than “doubly”`or `”nonnegative” is used for mat_type.

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

  • matrix. (nonnegative)

Return type:

bool