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

Home » Public Forums » archive » 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 #59770 is a reply to message #59680] Tue, 08 April 2008 07:23 Go to previous message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Tue, 8 Apr 2008, smasson@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
>

(where(array))[0] will be a little bit faster, because it spares a temp
array creation and write.

regards,
lajos
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Stacked Column Bar Plots
Next Topic: Annc: O-Matrix 6.4

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

Current Time: Fri Oct 10 10:02:36 PDT 2025

Total time taken to generate the page: 1.20159 seconds