[SciPy-User] Mixing arrays, matrices and sparse matrices

Jaakko Luttinen jaakko.luttinen at aalto.fi
Thu Feb 23 09:49:01 EST 2012


Hi!

I am trying to work without the matrix class in order to avoid problems,
but it is difficult because mixing arrays and sparse matrices results in
matrices.

I believe that NumPy/SciPy works incorrectly when using arrays, matrices
and sparse matrices mixed. I thought that results would be arrays rather
than matrices because arrays are more general and the result may require
more than two dimensions.

For instance, I think all the following operations should return arrays:
array.dot(array) = array
matrix.dot(array) = matrix
sparse.dot(array) = array
array + matrix = matrix
array + sparse = matrix

On the other hand,
sparse.multiply(array) should return sparse (because the element-wise
product makes the result sparse), but there are no N-dimensional sparse
arrays.. At the moment, sparse.multiply(array) returns a dense matrix,
which is not good in my opinion - either return an array or a sparse matrix.

I think it would be easiest if dense results were always given as arrays
when there are arrays involved.

Can anyone help? Should I create a ticket?

Regards,
Jaakko



More information about the SciPy-User mailing list