[SciPy-user] accessing only the nonzero elements of a sparse matrix

Nathan Bell wnbell@gmail....
Mon Jun 30 03:28:11 CDT 2008


On Sat, Jun 28, 2008 at 9:18 PM, Ted Sandler <ted.sandler@gmail.com> wrote:
>
> I guess I could convert to coordinate form 'COO' and then access the
> "row" and "col" fields but this seems a little evil as it relies on
> properties of the 'COO' matrix which could change in the future.  It
> would be nicer to have a uniform method of all sparse matrix types.
>
> Thanks for any info on this,

Ted, you are right that we should have a nonzero() member function.
Currently the best you can do is, as you say, converting to COO and
taking the .row,.col, and .data members.

I don't see the names of these variables changing, but we'll certainly
add .nonzero() in the future anyway.


-- 
Nathan Bell wnbell@gmail.com
http://graphics.cs.uiuc.edu/~wnbell/


More information about the SciPy-user mailing list