I tried this:
M = 50; T = 20; N = M*T*20;
A = reshape(1:N,Int(N/(M*T)),M,T);
indxs = rand(1:Int(N/(M*T)),Int(N/(M*T)),M,T);
@time begin
Mat = zeros(size(indxs,1),size(A,2),size(A,3));
for i=1:size(A,2)
for j=1:size(A,3)
Mat[:,i,j] = A[indxs[:,i,j],i,j];
end
end
end
@time @tullio Mat2[c,i,j] := A[indxs[c,i,j],i,j];
and the times were 0.001876 seconds vs. 0.363211 seconds. But I might have done something wrong.