comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Euclidean distance
items: Re: Euclidean distance

Euclidean distance
type: item
description: Hi: I'd like to program the following routine: giving two set of vectors with n and m vectors respectively (a matrix of size pxn and another of size pxm), I want to obtain a matrix of size nxm where the element (i,j) is the euclidean distance from first set's vector i to second set's vector j. I know the solution using loops, but exists it a different way without loops?
creator: Imanol Echave
date: 1998-05-21T07:00:00-00:00

Re: Euclidean distance
type: item
description: In article <3563F2D3.59A48553@sc.ehu.es>, Imanol Echave <ccaeccai@sc.ehu.es> wrote: > > Hi: > > I'd like to program the following routine: giving two set of vectors with n and > m vectors respectively (a matrix of size pxn and another of size pxm), I want to > obtain a matrix of size nxm where the element (i,j) is the euclidean distance > from first set's vector i to second set's vector j. I know the solution using > loops, but exists it a different way without loops? > The thing to do is to express each component of each vector as a (nxm) matrix. For the first set of vectors, the values would vary along the first index, and for the second they would vary along the second index. Then you use each matrix as a variable in the formula for the euclidian distance (A concept I am no longer familiar with) One example on how to do this is the following routine that I find invaluable. ;+ NAME: ; TWO_D_ARR ; ; PURPOSE: ; Creates two 2-D arrays AX, AY from the input two 1-D vectors. Both ; arrays have dimensions N_ELEMENTS(VX) * N_ELEMENTS(VY). AX contains ; VX in all of its rows, AY contains TRANSPOSE(VY) in all the columns. ; These two arrays can be used for surface or countour plotting of ; functions of two variables. The variable values are given in VX and VY, ; AX and AY are created and can be used to calculate the 2-D array of ; the function values. ; ; CATEGORY: ; Vector processing ; ; CALLING SEQUENCE: ; TWO_D_ARR, VX,VY,AX,AY ; ; INPUTS: ; VX, VY -- 1-D vectors ; ; OPTIONAL INPUT PARAMETERS: ; None ; ; OUTPUTS: ; AX, AY, array of dimensions N_ELEMENTS(VX) * N_ELEMENTS(VY) ; ; OPTIONAL OUTPUT PARAMETERS: ; DIM_ARR -- vector containing the dimension of the output arrays ; in common block ARRAY_STUFF ; ; COMMON BLOCKS: ; ARRAY_STUFF -- contains DIM_ARR, see above ; ; SIDE EFFECTS: ; None ; ; RESTRICTIONS: ; Unknown ; ; PROCEDURE: ; Straight forward ; ; MODIFICATION HISTORY: ; Conceived, written and performed by Mirko, Sept. 89 ;- PRO TWO_D_ARR, vx, vy, AX, AY common ARRA…
creator: mirko_vukovic
date: 1998-05-22T07:00:00-00:00