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

Home » Public Forums » archive » vectorization challenge! (help!)
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: vectorization challenge! (help!) [message #54908 is a reply to message #54844] Thu, 19 July 2007 01:35 Go to previous messageGo to previous message
Maarten[1] is currently offline  Maarten[1]
Messages: 176
Registered: November 2005
Senior Member
On Jul 17, 4:52 pm, Conor <cmanc...@gmail.com> wrote:

> n = 24
> npeeps = 50
> gn1 = findgen(n,npeeps)
> gn2 = findgen(n,npeeps)
> cutoff = .01
>
> for i=0,npeeps-1 do begin
>
> ; make a random value to determine if we do anything with this
> row
> if randomu(seed,1) lt cutoff then begin
>
> ; this row has been selected. Swap the last (random number)
> of digits in gn1[*,i] with gn2[*,i]
> randindex = long(randomu(seed,1)*n*nd)
> temp = gn1[randindex:*,i]
> gn1[randindex:*,i] = gn2[randindex:*,i]
> gn2[randindex:*,i] = temp
>
> endif
>
> endfor

I don't think you can get rid of the for loop, but you can get rid of
the if statement, and shorten the for loop by using

ran_levels = randu(seed,npeeps)
idx = where(ran_levels lt cutoff, cnt)
for i=0,cnt-1 do
randindex = long(randomu(seed,1)*n*nd)
temp = gn1[randindex:*,idx[i]]
gn1[randindex:*,idx[i]] = gn2[randindex:*,idx[i]]
gn2[randindex:*,idx[i]] = temp
endfor

> From here you may be able to use the tricks listed in
http://www.dfanning.com/code_tips/drizzling.html

Hope this helps.

Maarten
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: warp_tri()
Next Topic: Re: how can idl find out information of other softwares

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

Current Time: Fri Oct 10 14:16:10 PDT 2025

Total time taken to generate the page: 0.08248 seconds