If you want better performance then don't use 2D Math mode to enter procedures which call  `.` (dot).

The following timings are not the result of the order in which the cases are performed. The timings stay roughly the same if the blocks delimited by restarts are executed out of order.

 

First, the scalar case.

 

restart:

f:=proc(a) a.a end proc:

st:=time():

for i from 1 to 10^6 do

  f(4);

end do:

time()-st;

restart:

st:=time():

for i from 1 to 10^6 do

  f(4);

end do:

time()-st;

 

Next, the 2x2 Matrix case

 

restart:

f:=proc(a) a.a end proc:

st:=time():

for i from 1 to 10^6 do

  f(<<4,3>|<1,2>>);

end do:

time()-st;

restart:

st:=time():

for i from 1 to 10^6 do

  f(<<4,3>|<1,2>>);

end do:

time()-st;

 

Download 2dmath_dot_perf.mw

acer


Please Wait...