Skip to content

Instantly share code, notes, and snippets.

@MechCoder
Created March 21, 2014 05:32
Show Gist options
  • Save MechCoder/9680115 to your computer and use it in GitHub Desktop.
Save MechCoder/9680115 to your computer and use it in GitHub Desktop.
Sparse matrix handling
# Accessing rows and columns.
for ptr in xrange(len(csc.indptr) - 1):
strptr = csc.indptr[ptr]
endptr = csc.indptr[ptr + 1]
temp = xrange(strptr, endptr)
if temp:
for row in temp:
print ptr, csc.data[row], csc.indices[row]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment