Eigs passes the wrong StartVector

조회 수: 2 (최근 30일)
Sukhi Singh
Sukhi Singh 2021년 12월 3일
답변: Christine Tobler 2021년 12월 3일
Hi all,
I'm using MATLAB 2019b 64-bits. I'm calling eigs() to find the largest eigenvector of a matrix by passing it a function handle and specifying a 'StartVector' as follows:
A = reshape(1:9,3,3); % create some matrix for testing
StartVector = [0.4 0.9 1.7]'; % specify a start vector for eigs()
[vec,ev] = eigs(@(vec)test_eigs(vec,A),3,1,'largestabs','Display',0,'IsFunctionSymmetric',0,'MaxIterations',300,'StartVector',StartVector);
The definition of test_eigs() is as follows:
function vec = test_eigs(vec,A)
vec = A*vec;
end
However, eigs does not pass the specified start vector to the first call of test_eigs(). Instead, it passes the vector [1 0 0]' on all runs of the program. What am I missing? I'd appreciate any pointers!

채택된 답변

Christine Tobler
Christine Tobler 2021년 12월 3일
The standard method used in EIGS is only efficient for matrices that are quite large. When eigs detects that the input matrix is so small that it will be more accurate and faster to just call EIG instead and extract the requested values from that, it does this instead and most options that affect the standard method's behavior are ignored as that method isn't used.
When a function handle is passed, this means that the function handle is just called on each column of the identity matrix one at a time, to get a matrix representation that can be passed to EIG.
If you increase the size of the input matrix, you'll see the 'StartVector' be passed in on the first call to the function handle:
n = 21;
A = ones(n);
StartVector = flip(1:n)';
[vec,ev] = eigs(@(vec)test_eigs(vec,A),n,1,'largestabs','MaxIterations',300,'StartVector',StartVector);

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by