# Path: pyamg/util/params.py
# def set_tol(dtype):
#     """Set a tolerance based on a numpy dtype char.
# 
#     Parameters
#     ----------
#     dtype : np.dtype
#         numpy dtype
# 
#     Returns
#     -------
#     tol : float
#         A smallish value based on precision
# 
#     Notes
#     -----
#     Handles both real and complex (through the .lower() case)
# 
#     See Also
#     --------
#     numpy.typecodes, numpy.sctypes
#     """
#     if dtype.char.lower() == 'f':
#         tol = 1e3 * np.finfo(np.single).eps
#     elif dtype.char.lower() == 'd':
#         tol = 1e6 * np.finfo(np.double).eps
#     elif dtype.char.lower() == 'g':
#         tol = 1e6 * np.finfo(np.longdouble).eps
#     else:
#         raise ValueError('Attempting to set a tolerance for an unsupported precision.')
# 
#     return tol


from warnings import warn
from scipy import sparse
from scipy.sparse.linalg import aslinearoperator
from scipy.linalg import lapack, get_blas_funcs, eig, svd
from .params import set_tol
import numpy as np
#    Returns
#    -------
#        An approximation to the spectral radius of A
#
#    """
#    if symmetric:
#        method = eigen_symmetric
#    else:
#        method = eigen
#
#    return norm( method(A, k=1, tol=0.1, which='LM', maxiter=maxiter,
#    return_eigenvectors=False) )


def _approximate_eigenvalues(A, maxiter, symmetric=None, initial_guess=None):
    """Apprixmate eigenvalues.

    Used by approximate_spectral_radius and condest.

    Returns [W, E, H, V, breakdown_flag], where W and E are the eigenvectors
    and eigenvalues of the Hessenberg matrix H, respectively, and V is the
    Krylov space.  breakdown_flag denotes whether Lanczos/Arnoldi suffered
    breakdown.  E is therefore the approximate eigenvalues of A.

    To obtain approximate eigenvectors of A, compute V*W.

    """
    A = aslinearoperator(A)  # A could be dense or sparse, or something weird

    # Choose tolerance for deciding if break-down has occurred

# Path: pyamg/util/params.py
# def set_tol(dtype):
#     """Set a tolerance based on a numpy dtype char.
# 
#     Parameters
#     ----------
#     dtype : np.dtype
#         numpy dtype
# 
#     Returns
#     -------
#     tol : float
#         A smallish value based on precision
# 
#     Notes
#     -----
#     Handles both real and complex (through the .lower() case)
# 
#     See Also
#     --------
#     numpy.typecodes, numpy.sctypes
#     """
#     if dtype.char.lower() == 'f':
#         tol = 1e3 * np.finfo(np.single).eps
#     elif dtype.char.lower() == 'd':
#         tol = 1e6 * np.finfo(np.double).eps
#     elif dtype.char.lower() == 'g':
#         tol = 1e6 * np.finfo(np.longdouble).eps
#     else:
#         raise ValueError('Attempting to set a tolerance for an unsupported precision.')
# 
#     return tol


# Path: pyamg/util/linalg.py
from warnings import warn
from scipy import sparse
from scipy.sparse.linalg import aslinearoperator
from scipy.linalg import lapack, get_blas_funcs, eig, svd
from .params import set_tol
import numpy as np

#    Returns
#    -------
#        An approximation to the spectral radius of A
#
#    """
#    if symmetric:
#        method = eigen_symmetric
#    else:
#        method = eigen
#
#    return norm( method(A, k=1, tol=0.1, which='LM', maxiter=maxiter,
#    return_eigenvectors=False) )


def _approximate_eigenvalues(A, maxiter, symmetric=None, initial_guess=None):
    """Apprixmate eigenvalues.

    Used by approximate_spectral_radius and condest.

    Returns [W, E, H, V, breakdown_flag], where W and E are the eigenvectors
    and eigenvalues of the Hessenberg matrix H, respectively, and V is the
    Krylov space.  breakdown_flag denotes whether Lanczos/Arnoldi suffered
    breakdown.  E is therefore the approximate eigenvalues of A.

    To obtain approximate eigenvectors of A, compute V*W.

    """
    A = aslinearoperator(A)  # A could be dense or sparse, or something weird

    # Choose tolerance for deciding if break-down has occurred

    breakdown = set_tol(A.dtype)