[SciPy-user] find(M) equivalent for sparse matrices?
Tue Feb 6 15:37:18 CST 2007
I'm porting some Matlab code to Numpy and having some trouble.
Basically, in the matlab code we have a line that does a find() on a
sparse matrix and grabs out the rows, columns and values of the non-
zero element positions. It then modifies each element in a manner
dependent on its row and column, and then stores all the elements
back into their original spots.
I can't figure out a way to do this, as comparisons don't seem to be
implemented for the sparse matrix classes. I suppose I should mention
I'm using Python 2.4, scipy 0.5.1, numpy 1.0.
Anyone got an idea of how to do this?
By the way, what I'm doing can be expressed as left and right
multiplying it by a (the same on both sides) diagonal matrix, but
this appears to take a lot longer than it should when I write it that
way (with the diagonal stored as a sparse).
More information about the SciPy-user