Faster submatrix selection

Hi,
I've been trying to use mtimesx function for multidimensional multiplication to multiply M1*M2*.... A trial code for this is:
L=1000;
n=10;
a=rand(n,n,L);
for i=1:L
a(:,:,i)=expm(1i*(a(:,:,i)+a(:,:,i)')/2);
end
c=a;
while(L~=1)
L2=floor(L/2)*2;
d=c(:,:,end);
c = mtimesx(c(:,:,1:2:L2-1),c(:,:,2:2:L2));
if(L2~=L)
c(:,:,end+1) = d;
end
L=size(c,3);
end
It works quite well and gives a speed up when L is large but is slow when the dimension n is large. It seems to be due to finding the odd and even submatrices c(:,:,1:2:L2-1) and c(:,:,2:2:L2). Does anyones know how to speed up this process?
Thanks

Risposte (0)

Richiesto:

il 21 Giu 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by