示例#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 fastAAT(a):
    import numpy
    import matmult

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

    M,N = a.shape
    b.sort_indices()

    iw = numpy.zeros(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
示例#3
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
示例#4
0
def fastAAT3(a):
    import numpy
    import matmult
    import radSort

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

    M,N = a.shape
#    t = time.time()
#    radSort.sort_csr(b.indptr,b.indices,b.data,M)
#    print time.time()-t
    t = time.time()
#    wd = numpy.zeros(max(M,N))
#    wi = wd.astype(numpy.int32)
#    matmult.sort_csr3(b.indptr.size,b.indptr,b.indices,b.data,wi,wd)
    matmult.sort_csr3(b.indptr.size,N,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