pro filtzero,a,b,n ;Created 4/9/98 by C See ;This program filters out the common zero elements of arrays a & b ;and returns the resulting array size as n. ;a and b must be the unidimensional and have the same size. ;if all elements are zero, the programs returns n=0 and the arrays, ; a & b are untouched. sa=size(a) sb=size(b) dima=sa(sa(0)) dimb=sb(sb(0)) if dima ne dimb then begin print,'filtzero called with disparent arrays' goto, exit endif ;pack all the data into the top of the arrays... n=dima for i=0,dima-1 do begin if a(i) eq 0. and b(i) eq 0. then begin n=n-1 if i eq dima-1 then goto, shorten_array ;if last then exit loop a(i:n-1)=a(i+1:n) & b(i:n-1)=b(i+1:n) endif endfor shorten_array: if n eq 0 then goto,exit ;if all elements are zero a1=fltarr(n) b1=fltarr(n) a1=a(0:n-1) b1=b(0:n-1) a=fltarr(n) b=fltarr(n) a=a1 & b=b1 exit: return end