I've noticed that indexing expressions on large arrays can be quite slow, even if the indexes are mostly sequential. In the code below, the first loop takes 1.91 seconds while the second takes 0.11 seconds. Any suggestions on how to get around this would be much appreciated, even looking at Octave's source.
a = rand(300); tic for i = 1:100 a(1:(size(a, 1) - 1), :) += a(2:size(a, 1), :); endfor toc