comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Speedy way to get compare array elements. . .
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Speedy way to get compare array elements. . . [message #32835 is a reply to message #32828] Wed, 13 November 2002 20:28 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"Sean Raffuse" <sean@me.wustl.edu> writes:
> Exalted newsgroup,
>
> What is the fastest way to compare two adjacent values in an array?
>
> Something like:
>
> whoa_huge_jump = where(A[i+1]-A[i] GT 500)

I usually use this little bit of magic,

whoa_huge_jump = where(A[1:*]-A GT 500)

Now, if you are a goody goody, the correct way to do the subtraction
is A[1:*]-A[0:N-2], but that can get annoying, especially if you have
to figure out N first. The cool thing about the trick is that IDL
*automatically* truncates the vector A so that it matches the length
of A[1:*].

Some people on the newsgroup thing it is too obscure, but heck, I have
to have something to distinguish my own style.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: georeferencing satellite data
Next Topic: Running FlexLM on OS X

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:39:00 PDT 2025

Total time taken to generate the page: 0.00408 seconds