compilation (was Re: octave, matlab, maxima)



Insert a modedeclare into your function and try again; something like:

(%i1) f(n):=for j:1 thru n do (for k:1 thru n do return)$

(%i2) g(n):=(modedeclare(n, fixnum, j, fixnum, k, fixnum),for j:1 thru n do
  (for k:1 thru n
  do return))$
(%i4) f(1000)$
Evaluation took 5.3400 seconds (5.3400 elapsed)

(%i5) g(1000)$
Evaluation took 5.1800 seconds (5.1800 elapsed)

(%i6) compile(f,g)$

(%i7) f(1000)$
Evaluation took 0.9200 seconds (0.9200 elapsed)

(%i8) g(1000)$
Evaluation took 0.2500 seconds (0.2500 elapsed)

That's faster.

Barton

-----maxima-bounces at math.utexas.edu wrote: -----

>Why is the execution time of Maxima for-loop statements different
>than the equivalent Fortran do-loop execution time.
>
>For example the execution time of the time the nested Maxima for-loop is:
>
>(%i23) for j:1 thru 1000 do (for k:1 thru 1000 do return);
>Evaluation took 3.9800 seconds (3.9800 elapsed)