[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Zero vector detection in IDL
- Subject: Zero vector detection in IDL
- From: Frank Morgan <frank.morgan(at)jhuapl.edu>
- Date: Mon, 28 Jun 1999 16:51:31 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: Johns Hopkins University Applied Physics Lab, Laurel, MD, USA
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:15421
Given a big byte or integer array (actually a 1-D vector), is there a
fast IDL way to check whether any non-zero elements exist?
Something like "if (total(x) EQ 0)..." or a where() construct will work,
but scans the whole vector when the first non-zero element is enough to
answer the question. max(x) is even worse.
On the other hand:
for i=0,n-1 do begin
if (x(i) NE 0) then begin
(it's not all zero)
goto, BREAK
endif
endif
BREAK:
will stop early if possible, but looping a
conditional is maybe not the
fastest structure in IDL.
An internal command that implements the loop concept would be what I'm
looking for I think but I don't know if it exists.
Any better ideas?
Thanks,
Frank
frank.morgan@jhuapl.edu