def is_hermitian(operator):
    """
    Check if matrix or operator is hermitian.

    :param (numpy.ndarray|qutip.Qobj) operator: The operator or matrix to be tested.
    :return: True if the operator is hermitian.
    :rtype: bool
    """
    if isinstance(operator, qt.Qobj):
        return (operator.dag() - operator).norm(FROBENIUS) / operator.norm(FROBENIUS) < EPS
    if isinstance(operator, np.ndarray):
        return np.linalg.norm(operator.T.conj() - operator) / np.linalg.norm(operator) < EPS
    return spnorm(operator.H - operator) / spnorm(operator) < EPS
Check if matrix or operator is hermitian.

    :param (numpy.ndarray|qutip.Qobj) operator: The operator or matrix to be tested.
    :return: True if the operator is hermitian.
    :rtype: bool