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

Home » Public Forums » archive » Re: Randomize array order
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: Randomize array order [message #55024 is a reply to message #55023] Thu, 26 July 2007 05:28 Go to previous messageGo to previous message
Conor is currently offline  Conor
Messages: 138
Registered: February 2007
Senior Member
On Jul 25, 3:59 pm, hradilv <hrad...@yahoo.com> wrote:
> On Jul 25, 2:17 pm, Conor <cmanc...@gmail.com> wrote:
>
>> Hi everyone!
>
>> Anyone know an efficient way to randomize an array (I have a
>> sorted array that I want unsorted). Initially, I tried something like
>> this:
>
>> array = findgen(1000000)
>> unsort = array[sort(randomu(seed,1000000))]
>
>> It works, but sorting on a million elements is rather slow. Anyone
>> know a faster way?
>
> Takes about 0.87 seconds on my machine? Is this too long?
>
> Of course, if you want "with replacement" you could do:
> unsort = array[long(1000000*randomu(seed,1000000))]
>
> But you probably want a permutation, right? That'll be more difficult.

You know, it's a shame that sort and histogram don't make use of the
thread pool. If there were any algorithms that need to be multi-
threaded, those would be it. Oh well :(
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Routine for Converting DN to Radiance to Temperature
Next Topic: Re: Socket server in > IDL 6.3

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

Current Time: Fri Oct 10 04:29:15 PDT 2025

Total time taken to generate the page: 0.15995 seconds