[SciPy-user] csr_matrix
Sam frizou
excellent.frizou at gmail.com
Wed Nov 1 06:13:36 EST 2006
Thanks a lot.
I have another problem with sparse matrices please. I do not find how
to apply an operation directly to an entire row. For example,
m[1,:]=dot(m[1,:],4) does not work and I didnt found a "setrow" method
in the documentation.
Thanks
On 11/1/06, Robert Cimrman <cimrman3 at ntc.zcu.cz> wrote:
> Sam frizou wrote:
> > Hi,
> >
> > Is it possible to get the set of indices of non null elements of a
> > sparse matrix M ?
> > I means I can see them by doing "print M", but I want to use them, so
> > I would like something like a list of (i,j).
>
> A general way (should work for any kind of sparse matrix) is:
> [M.rowcol(ii) for ii in xrange(M.size)].
>
> for csr_matrix, you can use directly M.colind (array of all column
> indices), M.indptr (array pointing to first index of a row in colind)
> attributes, but I would not recommend it, unless the first approach is
> too slow.
>
> cheers,
> r.
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
--
On obtient beaucoup plus avec un mot gentil et une arme qu'avec
seulement un mot gentil - "Al Capone".
More information about the SciPy-User
mailing list