def makeTest(M): import rcm import sparse Mcsr = M.tocsr() plt.figure() plt.spy(Mcsr) p = rcm._reverse_cuthill_mckee(Mcsr.indices, Mcsr.indptr, M.shape[0]) Mrcm = sparse.sp_permute(Mcsr, p, p) print "Bandwidth before", sparse.sp_bandwidth(Mcsr) print "Bandwidth after", sparse.sp_bandwidth(Mrcm) plt.figure() plt.spy(Mrcm) plt.show() return
def doall(): import glob import rcm import sparse for f in glob.glob("*.mm"): start = time.time() M = spio.mmread(f).tocsr() timeElapsed = time.time() - start print "file:", f print "t_read:", timeElapsed print "length:", M.shape[0] print "nnz:", M.nnz print "explicit_zeros:", len(M.data[(M.data == 0)]) print "min:", min(abs(M.data[(M.data != 0)])) print "max:", max(abs(M.data)) print "bandwidth:", sparse.sp_bandwidth(M) p = rcm._reverse_cuthill_mckee(M.indices, M.indptr, M.shape[0]) Mrcm = sparse.sp_permute(M, p, p) print "rcm_bandwidth:", sparse.sp_bandwidth(Mrcm) return