Den 19.07.2011 11:05, skrev Carlos Becker:


N = 100;

tic;

for I=1:N

    k = m - 0.5;

end

toc / N

--------------------------------------------


m = rand(2000,2000);

Here, Matlab's JIT compiler can probably hoist the invariant out of the loop, and just do

   I=N
   k = m - 0.5

Try this instead:

   for I=1:N

      k = I - 0.5;

end


S.M.

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to