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

Home » Public Forums » archive » Re: Search single column of array - removing nasty loop
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: Search single column of array - removing nasty loop [message #78527 is a reply to message #78512] Wed, 30 November 2011 12:15 Go to previous messageGo to previous message
Yngvar Larsen is currently offline  Yngvar Larsen
Messages: 134
Registered: January 2010
Senior Member
On Nov 29, 6:53 pm, Heinz Stege <public.215....@arcor.de> wrote:
> Hi Rob,
>
> no loop necessary:
>
> array=(randomu(seed,2,6,360,42)-.1)>0.   ; sample array
> array=reform(array,n_elements(array)/42,42,/overwrite)
> ii=where(min(array,dim=2) eq 0.,count)
> if count ge 1 then array[ii,*]=0.
> array=reform(array,2,6,360,42,/overwrite)

Hm. The /OVERWRITE keyword to REFORM was new to me. Thanks!

Silly me. I have somehow always imagined that the compiler was smart
enough to do this (i.e. not copy any data, only alter the internal IDL
descriptor of the ARRAY variable) automatically when input and output
to REFORM is the same variable. But a bit of profiling shows this is
not at all the case. This will be _very_ useful many places in my
operational code...

A small comment to the code above: "where(min(array,dim=2) eq 0.)"
obviously only works if array contains only non-negative data. If not,
"where(total(array eq 0, 2) gt 0)" will do the trick also for floating
point data containing negative numbers, with more or less the same
performance.

--
Yngvar
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: GsLib
Next Topic: IDL's thread pool

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

Current Time: Sat Oct 11 17:28:14 PDT 2025

Total time taken to generate the page: 1.35891 seconds