[Numpy-discussion] Sparse matrices in NumPy?

Herbert L. Roitblat roitblat at hawaii.edu
Mon Jun 5 13:06:13 EDT 2000


Unless I am misunderstanding something, you have a vector, which is the
diagonal of a square matrix, and thus contains 7731 elements.  You want to
multiply it by another vector, which has 7731 columns.  Element by element
by element multiplication will, I think, give you the result that you want.

In matlab you would use the diag command and then use the .* operator to get
element by element multiplication.

In NumPY you would simply use the * operator to multiply the two vectors.

Travis Oliphant has sparse matrix classes that you might want to check out,
but I don't see why you would need them for this task.

HLR

----- Original Message -----
From: "Paul Gettings" <gettings at mines.utah.edu>
To: <numpy-discussion at lists.sourceforge.net>
Sent: Monday, June 05, 2000 6:49 AM
Subject: [Numpy-discussion] Sparse matrices in NumPy?


> I have a problem where I need to do matrix multiplication of a 7731x7731
> matrix; storing this thing would take over 250 MB of memory, which is more
> than my machine has. :(  However, the matrix is empty except for the main
> diagonal.  Ideally, all that needs to be stored is a single vector 7731
> elements long, and then tweak matrix multiplication algorithms to account
for
> this.  Are there any facilities in NumPy to do this sort of thing, or do I
> have to roll my own?  Is there a way to effeciently store a very sparse
> matrix and do standard matrix multiplies?  Thanks.
>
> -Paul Gettings
> Dep't of Geology & Geophysics
> University of Utah
> --
>   But Your Honor, they needed killin'.
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> http://lists.sourceforge.net/mailman/listinfo/numpy-discussion
>





More information about the NumPy-Discussion mailing list