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

Home » Public Forums » archive » Re: fastest way to find the first non-zero value in an array
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: fastest way to find the first non-zero value in an array [message #59672 is a reply to message #59671] Tue, 08 April 2008 06:56 Go to previous messageGo to previous message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Apr 8, 2:15 pm, Vince Hradil <hrad...@yahoo.com> wrote:
> On Apr 8, 3:04 am, smas...@locean-ipsl.upmc.fr wrote:
>
>> Hi,
>
>> I want to find the first non-zero value of an array. Is there a faster
>> way to do this than with the "where" command: (where(array ne 0))[0]
>> "Where" will look for all non-zero values and I only need the first
>> one. It would be great if I could stop "where" in its search process
>> as soon as it found one element...
>
>> sebastien
>
> Wow - I'd be interested in knowing how slow 'where' is. Are we
> talking the difference between 0.01 seconds and 0.05 seconds? Or even
> the difference between 1 and 5 seconds? Time is money, but at what
> point does our 'need for speed' end?

You make a good point, Vince.

If anyone can find an array that IDL actually searches faster using my
Histogram-and-small-Where setup than by using "Where" on its own, let
me know! :-)

Chris
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: array concatenation in 2-D
Next Topic: Re: Avoiding FOR loops (version googleplex.infinity)

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

Current Time: Thu Oct 09 07:23:26 PDT 2025

Total time taken to generate the page: 1.04025 seconds