FUNCTION intersection,a,b ;+ ; general purpose routine to return the intersection ; (i.e. common elements) of two vectors. Uses USERLIB ; routine UNIQ to obtain unique elements of a,b ; Written by M.J.Dutch June-1994. ; Centre de Recherches en Physique des Plasmas, EPFL, Switzerland ;- ab=[a(uniq(a,sort(a))),b(uniq(b,sort(b)))] ; combine unique elements of a,b ab=ab(sort(ab)) ; sort the combined vector nab=n_elements(ab) diff=ab(1:nab-1)-ab(0:nab-2) ind=where(diff eq 0) ; find repeated elements if (ind(0) ne -1) then return,ab(ind) else return,-999 end