comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Finding elements in Two Arrays (THE FUNCTION)
items: Re: Finding elements in Two Arrays (THE FUNCTION)

Finding elements in Two Arrays (THE FUNCTION)
type: item
description: Hi, as I promised, here it is. This function can be used to find the intersecting values, and more importantly their indecies. The thanks should go to Dan Carr who posted most of this in an interactive mode yesterday. I just tinkered with little things like error checking and making it into a function. It seems to run pretty DARN fast! Let me know if there are any problems and or suggestions! This should be a pretty useful function. -stephen Strebel ; ;+ ; NAME: ; where_array.pro ; ; PURPOSE: ; return the indecies of where vector B exists in vector A. ; Basicly a where(B eq A) where B and A are 1 dimensional arrays. ; ; ; CATEGORY: ; Array ; ; ; CALLING SEQUENCE: ; result = where_array(A,B) ; ; INPUTS: ; A vector the might contains elements of vector B ; B vector the we would like to know which of its ; elements exist in A ; ; OPTIONAL INPUTS: ; ; KEYWORD PARAMETERS: ; Common_num array to be filled with the numbers common to ; both arrays ; Com_Dup Array of all values that are alike. This is ; different from Common_num because values can be repeated. ; ; OUTPUTS: ; Index into B of elements found in vector A. If no ; matches are found -1 is returned. If the function is called ; with incorrect arguments, a warning is displayed, and -2 is ; returned (see side effects for more info) ; ; OPTIONAL OUTPUTS: ; ; COMMON BLOCKS: ; None ; ; SIDE EFFECTS: ; If the function is called incorrectly, a message is diplayed ; to the screen, and the !ERR_STRING is set to the warning ; message. No error code is set, because the program returns ; -2 already ; ; RESTRICTIONS: ; This should be used with only Vectors. Matricies other then ; vectors will result in -2 being returned. Also, A and B must ; be defined ; ; ; PROCEDURE: ; ; EXAMPLE: ; idl> A=[2,1,3,5,3,8,2,5] ; IDL> B=[3,4,2,8,7,8] ; IDL> result = where_array(a,b,COMMON_NUM=nums,COM_DUP=all_nums) ; IDL> print,result, nums,all_nums ; ; SEE ALSO: ; where ; ; MODIFICATION HISTORY: ; Written by: Dan Carr at RSI (command line version) …
creator: stl
date: 1994-06-03T13:36:09-00:00

Re: Finding elements in Two Arrays (THE FUNCTION)
type: item
description: Dang... Sorry about this folks, but the routine I just posted has some problems when the input arrays are string arrays. I am looking into it. -stephen -- Stephen C Strebel / SKI TO DIE stl@maz.sma.ch / and Swiss Meteorological Institute, Zuerich / LIVE TO TELL ABOUT IT 01 256 93 85 / (and pray for snow)
creator: stl
date: 1994-06-03T14:55:24-00:00