comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: The intersection of 2 arrays - where_ar.pro [1/1]

Re: The intersection of 2 arrays - where_ar.pro [1/1]
type: item
description: David P. Steele wrote: > > The attached routine (WHERE_ARRAY.PRO) was posted a few years back on this > newsgroup, courtesy of Stephen Strebel. It uses a vector algorithm, and does > what I think Phil wants to do. Just make sure you don't try and use it with big arrays -- it's an n^2 algorithm (versus the n algorithms posted prior). E.g., to compare two floating 128x128 arrays for overlapping values, the program would create 3 arrays, each of which takes 1 GB! The routine match() is likely much more efficient for doing intersections on big arrays. (Unless you have some serious RAM on your machine). JD
creator: J.D. Smith
date: 1997-03-04T08:00:00-00:00

Re: The intersection of 2 arrays - where_ar.pro [1/1]
type: item
description: --*-*-*- Next Section -*-*-* Content-Type: Text/Plain; charset=US-ASCII In article <331B37EE.41C6@irc.chmcc.org>, williams@irc.chmcc.org says... > > I know that I can find the union of two arrays by doing something like > > temp = [array1, array2] > union = temp(uniq(temp, sort(temp))) > > But how would I go about finding the intersection of the two arrays? > i.e. Is there a nice vector way of doing it rather than brute force? > (aka: Which IDL function did I miss this time?) > > Thanks in advance, > Phil > -- > /*********************************************************** ********/ > Phil Williams, Ph.D. > Research Instructor > Children's Hospital Medical Center "One man gathers what > Imaging Research Center another man spills..." > 3333 Burnet Ave. -The Grateful Dead > Cincinnati, OH 45229 > email: williams@irc.chmcc.org > URL: http://scuttle.chmcc.org/~williams/ > /*********************************************************** ********/ The attached routine (WHERE_ARRAY.PRO) was posted a few years back on this newsgroup, courtesy of Stephen Strebel. It uses a vector algorithm, and does what I think Phil wants to do. Good luck! Dave ------------------------------------------------------------ ------------ David P. Steele Ph: (306) 966-6447 ISAS, University of Saskatchewan Fax: (306) 966-6400 116 Science Place David.Steele@usask.ca Saskatoon SK S7N 5E2 DANSAS::STEELE --*-*-*- Next Section -*-*-* Content-Type: Text/Plain; charset=ISO-8859-1 ; ;+ ; NAME: ; WHERE_ARRAY ; ; PURPOSE: ; Return the indices where vector B exists in vector A. ; Basically 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 that might contains elements of vector B ; B vector that we would like to know which of its ; elements exist in A ; ; OPTIONAL INPUTS: ; ; KEYWORD PARAMETERS: ; iA_in_B return instead the indices of A that are in ; (exist) in B ; ; OUTPUTS: ; Index into B of elements found in ve…
creator: David.Steele
date: 1997-03-04T08:00:00-00:00