[Numpy-discussion] Sparse matrix hooks
schofield at ftw.at
Mon Feb 27 02:57:03 EST 2006
I'm trying to improve integration between SciPy's sparse matrices and
NumPy's dense array/matrix objects. One problem I'm facing is that
NumPy matrices redefine the * operator to call NumPy's dot() function.
Since dot() has no awareness of SciPy's sparse matrix objects, this
doesn't work for the operation 'dense * sparse'. (It does work for
sparse * dense, which calls sparse.__mul__ first.)
I'd like to propose the addition of a basic sparse matrix object to
NumPy. This wouldn't need to provide any actual functionality, but
could instead provide a skeletal interface or base class from which
sparse matrices in other packages (SciPy and potentially PySparse) could
derive. The spmatrix object in SciPy would be a good starting point.
The benefit of this would be that hooks for proper handling of sparse
matrices would be easy to provide for functions like dot(), where(), and
There may be other ways to make 'dense * sparse' work in SciPy, but I
haven't been able to come up with any. This solution would at least be
quite flexible and quite straightforward.
More information about the NumPy-Discussion