comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Why is MEAN so slow?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Why is MEAN so slow? [message #74499] Tue, 18 January 2011 16:52
Matt Francis is currently offline  Matt Francis
Messages: 94
Registered: May 2010
Member
I've been using the PROFILER to track down why some code was a bit
slow and found that it was spending most of its time in the MEAN
function (and then within that, in the MOMENT function called by
MEAN).

I had a look at the code for this and it looked very inefficient. It
took just moments to come up with this straight forward version:

function mean_quick,data,nan=nan,double=double

if keyword_set(nan) then begin
indx = where(finite(data),count)
if count EQ 0 then return, keyword_set(double) ? !values.D_nan : !
values.f_nan
return,total(data[indx],double=double)/count
endif else begin
return,total(data,double=double)/n_elements(data)
endelse

end

This is very simple minded, but as far as I can tell matches the
functionality of the library function MEAN and is at least 5 times
faster (for my usage in this code).

Why would the Library function be written so inefficiently?
[Message index]
 
Read Message
Previous Topic: How to speed up code which checks lots of values of an array
Next Topic: FINDFILE problems IDL 8 LINUX

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 20:54:35 PDT 2025

Total time taken to generate the page: 0.88276 seconds