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 #78551 is a reply to message #78538] Tue, 29 November 2011 04:49 Go to previous messageGo to previous message
Yngvar Larsen is currently offline  Yngvar Larsen
Messages: 134
Registered: January 2010
Senior Member
On Nov 29, 1:40 pm, Yngvar Larsen <larsen.yng...@gmail.com> wrote:

> (1) The original loop is better like this.
>
> FOR k = 0, 359 DO FOR j = 0, 5 DO FOR i=0,1 DO $
>   IF (total(array[i,j,k,*]) gt 0) THEN array[i,j,k,*] = 0

Bug fix. Should be:

FOR k = 0, 359 DO FOR j = 0, 5 DO FOR i=0,1 DO $
  IF (total(array[i,j,k,*] eq 0) gt 0) THEN array[i,j,k,*] = 0



> (3) Since you are operating only on one dimension, it should really be
> the first one for efficiency reasons. So it is better to actually keep
> the data stored that way. If that is not possible, a transpose before
> and after the operation might help you:
[...]
> for ii=0L, nrow-1 do if (total(A[*,ii] eq 0) gt 0) then A[*,ii] = 0

Another bugfix. Should of course be
for ii=0L, nrow-1 do if (total(array[*,ii] eq 0) gt 0) then
array[*,ii] = 0

--
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: Fri Oct 10 07:11:36 PDT 2025

Total time taken to generate the page: 1.04127 seconds