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

Home » Public Forums » archive » Re: How to speed up code which checks lots of values of 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: How to speed up code which checks lots of values of an array [message #74365 is a reply to message #74363] Thu, 13 January 2011 08:26 Go to previous messageGo to previous message
Axel Martínez is currently offline  Axel Martínez
Messages: 22
Registered: June 2010
Junior Member
On Jan 13, 5:06 pm, Robin Wilson <ro...@rtwilson.com> wrote:
> Hi all,
>
> I've been writing some code which checks that all of the values in one
> half of an array are less than a threshold, and all of the values on the
> right half of an array are greater than a threshold. I've written the
> code below, which seems to be a fairly clean way of writing it, and
> works for any length of array (which is important for my use of it).
>
> However, it's not very fast. I wondered if it might be able to be sped
> up using some sort of magic like the Histogram command... Any ideas?
>
> ---CODE---
> ; Assume we're given a 1D array called line with our values in it
>
> len = N_ELEMENTS(line)
>
> section_len = (len - 1) / 2
>
> ; Get the left-hand half of the array
> LHS = line[0:section_len - 1]
> RHS = line[section_len + 1: len - 1]
>
> res = WHERE(LHS GT 180, LHS_count)
> res = WHERE(RHS LT 180, RHS_count)
>
> IF LHS_count EQ 0 AND RHS_count EQ 0 THEN BEGIN
>    ; Do stuff
> ENDIF
>
> ---END CODE---
>
> Cheers,
>
> Robin

Hi Robin,

Try that:

IF(MAX(line[0:section_len - 1]) LE 180) AND (MIN(line[section_len + 1:
len - 1]) GE 180) THEN
; Do stuff
ENDIF
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL 8.0 plot lat/lon data into map
Next Topic: Columnist Talking About Newsgroup

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

Current Time: Sat Oct 11 13:02:48 PDT 2025

Total time taken to generate the page: 0.71933 seconds