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

Home » Public Forums » archive » Distance between two sets of datapoints
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Distance between two sets of datapoints [message #70257] Thu, 25 March 2010 03:33
Maxwell Peck is currently offline  Maxwell Peck
Messages: 61
Registered: February 2010
Member
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))
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: western hemisphere to eastern
Next Topic: problem with output on PS device / TVREAD

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

Current Time: Wed Oct 08 09:15:50 PDT 2025

Total time taken to generate the page: 0.00563 seconds