[SciPy-User] Can I copy a sparse matrix into an existing dense numpy matrix?
Conrad Lee
conradlee@gmail....
Mon Feb 6 08:56:22 CST 2012
Warren, thanks for the suggestion with the COO matrix. In general I'm
storing sparse matrices in the CSR format for quick multiplication, so your
approach would mean that I have to convert to a COO matrix every time, but
that conversion is pretty quick.
Although, unless your sparsity pattern doesn't change (which it may not),
> you'll need to zero the entire dense array before reassigning, which will
> also take "a non-negligible amount of time".
>
Zeroing out a matrix seems to happen very quickly, probably because it's a
vectorized operation taking advantage of the SIMD instructions on modern
processors. As far as I understand it, allocating huge amounts of memory
requires slower operations. I did a quick and dirty benchmark, and zeroing
takes a small fraction of the time of allocating.
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@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/20120206/995bb8b9/attachment-0001.html
More information about the SciPy-User
mailing list