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

Home » Public Forums » archive » Sky Falling, etc. : Array substitution + addition with plus-equal (+=)
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: Sky Falling, etc. : Array substitution + addition with plus-equal (+=) [message #53016 is a reply to message #52941] Tue, 13 March 2007 11:35 Go to previous messageGo to previous message
MarioIncandenza is currently offline  MarioIncandenza
Messages: 231
Registered: February 2005
Senior Member
Thanks for the great explanations, that one really had my head
spinning.

> One additional point is worth mentioning: when setting large arrays, the
> "offset" method of specifying a single index on the LHS is much faster
> than the '*' method of building the full index list to match up the
> dimensions of left and right-hand side arrays:

Well, yes. Which is how I came across this problem. The "offset"
method does not work for "+=" or any of the "iterative" operations,
because of the behavior you described.

My application is building a grand [X,Y,T] sum, from contributions of
a routine which returns an [X,Y,n] array, with n varying from, say, 1
to 10. Without the increment operation, I have to do

totals=fltarr(2,2,6);
add=GetAdd(InputArgs,ReturnT0=T0); Get ADD and the initial index in T
(T0)
sz=size(add)
if(sz[0] eq 2) then NT=1 else NT=sz[3]; get size of 3rd dimension
T1=T0 + NT - 1
previous_totals=totals[*,*,T0:T1]; extract subarray corresponding to
ADD
totals[0,0,t0] = previous_totals + add ; copy new totals back into
TOTALS

Which comes at considerable computational cost. But, that's life.
Thanks again for the explanations.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: randomn problem
Next Topic: Re: Array resize with arbitrary arithmetic

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

Current Time: Sun Oct 12 07:37:45 PDT 2025

Total time taken to generate the page: 0.56108 seconds