[SciPy-user] fast max() on sparse matrices

Peter Skomoroch peter.skomoroch@gmail....
Sun Jan 4 20:37:03 CST 2009

Does anyone have suggestions on a fast max() function for sparse matrices
(COO, CSC, or CSR format)?

I was thinking of slicing CSC or CSR matrices, and iterating through the
columns, but I suspect any loop based approach will be slow.

def sparse_amax(V):
    """Returns the max of a sparse CSR matrix V with shape (m,n)
    m = number of examples (# columns),
    n = dimensionality of examples (# rows) """
    n,m = V.shape
    # if type is CSR, slice by rows
    maxvals = []
    for row in xrange(n):
        #find max of row
    Vmax = max(maxvals)
    return Vmax

Peter N. Skomoroch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20090104/72ea13b0/attachment.html 

More information about the SciPy-user mailing list