[SciPy-User] flattened index for Sparse Matrix?
Thu Nov 4 10:39:52 CDT 2010
On Thu, Nov 4, 2010 at 6:44 AM, braingateway <firstname.lastname@example.org> 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]
Hope this helps,
More information about the SciPy-User