[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coherence test implementation



(quick, before they wake up in Australia! :-)

Hi again,

Dick Jackson wrote:
> 
> You piqued my curiosity, since you're right, there had to be a more
> efficient way! My attached coherence.pro should do the trick, and I
> clock it at about 60 times faster with a 300x300 test.
> [...]
> Generalizing coherence.pro to allow variable 'width' [...]
> wouldn't be hard

I looked at my code again, and realized I was duplicating the function of
the IDL CONVOL routine. That sure simplified things! (and in my 300x300
test, cut time in half yet again) Adding the 'width' idea was trivial. I
think writing helpful comments was the worst part. :-)

And, as with any Good Thing in IDL, it can be written in one line:

coh = Sqrt((Convol(array ^ 2.0, Replicate(1, width, width)) $
            - (Convol(Float(array), Replicate(1, width, width))^2 $
               / (width ^ 2))) $
           / ((width ^ 2)-1))

(the attached .pro is much easier to read and understand)

Enjoy.

Cheers,
-- 
-Dick

Dick Jackson             Fanning Software Consulting, Canadian Office
djackson@dfanning.com    Calgary, Alberta   Voice/Fax: (403) 242-7398
    Coyote's Guide to IDL Programming: http://www.dfanning.com/

coherence.pro