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

Home » Public Forums » archive » Re: for loop elimination
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: for loop elimination [message #56201] Mon, 15 October 2007 15:48 Go to next message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
jtmcahill@gmail.com wrote:

> Hello,
>
> I have been trying without success to get this simple calculation to
> be done without using a loop. Here it is:
>
> for y2=0L,n2-1 do e_sc[0,y2]=max(abs(sc_arr[*,y2]-model_sc[12:bands
> +11,y2]))
>
> Can I use the max function without and get an array of outputs without
> having to do them one at a time. To put this into context, I have a
> program that this piece of code is in and the program is taking too
> long to compute. I'm figuring I start with eliminating for loops and
> go from there to make it more efficient. Any ideas on this piece?
>
> Hawaiianite


Hi,

MAX() can get a dimension keyword... the help file is pretty straight
forward and contains examples!

Now you can also vectorize the subtraction!

Jean
Re: for loop elimination [message #56366 is a reply to message #56201] Wed, 17 October 2007 19:04 Go to previous message
jtmcahill is currently offline  jtmcahill
Messages: 26
Registered: October 2007
Junior Member
On Oct 15, 12:48 pm, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
> jtmcah...@gmail.com wrote:
>> Hello,
>
>> I have been trying without success to get this simple calculation to
>> be done without using a loop. Here it is:
>
>> for y2=0L,n2-1 do e_sc[0,y2]=max(abs(sc_arr[*,y2]-model_sc[12:bands
>> +11,y2]))
>
>> Can I use the max function without and get an array of outputs without
>> having to do them one at a time. To put this into context, I have a
>> program that this piece of code is in and the program is taking too
>> long to compute. I'm figuring I start with eliminating for loops and
>> go from there to make it more efficient. Any ideas on this piece?
>
>> Hawaiianite
>
> Hi,
>
> MAX() can get a dimension keyword... the help file is pretty straight
> forward and contains examples!
>
> Now you can also vectorize the subtraction!
>
> Jean

Thanks! It tends to be the small things that get missed...

Hawaiianite
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to read file to fill an array "partially" ?
Next Topic: making polygon on top of image in IDL

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

Current Time: Sat Oct 11 02:55:09 PDT 2025

Total time taken to generate the page: 1.03848 seconds