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

Home » Public Forums » archive » Re: Simple question in IDL, looking for solution, thank you
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: Simple question in IDL, looking for solution, thank you [message #81762 is a reply to message #81759] Mon, 22 October 2012 11:10 Go to previous messageGo to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On 10/22/12 7:55 AM, Heinz Stege wrote:
> Hi Danxia,
>
> you didn't ask for a solution without a loop. So here is my simple
> answer:
>
> arr=[5,2,3,1,8,3,1,2,3]
> bcg=[1,2,3,2,1,4,2,3,5]
> sum=intarr(max(arr)+1)
> for i=0,n_elements(bcg)-1 do sum[arr[i]]+=bcg[i]
> print,sum[1:*]
>
> Cheers, Heinz
>

And of course, if you need a very efficient implementation of this (i.e.
if your arrays have millions of elements), then read the "chunk
indexing" section of JD's HISTOGRAM tutorial
http://www.idlcoyote.com/tips/histogram_tutorial.html (you HAVE read
JD's HISTOGRAM tutorial, right???)

-Jeremy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to make text of axis much larger in idl 8?
Next Topic: cgHistoplot and multiplot

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

Current Time: Sun Apr 12 21:27:58 PDT 2026

Total time taken to generate the page: 0.02662 seconds