필터 지우기
필터 지우기

eigen values of 3D matrix

조회 수: 14 (최근 30일)
tomas
tomas 2012년 4월 17일
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
Friedrich
Friedrich 2012년 4월 17일
do you have Parallel Computing Toolbox?

댓글을 달려면 로그인하십시오.

답변 (2개)

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

Matt Tearle
Matt Tearle 2012년 4월 17일
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.)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by