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

Home » Public Forums » archive » Re: all combinations from two lists
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: all combinations from two lists [message #75651] Mon, 14 March 2011 13:20
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
Never mind, figured it out. Using HIST_ND makes it a lot easier to think about. It doesn't actually require much modification from the basic histogram-of-histogram approach:


maxid = max([list1, list2])
h1 = histogram(list1, min=0, max=maxid, reverse=ri1)
h2 = histogram(list2, min=0, max=maxid, reverse=ri2)
hnd = hist_nd(transpose([[h1],[h2]]), min=[0,0], 1, reverse_indices=rind)
hndsize = size(hnd, /dimen)

for k1=1L, hndsize[0]-1 do begin
for k2=1L, hndsize[1]-1 do if hnd[k1,k2] gt 0 then begin
knd = k1 + k2 * hndsize[0]
targ = [hnd[knd], k1, k2]
these_bins = rind[rind[knd]: rind[knd+1]-1]
these_1 = ri1[ri1[rebin(these_bins,targ,/samp)] + $
rebin(lindgen(1,k1,1),targ,/samp)]
these_2 = ri2[ri2[rebin(these_bins,targ,/samp)] + $
rebin(lindgen(1,1,k2),targ,/samp)]

...do stuff with these_1 and these_2...
endif
endfor


-Jeremy.
[Message index]
 
Read Message
Previous Topic: all combinations from two lists
Next Topic: binary files

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

Current Time: Wed Oct 08 15:37:10 PDT 2025

Total time taken to generate the page: 0.00397 seconds