Slow power of matrix computation
Reported by Claude GOMEZ
The computation of a power of matrix is very slow compared to a naive computation.
n=1000; k=10;
M=rand(1000,1000);
// 21.1 seconds !!!
tic; pM1=M^k; toc
// 0.382 second
tic;
pM2=eye(M);
for i=1:k
pM2=M*pM2;
end
toc
norm(pM2-pM1)/norm(pM1)