[SciPy-dev] removing lil_eye() and lil_diags()

Nathan Bell wnbell@gmail....
Wed Jul 23 00:43:02 CDT 2008


On Tue, Jul 22, 2008 at 6:08 PM, Stéfan van der Walt <stefan@sun.ac.za> wrote:
>
>> Is there any objection to removing lil_eye() and lil_diags() from
>> scipy.sparse?  I believe these functions were added after the 0.6
>> release and have now been superceded by sparse.eye(..., format='lil')
>> and sparse.spdiags(..., format='lil').
>
> I think that should be fine (I added them both, didn't I?).  One
> question: the implementations were both exploiting properties of lil
> matrices to be constructed efficiently; is constructing a dia_matrix
> and then converting to lil format as good?  It seems like a much
> cleaner solution, so I hope the answer is "yes"!
>

Although the conversion to LIL from DIA goes DIA->COO->CSR->LIL,  the
overall cost is still comparable.  For instance, the cost of A =
sparse.eye(10000, 10000, format='dia') is 0.130 ms and the breakdown
of cost for converting A from DIA to LIL is as follows:
  1.590 ms DIA->COO
  0.636 ms COO->CSR
50.100 ms CSR->LIL

The full process, i.e. eye(10000, 10000, format='lil'), takes about 52 ms.

On the other hand, your version of lil_eye()  [1], which exploits
properties of the LIL format, requires only 32.3 ms.

Since the DIA->LIL conversion is not significantly slower, I would
prefer that we rely on format conversion here.  The additional time
spent making special-purpose implementations for LIL and DOK is
probably better spent improving the conversions between sparse
formats.  Then, if the implementation of the LIL format changes, there
will only be a few places (e.g. csr_matrix.tolil() ) that require
modification.

[1] http://projects.scipy.org/scipy/scipy/browser/trunk/scipy/sparse/sparse.py?rev=3460#L2928

-- 
Nathan Bell wnbell@gmail.com
http://graphics.cs.uiuc.edu/~wnbell/


More information about the Scipy-dev mailing list