[SciPy-dev] Adding to an array with __radd__()

Travis Oliphant oliphant at ee.byu.edu
Mon Oct 31 11:42:49 CST 2005


Ed Schofield wrote:

>Sparse matrix objects now support adding a sparse matrix to a dense
>matrix of the same dimensions with the syntax:
>
>newdense = sparse + dense
>
>I'd like to add support for the opposite order too:
>
>newdense = dense + sparse
>
>but this doesn't seem possible currently.  This operation calls the
>__radd__() method of the sparse matrix object multiple times, each time
>passing a single element from the dense matrix. 
>
Why does it do this?   This does not seem to be the way Python would 
handle it. 

Can you track exactly what gets called when

dense + sparse

is performed?

-Travis







More information about the Scipy-dev mailing list