![](https://secure.gravatar.com/avatar/3e3b4dff04d6c945d0f990ea8c362abb.jpg?s=120&d=mm&r=g)
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: http://www.scipy.org/SciPyPackages/Sparse#head-be8a0be5d0e44c4d59550d64fb017... Using COO instead of LIL should be considerably faster. -- Nathan Bell wnbell@gmail.com http://graphics.cs.uiuc.edu/~wnbell/