;+ ; function vsign(x) ; ; returns total sign of x ; ; Method: counts number of negatives. ; returns -1 if odd, +1 if even, 0 if all x are zero ; ; Fergus Gallagher, RSADU ;- function vsign,x dummy = where(x lt 0,minus) dummy = where(x gt 0,plus) if (plus+minus) eq 0 then return,0 ; all zero v = (minus mod 2) u = 1-2*(v eq 1) return,u end ;+ ; function mtotal(x) ; ; Calculates fast geometric product of a vector x. ; ; Method: ans = exp(total(ln(x))). ; ; Copes with the case if any x negative. ; ; Fergus Gallagher, RSADU. ; Modified to cope with zero elements, D P Steele, ISR. ; ;- function mtotal,x y = abs(double(x)) IF MIN(y) GT 0 THEN BEGIN a = exp(total(alog(y)))*vsign(x) return,a ENDIF ELSE RETURN,0 end