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

Home » Public Forums » archive » Re: Cyclic array interfaces
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: Cyclic array interfaces [message #40198 is a reply to message #40193] Tue, 13 July 2004 05:59 Go to previous messageGo to previous message
cedricl is currently offline  cedricl
Messages: 8
Registered: July 2004
Junior Member
Since you're aiming for optimization, I might as well point out an
obvious one:

> A=[[1,2,3],[4,5,6]]
> B=[7,8,9]
> A[*,1]=B

Use A[0, 1] = B instead, since the elements are contiguous in the
first dimension. You might also want to take a loot at "temporary" if
you haven't already.

> (e.g. Does IDL actually rewrite the entire array, regardless of how many
> elements are being changed,

No.

> or does it only change the particular elements
> and hence the first example should be about twice as fast as the second)?

It doesn't work that way, like the previous poster has shown. Your
performance mostly depends on the type of access that you're doing. If
you're accessing memory in a continuous fashion (the first dimension
varies), it's almost sure IMO that it's going to be faster.
Furthermore, consider the next example:

a = fltarr(5)
; Option 1: Create a new array
a = [3, 4, 5, 6, 7]
; Option 2: Rewrite the array
a[0] = [3, 4, 5, 6, 7]

Option 1 and 2 are equivalent, code-wise, but I would argue (and of
course, profile, were I not lazy) that option 2 is faster, because it
doesn't have to deallocate the array that was already contained in a,
and allocate a new one. Of course, there are many other optimizations
that IDL could do that would make 1 faster than 2, but considering
RSI's approach to compile-time optimizations, I'm confident in my
analysis.

Cedric
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Collection of different size arrays?
Next Topic: IDL FFT Source Code

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

Current Time: Sat Oct 11 10:31:31 PDT 2025

Total time taken to generate the page: 0.08605 seconds