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

Home » Public Forums » archive » Re: How to get matching elements of array efficiently
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: How to get matching elements of array efficiently [message #69889] Mon, 01 March 2010 11:18 Go to previous message
JJ is currently offline  JJ
Messages: 36
Registered: January 2007
Member
>
> Are your values integers as in the example? If they are, and if there
> are no big gaps in B (the number of elements of B is not much smaller
> than max(B)-min(B)), histogram comes to mind:
>
> h=histogram(A,binsize=1,min=min(b),max=max(b),reverse_indice s=ri)
> if (max(h) gt 0L) then res=ri[n_elements(h)+1:*] else (deal with the
> case of none found in b)
>
> Which would give the result you want in res, but ordered by bin (their
> order in B). In this example, res would be [0,3,2,4].

What I actually used was something akin to this:

h = histogram(a,min=0,max=(max(a) > max(b)),reverse_indices=ri)
w = where(h[b] gt 0)
res = ri[[ri[b[w]],ri[b[w]+1]-1]]

-JJ
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Intersection of polyline curve and polygon in 3D
Next Topic: Deconvolving a set of points

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

Current Time: Wed Oct 08 19:15:53 PDT 2025

Total time taken to generate the page: 0.00437 seconds