my loop is too slow

Tim Hochberg hochberg at psn.net
Wed May 19 09:47:58 EDT 1999


Some time ago Tim Hochberg (me) wrote:

>>from Numeric import *
>>a = a + dot(c, f) * dot(c, transpose(f))


John E. Davis then wrote:

>Are you sure about this?
[SNIP]
>where `#' denotes matrix multiplication and ' represents the
>transpose.  So, I would code this as:
>
>  a = a + (c#f)*(c#f')
>
>where `*' represents an element by element multiply and `+' represents
>an element by element addition.


We agree. Really. Numeric.dot acts as a matrix multiply on 2D matrices. At
some point, Numeric.matrixmultiply got marked as deprecated and new code was
supposed to use dot. (I don't recall why, you'd have to search the old
Numeric mailing list archives).

-tim







More information about the Python-list mailing list