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

Home » Public Forums » archive » Array Concatenation Optimization
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: Array concatenation [message #48961 is a reply to message #42493] Wed, 07 June 2006 06:41 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
maye writes:

> I was searching for an effective way to do this, but can't find anybody
> writing about what (as usual) seems to be an obvious problem/task to
> me. :)
> I don't know how many elements I will collect while scanning a bunch of
> images, so I want to use array concatenation to collect the values like
> this:
> means = [means, currMean]
> But for this to compile/run properly, I need mean to exist before.
> If I do a
> means = 0.
> before the loop, I will always have a zero-element in the beginning
> that I don't want at plotting time. Of course I could remove it with
> means = means[1:*]
> but not only does this waste resources, it also becomes cumbersome if I
> collect 20 different data values, for that I ALL have to remove the
> first value?
> Surely there must be a better way?
> Please help me to program IDL efficiently! :)

I think most people do something like this:

IF N_Elements(means) EQ 0 THEN means = [currMean] ELSE $
means = [Temporary(means), currMean]

Or, did you mean something that doesn't involve any coding? :-)

Be aware that if your loop is large, it is much more
efficient to allocate the memory for your array in chucks
of say 100 or 1000, and then fill it up, then it is to
continuously re-define your array like this.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: End Statement Syntax Problem
Next Topic: Re: IDL and the RAM memory

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

Current Time: Fri Oct 10 15:36:37 PDT 2025

Total time taken to generate the page: 0.87850 seconds