[SciPy-user] Sparse matrices and array multiplication

Christopher Mutel cmutel@gmail....
Sun Jan 27 07:20:22 CST 2008


Hello all-

I hesitate to ask what may be a decidedly simple question, but is it
somehow possible to do array multiplication (the way NumPy arrays are
multiplied) with the sparse matrix classes defined in SciPy? I have
tried searching the the NumPy book & on-line documentation, and the
mailing list, but haven't yet found a way.

By array multiplication, I mean:
a = [a1, a2]
b = [[b1, b2], [b3, b4]]
a*b = [[a1*b1, a2*b2], [a1*b3, a2*b4]]

I am using relatively large arrays, about 1500*4000, with a 1-d
multiplying vector of length 1500, but with only about 1-2% coverage
in both, so populating NumPy arrays means lots of wasted space, or
even exhausts available memory when considering ~20 arrays
simultaneously.

On possible approach would be to slice the arrays to remove empty rows
and columns, using a dictionary to match new indices to the old
indices, but probably there is some magic in the Scipy library that is
cleverer and faster.

Any help, or suggestions for further investigation, would be greatly
appreciated.

-Chris Mutel

-- 
############################
Chris Mutel
Ökologisches Systemdesign - Ecological Systems Design
Institut f.Umweltingenieurwissenschaften - Institute for Environmental
Engineering
ETH Zürich - HIF C 42 - Schafmattstr. 6
8093 Zürich

Telefon: +41 44 633 71 45 - Fax: +41 44 633 10 61
############################


More information about the SciPy-user mailing list