Matrix sum is 220 times slower than scipy

  • Anonymous - 2012-05-22

    The following code was used to calculate the sum of sparse matrix A:

    [i]pysparse B init:[/i]
    B = pysparse.spmatrix.ll_mat(1,N)
    val = np.ones(N)
    row = np.zeros(N)
    col = np.arange(0,N)
    [b]272 seconds[/b]
        C = pysparse.spmatrix.matrixmultiply(B,A)
        a = np.zeros(N,dtype=int)
    [b]214 seconds[/b]
        f = pysparse.spmatrix.matrixmultiply(B,A).find()
        a = np.zeros(N, dtype=np.int32)
        for i, c in enumerate(f[2]): a[c] += f[0][i]
    88 seconds
        a = np.zeros(N, dtype=np.int32)
        for i in tree.dA.find()[2]: a[i] += 1
    [b]0.4 seconds[/b]
        a = np.array(scipy.sparse.csr_matrix.sum(A,0))[0]

    Am I doing something wrong here or is there no simple/fast way of getting the sum of A into a numpy array?

  • Anonymous - 2012-05-22

    Also, there seems to be a memory leak when using ll_matrix.nnz
    (I'm not sure how to create a bug report so I write it here)


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks