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

Home » Public Forums » archive » Re: FOR loops removal
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: FOR loops removal [message #62057 is a reply to message #61972] Wed, 20 August 2008 00:24 Go to previous messageGo to previous message
loebasboy is currently offline  loebasboy
Messages: 26
Registered: August 2008
Junior Member
On Aug 19, 3:43 pm, Wox <nom...@hotmail.com> wrote:
> On Tue, 19 Aug 2008 05:38:50 -0700 (PDT), loebasboy
>
> <stijn....@gmail.com> wrote:
>>      FOR l = 0, n*2 DO BEGIN
>>        temp  = 0
>>        FOR i =0,max_y-1 DO BEGIN
>>          FOR j=0,max_x-1 DO BEGIN
>>            jtemp = j + l
>>            jtemp2 = j + n
>>            temp = temp + (arr[i,jtemp] * arr [i,jtemp2])
>>          ENDFOR
>>        ENDFOR
>>        output[l] = temp/(max_x*max_y)
>>      ENDFOR
>
> The code below is a start. Does this processing have a name? It feels
> familiar somehow. Btw, in IDL the first index of an array is the
> column and the second is the row. So in your case y are the columns
> and x are the rows. No problem with that off course, just check
> whether this is how you intended it.
>
> n = 8
> max_x = 5
> max_y = 5
> output = fltarr(2*n+1)
> arr = findgen(max_y, 2*n+max_x) +1
>
> arr2=arr[0:max_y-1,n:max_x-1+n]
> FOR l = 0, 2*n DO $
>         output[l] = total(arr[0:max_y-1,l:max_x-1+l]*arr2)
> output/=max_x*max_y

Thank you for your code, it works rather well, maybe it seems familiar
because it's a kind of autocorrelation that I'm calculating... .

I think I still need some vectorisation training to get IDL much
faster, I've calculated a time profit of 14 h (that makes 8.5 h
instead of 22.5 h), so I still have some FOR loops I can train on ;).
Thanks for helping finding my way and the fast answers, I think I will
definitely post again when I'm really stuck again ;).
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Today's IDL Lesson
Next Topic: speed of accessing different dimensions

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

Current Time: Sun Oct 12 09:55:53 PDT 2025

Total time taken to generate the page: 1.43828 seconds