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

Home » Public Forums » archive » Array concatenation
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 #62806 is a reply to message #48962] Fri, 03 October 2008 18:11 Go to previous messageGo to previous message
Karl[1] is currently offline  Karl[1]
Messages: 79
Registered: October 2005
Member
On Oct 3, 3:16 pm, lecacheux.al...@wanadoo.fr wrote:
> On 3 oct, 17:15, Joost Aan de Brugh <joost...@gmail.com> wrote:
>
>
>
>> On Oct 3, 1:19 pm, lecacheux.al...@wanadoo.fr wrote:
>
>> Hello,
>
>> Maybe it has something to do with the array descriptor. Anyway, in a
>> large group concatenation is not the most elegant way. In Matlab (a
>> language similar to IDL), you get a warning if you use such a
>> construction. It has to do with the fact that if your array grows, you
>> ask your system for more space. A safer way is to ask for enough space
>> at once.
>
>> afh = a few 100
>
>> b = BytArr(afh*1000) ; Here is where you ask for a lot of space.
>> for i=0,999 do begin
>>   ... compute a = array of bytes (a few 100) ...
>>   b[i*afh:(i+1)*afh-1] = a ; Now b does not grow in the loop
>> end
>
>> Or use a 2D array
>
>> b = BytArr(afh,1000) ; Here, you ask for the space again.
>> for i=0,999 do begin
>>   ... compute a = array of bytes (a few 100) ...
>>   b[*,i] = a ; Now b does not grow in the loop
>> end
>
>> Cheers,
>> Joost
>
>> b = Reform(b,afh*1000) ; Or b = Reform(b,N_Elements(b))
>
>> It is a bit harder if you have different 'a few 100's for each
>> iteration
>
> Thanks for your reply. I agree with you that such a programming style
> is far from ideal.
> My point is that it likely can produce some not obvious array boundary
> error (and subsequent IDL crash),
> while largest used array sizes remain far below the maximum authorized
> one.
> Or I missed something ?
> alx.

I dunno, I think that there's something else going on. IDL should
fail gracefully if it runs out of memory allocating that array over
and over, even if you are chewing up space and causing a lot of
fragmentation. How big is the array actually getting when you crash?
I just tried it on linux with an array size of 500 and looping 25,000
times with no issue at all. Are you pushing up against the max virt
mem in your machine? If you are indeed paging, Windows can get a
little unstable under excessive paging.

The COMPILE_OPT IDL2 note is interesting too. Recall that if you
don't specify this, integers are 16-bit, and 32-bit if you do. What
does your code specified by "... compute a = array of bytes (a few
100) ... " do? Does it call a custom DLM? Is there something that
would break or overflow if ints are 16-bit? Still, IDL checks array
accesses at run time, so a bad array index shouldn't cause a crash.
It may be worth taking a closer look at why IDL2 makes a difference.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL slow to load command prompt
Next Topic: The usage of PS_END

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

Current Time: Thu Oct 09 02:48:40 PDT 2025

Total time taken to generate the page: 0.88044 seconds