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 #59814 is a reply to message #59678] Wed, 09 April 2008 13:02 Go to previous message
karo03de is currently offline  karo03de
Messages: 21
Registered: March 2007
Junior Member
On 8 Apr., 10:42, "Clemens" <yy...@hotmail.com> wrote:
> it depends on the size of array. Small array is a simple loop.
> Huge one can be :
>
> index_arr = where( arr NE 0)
> print, index_arr[0]
>
> on very huge arrays you can devide arr into big peaces.
>
> Clemens
>
> <smas...@locean-ipsl.upmc.fr> schrieb im Newsbeitragnews:ff3bf651-8707-47e8-8cff-5e694dd5622f@m71g200 0hse.googlegroups.com...
>
>> 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

What about the system function ARRAY_EQUAL ?
Karsten
[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: Wed Oct 22 18:20:04 PDT 2025

Total time taken to generate the page: 0.43832 seconds