Re: for loop elimination [message #56201] |
Mon, 15 October 2007 15:48  |
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  |
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
|
|
|