octave, matlab, maxima



~~~

Ok, flowing your advice, I compared the execution time of 2 Maxima and Fortran nested 
do-nothing loops compiled with mode_declare([j,k], fixnum) and implicit none respectively. 
Also I increased the number of loops to overcome process startup time overheads. 
And in the Fortran pgm I added a simple integer counter m=m+1 instruction to to overcome 
the Fortran compiler optimization of the do-nothing loops to zero executed instructions.

The result is that Maxima do-nothing loops compiled using mode_declare are 20 times 
faster than Maxima compilation without it. However Fortran is still 196 times faster 
than Maxima compiled with mode_declare([j,k], fixnum) indexes . 

If I understand your explanation, in Maxima even with the loop index declared fixnum, 
the Maxima index variable remains symbolic that is a symbolic integer expression in the 
body of the for-loop can redefine the index. This does not seem too useful me, 
but I am willing to be convinced otherwise, namely are there algorithm examples 
where the expensive symbolic for-loop index is necessary or useful?
 

Ed

~~~

At 03:55 PM 5/26/2008, Stavros Macrakis wrote:
>On Mon, May 26, 2008 at 3:59 PM, Edward A. Romana <erom at earthlink.net> wrote:
>> Why is the execution time of Maxima for-loop statements different than the equivalent Fortran do-loop execution time.
><...>
>According to Fortran semantics, i and k are implicitly declared
>integer. According to Maxima semantics, all variables are implicitly
>declared "symbolic". Though in principle Maxima could infer that i
>and k are integer-valued in this case, it doesn't (in theory, the user
>could set i to anything in the body of the do, but that would rarely
>be useful).
>
>If you use modedeclare to declare them integer, you should see far
>faster execution.
>
>              -s
>_______________________________________________
>Maxima mailing list
>Maxima at math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima