in src/braket/default_simulator/operation_helpers.py [0:0]
def check_cptp(matrices: List[np.ndarray]):
"""Checks that the given matrices define a CPTP map.
Args:
matrices (List[np.ndarray]): The matrices to check
Raises:
ValueError: If the matrices do not define a CPTP map
"""
E = sum([np.matmul(matrix.T.conjugate(), matrix) for matrix in matrices])
if not np.allclose(E, np.eye(*E.shape)):
raise ValueError(f"{matrices} do not define a CPTP map")