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

Home » Public Forums » archive » Modifying an array while conserving memory
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: Modifying an array while conserving memory [message #30963 is a reply to message #30878] Fri, 24 May 2002 08:38 Go to previous messageGo to previous message
Xiangyun Qiu is currently offline  Xiangyun Qiu
Messages: 6
Registered: November 2001
Junior Member
Randall Skelton wrote:
Hi there,

Provided TEMPORARY() function works as we expect, I think the following
steps can
use less memory:

a = findgen(1000)
b = randomu(seed,100)
a = shift(TEMPORARY(a), 500)
c = [TEMPORARY(b),TEMPORARY(a)]
c = Shift(TEMPORARY(c), 500) ; here happens to be 500 too, because
500 = 1000 - 500

This solely rely on TEMPORARY function, live or die with it.

Xiangyun

>
> Hi all,
>
> I have a large array and I would like to 'insert' some data into the
> middle of it. Imagine an array of 1000 points and having 100 points to
> insert beginning at index 500 (the resulting array will have 1100 points).
> Typically, I do not know the length of data I wish to insert until after
> 'a' is defined.
>
> a = findgen(1000)
> b = randomu(seed,100)
> c = fltarr(1100) ; seems wasteful to use more memory
> c[0:499] = a[0:499]
> c[500:599] = b
> c[600:1099] = a[500:999]
>
> In reality, 'a' is of order 2e7 so I would like to avoid making
> multiple copies of it. Does anyone have any suggestions regarding the
> most memory efficient way of doing this?
>
> Many thanks,
> Randall

--
Xiangyun
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Modifying an array while conserving memory
Next Topic: url_get and idl -rt

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

Current Time: Wed Oct 08 17:24:51 PDT 2025

Total time taken to generate the page: 0.00385 seconds