Re: Automatically transform or expand do loop in a subroutine



highegg <highegg@xxxxxxxxx> wrote:

On Jan 31, 7:06 am, nos...@xxxxxxxxxxxxx (Richard Maine) wrote:
yaqi <yaqiw...@xxxxxxxxx> wrote:
I want to save computing time as much as I can.

...

do i=1,d
c = c + i
end do

The "obvious" way to save a lot of computing time here is to replace the
loop with

c = c + d*i

certainly not. c = c + d*(d+1)/2, more likely :)

Um. Er. Right.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.