[SciPy-User] flattened index for Sparse Matrix?
Fri Nov 5 20:20:12 CDT 2010
> On Thu, Nov 4, 2010 at 6:44 AM, braingateway <email@example.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, i % a.shape]
Thanks, but is would be very inconvenient in lots of circumstances, such
as nested dissection, blabla.
> Hope this helps,
> SciPy-User mailing list
More information about the SciPy-User