 # Feature request : Comparison of sparse matrices is not implemented.

Hi all,
I tried to visualize the structure of large and sparse matrices using

from matplotlib.colors import LinearSegmentedColormap
from matplotlib.matlab import *
from scipy import *
import IPython

def spy2(Z):
"""
SPY(Z) plots the sparsity pattern of the matrix S as an image
"""

#binary colormap min white, max black
cmapdata = {
'red' : ((0., 1., 1.), (1., 0., 0.)),
'green': ((0., 1., 1.), (1., 0., 0.)),
'blue' : ((0., 1., 1.), (1., 0., 0.))
}
binary = LinearSegmentedColormap('binary', cmapdata, 2)

Z = where(Z>0,1.,0.)
imshow(transpose(Z), interpolation='nearest', cmap=binary)

rows, cols, entries, rep, field, symm = io.mminfo('k0.mtx')
print 'number of rows, cols and entries', rows, cols, entries
print 'Start reading matrix - this may take a minute'
print 'Finished'
flag = 1
if flag == 1:
spy2(ma)
show()

It failed. Is it somehow possible to visualize sparse matrices ?
Any suggestion would be appreciated.

Nils

number of rows, cols and entries 67986 67986 4222171
Start reading matrix - this may take a minute
Finished
Traceback (most recent call last):
File "spy.py", line 29, in ?
spy2(ma)
File "spy.py", line 19, in spy2
Z = where(Z>0,1.,0.)
File "/usr/lib/python2.3/site-packages/scipy/sparse/Sparse.py", line 145, in __cmp__
raise TypeError, "Comparison of sparse matrices is not implemented."
TypeError: Comparison of sparse matrices is not implemented.