[SciPy-User] flattened index for Sparse Matrix?

LittleBigBrain braingateway@gmail....
Wed Nov 3 14:12:17 CDT 2010


Hi Everyone,

I am trying sparse matrix these days. I am wondering is there any way
I can access the sparse matrix with flattened index?
For example:
a=numpy.matrix([[0,1,2],[3,4,5])
matrix([[0, 1, 2],
        [3, 4, 5]])
>>>print a.flat[3]
3
>>> a.flat[3]=10
>>> print a
[[ 0  1  2]
 [10  4  5]]

How could I do the similar indexing for sparse matrix?

And is there any more delicate way to obtain max, min of a sparse
matrix than a[a.nonzero()].max()?

Thanks ahead,

LittleBigBrain


More information about the SciPy-User mailing list