def is_hermitian(matrix):
    """Check, if a matrix is Hermitian.

    `matrix` can be a numpy array, a scipy sparse matrix, or a `qutip.Qobj`
    instance.

    Args:
        matrix (list, numpy.ndarray, qutip.Qobj): Input array.

    Returns:
        bool: Returns `True` if matrix is Hermitian, `False` otherwise.

    Examples:
         >>> m = np.array([[0, 1j], [-1j, 1]])
         >>> is_hermitian(m)
         True

         >>> m = np.array([[0, 1j], [-1j, 1j]])
         >>> is_hermitian(m)
         False

         >>> m = np.array([[0, -1j], [-1j, 1]])
         >>> is_hermitian(m)
         False

         >>> from scipy.sparse import coo_matrix
         >>> m  = coo_matrix(np.array([[0, 1j], [-1j, 0]]))
         >>> is_hermitian(m)
         True
    """
    if hasattr(matrix, 'isherm'):  # qutip.Qobj
        return matrix.isherm
    else:  # any numpy matrix/array or scipy sparse matrix)
        # pylint: disable=simplifiable-if-statement
        if (abs(matrix - matrix.conjugate().transpose())).max() < 1e-14:
            # If we were to "simplify the if statement" and return the above
            # expression directly, we might get an instance of numpy.bool_
            # instead of the builtin bool that we want.
            return True
        else:
            return False