Skip to content

Instantly share code, notes, and snippets.

Created September 13, 2010 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/578226 to your computer and use it in GitHub Desktop.
Save anonymous/578226 to your computer and use it in GitHub Desktop.
import scipy.sparse
import scipy.io.mmio
import os
import gc
import time
import numpy
matrix = scipy.io.mmio.mmread(os.popen("cat sparse_matrix.head try3"))
mat2 = matrix.tocsc()
numpy.savez('foo.npz', mat=mat2)
norms = numpy.zeros((1,mat2.shape[1]))
import math
for j in range(0, mat2.shape[1] - 1):
if (j % 10000 == 0):
print('j is', j)
c = mat2.getcol(j)
norms[0, j] = scipy.linalg.norm(c.A)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment