(A)
return np.dot(np.abs(A), np.ones((A.shape[1],), dtype=A.dtype)).max()
Infinity norm of a matrix (maximum absolute row sum).

    Parameters
    ----------
    A : csr_matrix, csc_matrix, sparse, or numpy matrix
        Sparse or dense matrix

    Returns
    -------
    n : float
        Infinity norm of the matrix

    Notes
    -----
    - This serves as an upper bound on spectral radius.
    - csr and csc avoid a deep copy
    - dense calls scipy.linalg.norm

    See Also
    --------
    scipy.linalg.norm : dense matrix norms

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.sparse import spdiags
    >>> from pyamg.util.linalg import infinity_norm
    >>> n=10
    >>> e = np.ones((n,1)).ravel()
    >>> data = [ -1*e, 2*e, -1*e ]
    >>> A = spdiags(data,[-1,0,1],n,n)
    >>> print(infinity_norm(A))
    4.0
Infinity norm of a matrix (maximum absolute row sum).
Infinity norm of a matrix ( maximum absolute row sum ) .
def infinity_norm(A):
    """Infinity norm of a matrix (maximum absolute row sum).

    Parameters
    ----------
    A : csr_matrix, csc_matrix, sparse, or numpy matrix
        Sparse or dense matrix

    Returns
    -------
    n : float
        Infinity norm of the matrix

    Notes
    -----
    - This serves as an upper bound on spectral radius.
    - csr and csc avoid a deep copy
    - dense calls scipy.linalg.norm

    See Also
    --------
    scipy.linalg.norm : dense matrix norms

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.sparse import spdiags
    >>> from pyamg.util.linalg import infinity_norm
    >>> n=10
    >>> e = np.ones((n,1)).ravel()
    >>> data = [ -1*e, 2*e, -1*e ]
    >>> A = spdiags(data,[-1,0,1],n,n)
    >>> print(infinity_norm(A))
    4.0

    """
    if sparse.isspmatrix_csr(A) or sparse.isspmatrix_csc(A):
        # avoid copying index and ptr arrays
        abs_A = A.__class__((np.abs(A.data), A.indices, A.indptr),
                            shape=A.shape)
        return (abs_A * np.ones((A.shape[1]), dtype=A.dtype)).max()

    if sparse.isspmatrix(A):
        return (abs(A) * np.ones((A.shape[1]), dtype=A.dtype)).max()

    return np.dot(np.abs(A), np.ones((A.shape[1],), dtype=A.dtype)).max()
def infinity_norm ( A ) : if sparse . isspmatrix_csr ( A ) or sparse . isspmatrix_csc ( A ) : # avoid copying index and ptr arrays abs_A = A . __class__ ( ( np . abs ( A . data ) , A . indices , A . indptr ) , shape = A . shape ) return ( abs_A * np . ones ( ( A . shape [ 1 ] ) , dtype = A . dtype ) ) . max ( ) if sparse . isspmatrix ( A ) : return ( abs ( A ) * np . ones ( ( A . shape [ 1 ] ) , dtype = A . dtype ) ) . max ( ) return np . dot ( np . abs ( A ) , np . ones ( ( A . shape [ 1 ] , ) , dtype = A . dtype ) ) . max ( )