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

Home » Public Forums » archive » Read Total lines in an ASCII file
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: Read Total lines in an ASCII file [message #33302 is a reply to message #33219] Mon, 16 December 2002 12:00 Go to previous messageGo to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
"Robert Moss" <rmoss4@houston.rr.com> wrote in message
news:yhnL9.168422$Gc.5459794@twister.austin.rr.com...
> Mark Hadfield wrote:

>> *snip*
>>
>> ... IDL arrays *look* like they can be extended,
>> but in fact every time you extend an IDL array you
>> create a new one.
>>
>
> What about this then?
>
> array = [ TEMPORARY( array ), new_element ]

Before this statement executes you have an array occupying n*m bytes
of memory, where n is number of elements and m is number of bytes to
store one element. After it executes you have an array occupying
(n-1)*m bytes. There is no way the new array will fit into the space
vacated by the old array, so a new space has to be allocated and all
the old elements copied over. This takes significant time (when n is
large) and doing it repeatedly tends to leave unusable holes all over
the memory space.

There are several things IDL could do to make the above more
efficient:

- Allow arrays to be stored non-contiguously (as Numeric Python
does, for example). Of course this would open up another can of
worms. When your DLM wants to access a non-contiguous array, how
does it no where to find the data?

- Extend arrays in chunks, eg the new array created above would be
larger than the old one by a specified increment or a specified
ratio (1.5 is a good compromise). Then the array could be extended
several more times before the need arose to copy the whole
thing. IDL would have to keep track of the fact that not all of the
allocated space was currently being used.

- Uh, I am sure there are several more but I can't think of any right
now.

I knew this had been discussed on the group some time in the past, so I
searched Google. I found a thread that touches on this entitled "How
to use pointers instead of arrays" and dated 9-10 Dec 2002!

Those who do not remember history are condemned to repeat it, about
once a week.


--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
[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
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: 2002 IDL Christmas Project
Next Topic: Issue Installing IDL 5.6 under Mac OS 10.2.3

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

Current Time: Wed Oct 08 18:41:01 PDT 2025

Total time taken to generate the page: 0.00575 seconds