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

Home » Public Forums » archive » Re: Distance between two sets of datapoints
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: Distance between two sets of datapoints [message #70256 is a reply to message #70254] Thu, 25 March 2010 03:46 Go to previous message
Maxwell Peck is currently offline  Maxwell Peck
Messages: 61
Registered: February 2010
Member
That should say I am generating the full set of indices and then
subsetting.
Thanks
On Mar 25, 9:33 pm, Maxwell Peck <maxjp...@gmail.com> wrote:
> Hi All,
>
> I have two sets of data points, inputa and inputb, inputa has many
> more data points than the other. I need to find the distance between
> each point in inputa and all the points in inputb (hopefully without
> loops). At the moment I am using parts of distance_measure.pro to
> generate the full set of distances and subsetting indexes as required.
> The code follows. I can't see an easy way of generating the indexes
> though so that only the pairs i want are calculated (i.e. not
> calculating between inputb/inputb or inputa/inputa indexes).
>
> inputa and inputb can be very very large so I don't think i can use a
> matrix approach to do it vectorially and looping seems awfully slow.
>
> An alternative approach or other suggestions would be appreciated.
>
> Regards
>
> Max
>
> inputa = findgen(2,10)
> inputb = findgen(2,2)
>
> t = [[inputa],[inputb]]
> m=n_elements(t)/2
> n = m*(m-1)/2
>
> ii = 0L
> index0 = LINDGEN(m - 1) + 1   ; work array
> index1 = LONARR(n, /NOZERO)
> index2 = LONARR(n, /NOZERO)
>
> for i=0,m-2 do begin
>   n1 = m - (i+1)
>   index1[ii:ii+n1-1] = i
>   index2[ii] = index0[0:n1-1] + i
>   ii += n1
> endfor
>
> diff = abs(t[*,index1] - t[*,index2])
> res = sqrt(TOTAL(diff^2, 1))
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Highlight default button
Next Topic: IDL licensing

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

Current Time: Fri Oct 10 09:10:10 PDT 2025

Total time taken to generate the page: 1.27872 seconds