# [SciPy-user] Bug in scipy.sparse

Olivier zelbier@gmail....
Thu Nov 1 13:06:29 CDT 2007

```Nobody seems to care much about sparse arrays in scipy.... One reason
why i tremendously prefer arrays over matrices is that it is extremely
easy to multiply all the rows or columns of a matrix by a vector of
coefficients. You just do M*V to multiply column-wise or
M*V.reshape(-1,1) to multiply row-wise.

I hate having to create a diagonal matrix for such a simple task.

Nobody is interested in having sparse arrays in scipy?

== Olivier

On Oct 31, 12:01 pm, "Olivier Verdier" <zelb...@gmail.com> wrote:
> The first thing I'm surprised about with scipy.sparse is that it uses the
> matrix type instead of the array type. This is very unfortunate, in my
> opinion.
> The bug is that a sparse matrix won't work correctly with `dot` and `array`:
>
> spmat = speye(3,3)
> vec  = array([1,0,0])
>
> dot(spmat, vec)
> returns:
> array([  (0, 0) 1.0
>   (1, 1)        1.0
>   (2, 2)        1.0,
>          (0, 0) 0.0
>   (1, 1)        0.0
>   (2, 2)        0.0,
>          (0, 0) 0.0
>   (1, 1)        0.0
>   (2, 2)        0.0], dtype=object)
>
> Ouch!!
>
> The right result may however be obtained with spmat * vec.
>
> This is a pity because any code that works with arrays or matrices in
> general and uses `dot` to do the matrix vector multiplication will be
> *broken* with sparse matrices.
>
> How reliable is scipy.sparse? Is there any plan to make it more compatible
> with the array type? Behave like the array type? How can I help?
>
> == Olivier
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-u...@scipy.orghttp://projects.scipy.org/mailman/listinfo/scipy-user

```