Пример #1
0
def bah():
    b1 = b.copy()
    b2 = b.copy()
    b3 = b.copy()

    t = time.time()
    b1.sort_indices()
    print time.time()-t,'python'
    print b1.indices

    t = time.time()
    matmult.sort_csr(b2.indptr.size,b2.indptr,b2.indices,b2.data)
    print time.time()-t,'subsort'
    print b2.indices

    import radSort
    print numpy.sort(b3.indices),b3.indices.size,b.shape
    t = time.time()
    #matmult.sort_csr2(b3.indptr.size,b3.data.size,b3.indptr,b3.indices,b3.data)
    radSort.sort_csr(b3.indptr,b3.indices,b3.data,M)
    print time.time()-t,'qsort'
    print b3.indices
    print abs((b3.data-b2.data)/b2.data).max()
    df

    iw = numpy.empty(max(a.shape),dtype=numpy.intc)
    t = time.time()
    nnz = matmult.count_t(M,a.indices+1,a.indptr+1,b.indices+1,b.indptr+1,iw)
    print time.time()-t
    t = time.time()
    c,jc,ic = matmult.multd_t(M,M,a.indices,a.indptr,b.indices,b.indptr,a.data,b.data,nnz)
    print time.time()-t
    out = a.__class__((c,jc,ic),shape=(M,M))
    return out+out.T
Пример #2
0
def fastAAT2(a):
    import numpy
    import matmult

    b = a.tocsr()
    a = a.T.tocsr()

    M,N = a.shape
    t = time.time()
    matmult.sort_csr(b.indptr.size,b.indptr,b.indices,b.data)
    print time.time()-t

    iw = numpy.empty(max(a.shape),dtype=numpy.intc)
    nnz = matmult.count_t(M,a.indices+1,a.indptr+1,b.indices+1,b.indptr+1,iw)
    c,jc,ic = matmult.multd_t(M,M,a.indices,a.indptr,b.indices,b.indptr,a.data,b.data,nnz)
    out = a.__class__((c,jc,ic),shape=(M,M))
    return out+out.T