[SciPy-user] dot behaviour with sparse matrix

Nathan Bell wnbell@gmail....
Wed Oct 1 11:29:59 CDT 2008


On Wed, Oct 1, 2008 at 12:20 PM, Robin <robince@gmail.com> wrote:
> Not sure if this is a bug or not but it was certainly unexpected
> behaviour for me.
>
> I found that dot(dense,dense) works as expected
> (ie dimensions (8,255),(255,8) -> (8,8))
> and that dot(sparse,sparse) also works that way, producing a sparse result.
>
> But dot(dense,sparse) gives an output with the same dimensions as the
> dense input. Not sure why this is happening and I found it a bit
> confusing. Is this a bug or inteded behaviour?
>
> Actually I was just going through an example and I notice that
> dot(csc_matrix, dense_matrix) raises a NotImplemented type - so
> perhaps the other cases should also:
>

The sparse formats do support sparse * sparse, sparse * dense, and
dense * sparse using the standard infix operator.  I'm surprised that
dot() works at all with sparse arguments.

If you can get to the bottom of this I'd be happy to fix it.

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


More information about the SciPy-user mailing list