[Numpy-discussion] flattened index for Sparse Matrix?

braingateway braingateway@gmail....
Thu Nov 4 08:46:33 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?

Thanks ahead,

LittleBigBrain



More information about the NumPy-Discussion mailing list