[Numpy-discussion] loop vectorization

Thomas K Gamble tkg at lanl.gov
Fri Mar 11 13:13:38 EST 2011


I have the followin loop in my code:

    for i in range(0, nFrames):
        data += dot(transpose(bipData[:,i,:]), bipData[:,i,:]) 

bipData is a 1024x258x256 double precision float array.

The loop takes all of 15 seconds to run on my computer and, with several 
hundred files to process...

Is there a way to do something like:

data = sum(dot(transpose(bipData), bipData))

with dot done on the desired axis of bipData?
This might give a fair speed increase.  Or perhaps a different approach I'm not 
seeing?

-- 
Thomas K. Gamble
Research Technologist, System/Network Administrator
Chemical Diagnostics and Engineering (C-CDE)
Los Alamos National Laboratory
MS-E543,p:505-665-4323 f:505-665-4267

"There cannot be a crisis next week. My schedule is already full."
    Henry Kissinger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110311/ca882b8d/attachment.html>


More information about the NumPy-Discussion mailing list