[SciPy-user] New sparse matrix functionality
schofield at ftw.at
Mon Feb 27 17:21:41 CST 2006
On 27/02/2006, at 11:23 AM, Robert Cimrman wrote:
> well done! I think it's better your way - if a vector (i.e. 2D
> array) is
> put in, it is expected that a vector goes out as well.
Okay, great. This was probably the only change that could be
controversial, so if you're happy (and nobody else objects) I'll
merge the whole patch.
> Do you also plan to add the c-based linked-list matrix as in PySparse
> (ll_mat.c there)? This could be even faster than using the Python
Well, I guess it would be nice to have, and the code's already
written, but I don't know how we'd make it derive from the spmatrix
base class, which is written in Python. Travis mentioned back in
October that this is possible but not easy. So it would require some
work. I don't need the extra speed personally -- the new class seems
to be fast enough for my needs (the bottleneck for my work is now
>> These changes have highlighted a problem present in both the main
>> and my branch: that multiplying a dense matrix 'a' by a sparse matrix
>> 'b' is not possible using the syntax 'a*b'. I'll follow this up
>> with a
>> proposal to numpy-discussion on how we can solve this.
> I am very curious how to do this. Surely NumPy will have to be
> aware of
> existence of sparse matrix objects, right?
An update: I've changed the matrix.__mul__ function in NumPy SVN to
return NotImplemented if the right operand defines __rmul__ and isn't
a NumPy-compatible type. This seems to work fine for * now.
Functions like numpy.dot() still won't work on sparse matrices, but I
don't really have a problem with this ;)
More information about the SciPy-user