[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Avoiding a for cicle
- Subject: Avoiding a for cicle
- From: Ricardo Fonseca <zamb(at)physics.ucla.edu>
- Date: Thu, 06 Apr 2000 17:25:16 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: University of California, Los Angeles
- User-Agent: Microsoft Outlook Express Macintosh Edition - 5.0 (1513)
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:19173
Hi
I'm looking for a more efficient way of implementing the following (i.e.
avoiding the for cycle) which is a routine for finding local maximuns
; Data is a 1D Array
s = Size(Data)
nx = s[1]
max_pos = [-1]
for i = 1, nx-1 do $
if ((Data[i] gt Data[i-1]) and (Data[i] gt Data[i+1])) then $
max_pos = [[max_pos],i]
; and then throw away the first element...
Any ideas? Thanks in advance, Ricardo