[SciPy-user] fastest way to populate sparse matrix?

Nathan Bell wnbell@gmail....
Wed Dec 10 12:46:38 CST 2008

On Wed, Dec 10, 2008 at 12:54 PM, Peter Skomoroch
<peter.skomoroch@gmail.com> wrote:
> What is the fastest way to replace non-zero elements of a sparse
> matrix with corresponding elements from a product of dense matrices,
> without the memory overhead of computing the entire dense matrix
> product?
> The code below demonstrates the way I am doing it now: looping through
> the nonzero elements in the sparse matrix, and forming the
> corresponding row - column product from the dense matrices.  It uses
> the sparse module from the latest scipy trunk.

The fastest way to construct a sparse matrix is using the COO format
as discussed here:

Using COO instead of LIL should be considerably faster.

Nathan Bell wnbell@gmail.com

More information about the SciPy-user mailing list