cirq.is_diagonal

cirq.is_diagonal(matrix: numpy.ndarray, *, atol: float = 1e-08) → bool[source]

Determines if a matrix is a approximately diagonal.

A matrix is diagonal if i!=j implies m[i,j]==0.

Parameters:
  • matrix – The matrix to check.
  • atol – The per-matrix-entry absolute tolerance on equality.
Returns:

Whether the matrix is diagonal within the given tolerance.