[SciPy-User] flattened index for Sparse Matrix?

braingateway braingateway@gmail....
Fri Nov 5 20:20:12 CDT 2010

Lutz Maibaum:
> On Thu, Nov 4, 2010 at 6:44 AM, braingateway <braingateway@gmail.com> wrote:
>> Thanks a lot! Then what about the first question? How could I index the
>> sparse matrix as flattened version?
> If you want to index only the non-zero matrix elements, you can use
> the (for CSR matrices) the data array directly. If you want to index
> all matrix elements, I can't think of a better way than to convert an
> index i to the two-dimensional matrix coordinates:
>   a[i / a.shape[1], i % a.shape[1]]
Thanks, but is would be very inconvenient in lots of circumstances, such 
as nested dissection, blabla.
> 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