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

Home » Public Forums » archive » Check if coordinate is in array
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: Check if coordinate is in array [message #34192 is a reply to message #34072] Thu, 20 February 2003 14:30 Go to previous messageGo to previous message
condor is currently offline  condor
Messages: 35
Registered: January 2002
Member
Thomas Gutzler <tgutzler@ee.uwa.edu.au> wrote in message news:<3E544CAB.6020006@ee.uwa.edu.au>...
> Hi again.
>
> Here is the daily riddle:
> Is there a faster way to check, if a coordinate (2-element array) is
> element of an array of coordinates (2,n-element array) than this:
>
> FUNCTION is_element_of_2D, x, arr
> xidx = WHERE(arr[0,*] EQ x[0], c1)
> yidx = WHERE(arr[1,*] EQ x[1], c2)
> IF (c1 + c2 GT 0) THEN tmp = WHERE(MATRIX_MULTIPLY(xidx, $
> 1./TRANSPOSE(yidx)) EQ 1, c3) ELSE c3 = 0
> RETURN, c3 NE 0
> END
>
> Example:
> arr = [[1,2], [3,4], [3,2]]
> x = [3,4]
> y = [2,3]
> print, is_element_of_2D(x, arr)
> print, is_element_of_2D(y, arr)
>
> Tom


I don't know the context of this snippet of code, but in my math
background there is the strong notion that all plane geometry should
always be done in complex numbers as you get the whole world of
Wirtinger calculus for free.

In IDL you get this:


IDL> help,f,g
F COMPLEX = ( 1.00000, 2.00000)
G COMPLEX = Array[4]
IDL> print,g,format='(10(2i2,3x))'
3 4 8 3 1 2 4 5
IDL> print,where(g eq f)
2


So if you could keep your coordinates in complex variables from the
beginning, you can match them and compare them to each other and
such...
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Is there a way to use C++ code in IDL
Next Topic: Sort an Array of Structures...

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

Current Time: Sat Oct 11 09:27:35 PDT 2025

Total time taken to generate the page: 1.91947 seconds