[SciPy-User] flattened index for Sparse Matrix?

braingateway braingateway@gmail....
Thu Nov 4 08:44:23 CDT 2010


Lutz Maibaum :
> On Wed, Nov 3, 2010 at 12:12 PM, LittleBigBrain <braingateway@gmail.com> wrote:
>   
>> I am trying sparse matrix these days. I am wondering is there any way
>> I can access the sparse matrix with flattened index?
>>     
>
>   
>> And is there any more delicate way to obtain max, min of a sparse
>> matrix than a[a.nonzero()].max()?
>>     
>
>   
Thanks a lot! Then what about the first question? How could I index the 
sparse matrix as flattened version?
> It probably depends on which sparse matrix type you are using. For a
> CSR matrix, for example, the data member contains the values of all
> non-zero elements. You could do something like a.data.max(), but you
> will still have to compare the result to 0 unless the matrix is in
> fact dense.
>
> Hope this helps,
>
>   Lutz
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>   



More information about the SciPy-User mailing list