I have an NxN array of 2x2 matrices, and I need to invert each of them. Using Matlab (or user defined functions), is there a way to do this faster than just looping through each one and inverting it? I can assume that they are all invertable and well conditioned.
example:
% dim(A) = 2 x 2 x N x N
I = eye(2);
for i = 1:N
for j = 1:N
exphl(:, :, i, j) = expm(A(:, :, i, j));
for k = 1:M
z = r(k); %constants
zIA = (z*I-A)\I;
exphL1(:, :, i, j) = exphL1(:, :, i, j) + dt*zIA*(exp(z/2)-1);
end
end
end
As a side note, could anyone tell me why the profiler says that the last line "exphL1(:..." takes the most time?