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
Check if coordinate is in array [message #34072] Wed, 19 February 2003 19:34 Go to previous message
Thomas Gutzler is currently offline  Thomas Gutzler
Messages: 44
Registered: November 2002
Member
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
[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: Fri Oct 10 09:44:14 PDT 2025

Total time taken to generate the page: 0.55704 seconds