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

Home » Public Forums » archive » Re: Efficient sub array extraction
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: Efficient sub array extraction [message #82420 is a reply to message #82418] Tue, 11 December 2012 15:41 Go to previous messageGo to previous message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
On Tue, 11 Dec 2012 14:26:40 -0800 (PST), markjamie@gmail.com wrote:

> I'm using large 2D arrays e.g 30000 x 30000 and need to remove a 2D sub array for later processing e.g. Rows 30-700 and columns 100-10000.
>
> Is there a more efficient way to do this than using subscript ranges?
>
> For example?
>
> Subarray = largearray[100:10000, 30:700]
>
>
> The exact code I'm using is as follows:
>
> A = [100,10000]
> B = [30,700]
>
> Subarray = largearray[A[0]:A[1],B[0]:B[1]]

Hi Mark,

from my point of view the use of subscript ranges is fine. (However do
not use arrays for subscripting.) Using subscript ranges is fast and
don't need much memory. In the following example roughly about 100
extra bytes are used at creating the subarray:

IDL> array=bindgen(30000,30000)
IDL> a=[100,10000]
IDL> b=[30,70]
IDL> help,/mem
heap memory used: 900729595, max: 900729989, gets: 1073, frees:
232
IDL> subarr=array[a[0]:a[1],b[0]:b[1]]
IDL> help,/mem
heap memory used: 901135568, max: 901135685, gets: 1085, frees:
243
IDL> print,!version
{ x86 Win32 Windows Microsoft Windows 8.0.1 Oct 5 2010 32
64}

Cheers, Heinz
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: increment an array subset based on another subset
Next Topic: Re: array manipulation (TOTAL-ing or MEDIAN-ing) in uneven bins

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

Current Time: Thu Oct 09 20:43:59 PDT 2025

Total time taken to generate the page: 2.00037 seconds