eigen values of 3D matrix

8 views (last 30 days)
tomas
tomas on 17 Apr 2012
Hello,
I need to compute eigen values of 3D matrix, something like 3x3x30000, means 30000 different 3x3 matrices. Do you have any suggestions how to do it without the "for" loop?
I've tried convert the large matrix to the cell format and do it through cellfun(@eig...) and it takes for 17 seconds but problem is that I need to do it for 150 times. So, it's still 45 minutes. Any improvement will be appreciated.
Thanks
  1 Comment
Friedrich
Friedrich on 17 Apr 2012
do you have Parallel Computing Toolbox?

Sign in to comment.

Answers (2)

James Tursa
James Tursa on 17 Apr 2012
You can try Bruno Luong's small size multi-eigenvalue solver on the FEX:

Matt Tearle
Matt Tearle on 17 Apr 2012
I have suggestions how to do it without the for loop, but not in a way that will speed things up! :) Making a block diagonal or such-like just slows things down with the memory it chews up.
So: sorry, it looks like looping is your best option. If you have Parallel Computing Toolbox, you can at least distribute this task, which might give you some improvement.
I wondered about writing your own eig function for the special case of 3-by-3, but it's hard to beat the built-in eig.
Here's my experiment:
n = 30000;
x = randi(10,[3,3,n]);
tic
ev1 = zeros(3*n,1);
for k = 1:n
j = 3*k;
ev1(j-2:j) = eig(x(:,:,k));
end
toc
tic
ev2 = zeros(3*n,1);
for k = 1:n
j = 3*k;
ev2(j-2:j) = eig3by3(x(:,:,k)); % my own eig for 3x3 matrices
end
toc
tic
y = num2cell(x,[1,2]);
z = cellfun(@eig,y,'unif',false);
ev3 = cat(1,z{:});
toc
Output:
Elapsed time is 0.315167 seconds.
Elapsed time is 0.814756 seconds.
Elapsed time is 0.281028 seconds.
Out of curiosity, what version of MATLAB are you running? (Note the significant difference in run times I get from what you were getting.)

Categories

Find more on Linear Algebra in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!