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

Home » Public Forums » archive » Re: Array operation question
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: Array operation question [message #33932 is a reply to message #33930] Fri, 07 February 2003 06:29 Go to previous message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <b207km$enf$1@news.ox.ac.uk>,
Edd Edmondson <eddedmondson@hotmail.com> wrote:

> It's yet another question about how to get an efficient operation on an
> array:
>
> I have one array
> q=[num1,num2,num3,num4]
> and an array
> r=[ [num1a,num1b,num1c...],[num2a,num2b..],[num3a...],[num4a..] ]
> and I want to find w=r-q such that
> w=[ [num1a-num1,num1b-num1,num1c-num1...],[num2a-num2..],[num3a- num3..]..]
>
> Is there an efficient way of doing it without expanding q so that it is
> the same dimension as r? That'd be very expensive in terms of memory for
> me, unfortunately. I could loop over the 4 elements of q and r and do that
> seperately but I'd quite like to eliminate that last loop.
>
> I've tried various things but all fall victim to the 'feature' mentioned
> earlier that IDL will make the result have the dimensions of the smaller
> array.

The first rule of thumb of optimization is "optimize the innermost
loop", so

FOR j = 0, nj-1 DO w[0,j] = r[*,j]-q[j]

will be pretty efficient if the first dimension or r is large. (Note
that the zero on the lhs is important for efficiency.)

Ken Bowman
[Message index]
 
Read Message
Read Message
Previous Topic: Array operation question
Next Topic: IDL executable compile options for FPE

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

Current Time: Sat Oct 11 08:50:24 PDT 2025

Total time taken to generate the page: 0.48344 seconds