[SciPy-User] flattened index for Sparse Matrix?
Thu Nov 4 08:44:23 CDT 2010
Lutz Maibaum :
> On Wed, Nov 3, 2010 at 12:12 PM, LittleBigBrain <email@example.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,
> SciPy-User mailing list
More information about the SciPy-User