(A, maxiter=25, symmetric=False)
return (np.max([norm(x) for x in ev])/min(norm(x) for x in ev))**power
r"""Estimates the condition number of A.

    Parameters
    ----------
    A   : {dense or sparse matrix}
        e.g. array, matrix, csr_matrix, ...
    maxiter: {int}
        Max number of Arnoldi/Lanczos iterations
    symmetric : {bool}
        If symmetric use the far more efficient Lanczos algorithm,
        Else use Arnoldi.
        If hermitian, use symmetric=True.
        If complex symmetric, use symmetric=False.

    Returns
    -------
    Estimate of cond(A) with \|lambda_max\| / \|lambda_min\| or simga_max / sigma_min
    through the use of Arnoldi or Lanczos iterations, depending on
    the symmetric flag

    Notes
    -----
    The condition number measures how large of a change in the
    the problems solution is caused by a change in problem's input.
    Large condition numbers indicate that small perturbations
    and numerical errors are magnified greatly when solving the system.

    Examples
    --------
    >>> import numpy as np
    >>> from pyamg.util.linalg import condest
    >>> c = condest(np.array([[1.,0.],[0.,2.]]))
    >>> print(f'{c:2.6}')
    2.0
r"""Estimates the condition number of A.
r Estimates the condition number of A .
def condest(A, maxiter=25, symmetric=False):
    r"""Estimates the condition number of A.

    Parameters
    ----------
    A   : {dense or sparse matrix}
        e.g. array, matrix, csr_matrix, ...
    maxiter: {int}
        Max number of Arnoldi/Lanczos iterations
    symmetric : {bool}
        If symmetric use the far more efficient Lanczos algorithm,
        Else use Arnoldi.
        If hermitian, use symmetric=True.
        If complex symmetric, use symmetric=False.

    Returns
    -------
    Estimate of cond(A) with \|lambda_max\| / \|lambda_min\| or simga_max / sigma_min
    through the use of Arnoldi or Lanczos iterations, depending on
    the symmetric flag

    Notes
    -----
    The condition number measures how large of a change in the
    the problems solution is caused by a change in problem's input.
    Large condition numbers indicate that small perturbations
    and numerical errors are magnified greatly when solving the system.

    Examples
    --------
    >>> import numpy as np
    >>> from pyamg.util.linalg import condest
    >>> c = condest(np.array([[1.,0.],[0.,2.]]))
    >>> print(f'{c:2.6}')
    2.0

    """
    C = aslinearoperator(A)
    power = 1
    if not symmetric:
        def matvec(v):
            return C.rmatvec(C.A @ v)
        C.matvec = matvec
        power = 0.5

    [evect, ev, H, V, breakdown_flag] =\
        _approximate_eigenvalues(C, maxiter, symmetric)
    del evect, H, V, breakdown_flag

    return (np.max([norm(x) for x in ev])/min(norm(x) for x in ev))**power
def condest ( A , maxiter = 25 , symmetric = False ) : C = aslinearoperator ( A ) power = 1 if not symmetric : def matvec ( v ) : return C . rmatvec ( C . A @ v ) C . matvec = matvec power = 0.5 [ evect , ev , H , V , breakdown_flag ] = _approximate_eigenvalues ( C , maxiter , symmetric ) del evect , H , V , breakdown_flag return ( np . max ( [ norm ( x ) for x in ev ] ) / min ( norm ( x ) for x in ev ) ) ** power