(A, fast_check=True, tol=1e-6, verbose=False)
return False
r"""Return True if A is Hermitian to within tol.

    Parameters
    ----------
    A   : {dense or sparse matrix}
        e.g. array, matrix, csr_matrix, ...
    fast_check : {bool}
        If True, use the heuristic < Ax, y> = < x, Ay>
        for random vectors x and y to check for conjugate symmetry.
        If False, compute A - A.conj().T.
    tol : {float}
        Symmetry tolerance

    verbose: {bool}
        prints
        max( \|A - A.conj().T\| ) if nonhermitian and fast_check=False..
        \| <Ax, y> - <x, Ay> ) \| / sqrt( \| <Ax, y> * <x, Ay> \| )
        if nonhermitian and fast_check=True

    Returns
    -------
    True                        if hermitian
    False                       if nonhermitian

    Notes
    -----
    This function applies a simple test of conjugate symmetry

    Examples
    --------
    >>> import numpy as np
    >>> from pyamg.util.linalg import ishermitian
    >>> ishermitian(np.array([[1,2],[1,1]]))
    False

    >>> from pyamg.gallery import poisson
    >>> ishermitian(poisson((10,10)))
    True
r"""Return True if A is Hermitian to within tol.
r Return True if A is Hermitian to within tol .
def ishermitian(A, fast_check=True, tol=1e-6, verbose=False):
    r"""Return True if A is Hermitian to within tol.

    Parameters
    ----------
    A   : {dense or sparse matrix}
        e.g. array, matrix, csr_matrix, ...
    fast_check : {bool}
        If True, use the heuristic < Ax, y> = < x, Ay>
        for random vectors x and y to check for conjugate symmetry.
        If False, compute A - A.conj().T.
    tol : {float}
        Symmetry tolerance

    verbose: {bool}
        prints
        max( \|A - A.conj().T\| ) if nonhermitian and fast_check=False..
        \| <Ax, y> - <x, Ay> ) \| / sqrt( \| <Ax, y> * <x, Ay> \| )
        if nonhermitian and fast_check=True

    Returns
    -------
    True                        if hermitian
    False                       if nonhermitian

    Notes
    -----
    This function applies a simple test of conjugate symmetry

    Examples
    --------
    >>> import numpy as np
    >>> from pyamg.util.linalg import ishermitian
    >>> ishermitian(np.array([[1,2],[1,1]]))
    False

    >>> from pyamg.gallery import poisson
    >>> ishermitian(poisson((10,10)))
    True

    """
    # convert to array type
    if not sparse.isspmatrix(A):
        A = np.asarray(A)

    if fast_check:
        x = np.random.rand(A.shape[0], 1)
        y = np.random.rand(A.shape[0], 1)
        if A.dtype == complex:
            x = x + 1.0j*np.random.rand(A.shape[0], 1)
            y = y + 1.0j*np.random.rand(A.shape[0], 1)
        xAy = np.dot((A.dot(x)).conjugate().T, y)
        xAty = np.dot(x.conjugate().T, A.dot(y))
        diff = float(np.abs(xAy - xAty) / np.sqrt(np.abs(xAy*xAty)))

    else:
        # compute the difference, A - A.conj().T
        if sparse.isspmatrix(A):
            diff = np.ravel((A - A.conj().T).data)
        else:
            diff = np.ravel(A - A.conj().T)

        if np.max(diff.shape) == 0:
            diff = 0
        else:
            diff = np.max(np.abs(diff))

    if diff < tol:
        diff = 0
        return True

    if verbose:
        print(diff)

    return False
def ishermitian ( A , fast_check = True , tol = 1e-6 , verbose = False ) : # convert to array type if not sparse . isspmatrix ( A ) : A = np . asarray ( A ) if fast_check : x = np . random . rand ( A . shape [ 0 ] , 1 ) y = np . random . rand ( A . shape [ 0 ] , 1 ) if A . dtype == complex : x = x + 1.0j * np . random . rand ( A . shape [ 0 ] , 1 ) y = y + 1.0j * np . random . rand ( A . shape [ 0 ] , 1 ) xAy = np . dot ( ( A . dot ( x ) ) . conjugate ( ) . T , y ) xAty = np . dot ( x . conjugate ( ) . T , A . dot ( y ) ) diff = float ( np . abs ( xAy - xAty ) / np . sqrt ( np . abs ( xAy * xAty ) ) ) else : # compute the difference, A - A.conj().T if sparse . isspmatrix ( A ) : diff = np . ravel ( ( A - A . conj ( ) . T ) . data ) else : diff = np . ravel ( A - A . conj ( ) . T ) if np . max ( diff . shape ) == 0 : diff = 0 else : diff = np . max ( np . abs ( diff ) ) if diff < tol : diff = 0 return True if verbose : print ( diff ) return False