[SciPy-user] Converting dense into sparse matrices is slow
nwagner at mecha.uni-stuttgart.de
Mon Mar 20 05:53:36 CST 2006
Robert Cimrman wrote:
> Nils Wagner wrote:
>> Hi all,
>> AFAIK linalg.kron only works with dense matrices.
>> It would be nice if kron can handle sparse matrices as well.
>> The example (bao.py) takes a lot of time
>> Kronecker product (sec): 6.28
>> Dense to sparse (sec): 70.09
>> Number of nonzero elements 16129
>> If one uses a dense matrix there are 16777216 entries.
>> Anyway, is it possible to accelerate some operations (especially
>> csr_matrix()) in bao.py ?
> Hi Nils,
> the actual conversion is done by *fulltocsc() function of sparsetools,
> which IMHO allocates space for the whole dense matrix which is very
> large in your case. Maybe a two-pass approach would be faster - 1. count
> the actual nonzeros, 2. build the matrix. I cannot try it right now,
> SciPy-user mailing list
> SciPy-user at scipy.net
Thank you for your short note.
BTW, a fix for
would be awesome.
More information about the SciPy-user