[SciPy-User] Can I copy a sparse matrix into an existing dense numpy matrix?
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User