WHEREIN Function
Find the indices into an array where the values occur in a second array; keywords yield intersection, union, and complement
enabled when the Sorted keyword is used.
Usage
i = WHEREIN( a, b[, c] )
Input Parameters
a — The array you are searching.
b — The array containing the values you are searching for.
Output Parameters
c — (Optional) A scalar representing the number of matches found.
Returned Value
i — The array of indices such that each element in a(i) occurs in b; if no matches were found, then a scalar –1 is returned.
Keywords
Sorted — If set, indicates that a is sorted, either ascending or descending.
 
note
Only the Outall keyword can be used when this keyword is set, all other keywords are ignored. Setting this keyword allows faster search algorithms to be used with less memory required.
Output Keywords
 
note
For unsorted numerical data, if keywords j and B_Complement are not set, a more efficient algorithm is used.
j — The array of indices such that each element in b(j) occurs in a; if no matches were found, then a scalar –1 is returned.
Intersection — The vector of elements common to both a and b; if there are no such elements then nothing is returned.
Union — The vector of elements in either a or b.
A_Complement — The array of indices into a where the values do not occur in b; if there are no such indices then –1 is returned.
B_Complement — The array of indices into b where the values do not occur in a; if there are no such indices then –1 is returned.
Outall — The array of 0s and 1s (of the same size as a) such that i = where(Outall).
Example 1
The following example prints the array of indices returned by WHEREIN when searching the array a (0,1,2,3,2) for the values in array
b (0,0,4,2,5,5,6,0).
PM, WHEREIN( [0,1,2,3,2], [0,0,4,2,5,5,6,0] )
; PV-WAVE prints the following:
; 0
; 2
; 4
See Also