[SciPy-User] fancy indexing lil_matrix extremely slow

Christopher Mutel cmutel at gmail.com
Tue Dec 25 11:27:42 EST 2012


It sounds like you would be better served using a COO matrix constructor
instead of LIL (
http://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html).
>From your example code, you don't actually need slicing.

On Tue, Dec 25, 2012 at 5:16 PM, Cplusplus Programmer <
programmercplusplus at yahoo.com> wrote:

> Hello All,
>
> I am using scipy version 0.9. I have a sparse matrix, of which I do not
> know beforehand what values it will get.
> What I did was first generating a scipy.sparse.lil_matrix of zeros (N x N
> matrix).
>
> To assign values to the sparse matrix I use fancy slicing e.g
>
> for i in range( N ):
>     myLilMatrix[ 0: N-4, i ] = myArrayWithValuesToAssign
>
> I works fine, however, it is very very slow. I could not use other sparse
> matrix types, since those does not support fancy indexing for assignment. I
> was wondering if there is a way to speed up sparse matrix assignements ?
>
> If scipy.sparse module does not support this, does anyone know another
> module which will be faster ?
>
> regards,
>
> pcpp
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20121225/423df4b4/attachment.html>


More information about the SciPy-User mailing list