Skip to content

Instantly share code, notes, and snippets.

@cournape
Forked from anonymous/gist:578226
Created September 14, 2010 06:43
Show Gist options
  • Save cournape/578640 to your computer and use it in GitHub Desktop.
Save cournape/578640 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