eigs function: incorrect eigenvalues
이전 댓글 표시
I am trying to use the function eigs to obtain several eigenvalues of the smallest magnitude of a singular sparse matrix. This funciton correctly obtaines the zero egienvalue and the corresponding eigenvector, but all non-zero eigenvalues are different from those obtained using the function eig. Moreover, calling eigs several times in a row produces different non-zero eigenvalues. I tried decreasing the tolerance and increasing the number of Lanczos vectors, but that didn't help.
I am attaching a mat file with the matrix. The code that I used for testing is below:
load('test.mat'); % this loads matrix A
[V,D] = eigs(A,5,0);
[V1,D1] = eig(full(A));
댓글 수: 7
Walter Roberson
2019년 5월 9일
I seem to recall that eigs involves a random initialization, and that can matter when the eigenvalues are close together.
Dmitry Kopelevich
2019년 5월 9일
Walter Roberson
2019년 5월 9일
편집: Walter Roberson
2019년 5월 10일
Not a solution but informative https://www.mathworks.com/matlabcentral/answers/356200-eigs-runs-faster-for-more-eigenvalues-of-the-same-matrix
Dmitry Kopelevich
2019년 5월 10일
Walter Roberson
2019년 5월 10일
Was Andrew's FEX contribution useful for you? https://www.mathworks.com/matlabcentral/fileexchange/48-lobpcg-m
Dmitry Kopelevich
2019년 5월 10일
Dmitry Kopelevich
2019년 5월 10일
답변 (1개)
Christine Tobler
2019년 5월 13일
The problem is that the matrix A is badly conditioned:
>> cond(full(A))
ans =
2.206837183464466e+16
This is just around the border of when EIGS (or even MLDIVIDE) would give a warning about the matrix being ill-conditioned. It doesn't happen to give that warning, but the results still come out wrong (I'll investigate exactly why the warning isn't given here).
The reason for the wrong results here is that for a sigma shift, EIGS operates on the inverse of (A - sigma*I): It computes the largest eigenvalues in absolute value of A\x instead of using A*x, and then inverts those eigenvalues to return the eigenvalues of A. But when A is ill-conditioned, A\x doesn't apply the inverse of a in exact arithmetic, because of round-off error.
Unfortunately, there isn't anything that will make this always come out right. For your particular matrix, I've found that moving the shift slightly to the right will make the matrix (A-sigma*I) be better conditioned, and give the correct eigenvalues:
eigs(A, 5, 1e-4)
Another thing that works for this matrix is to request the largest eigenvalues by real value instead of the ones closest to zero (which happen to be the same ones for this matrix):
eigs(A, 5, 'largestreal')
카테고리
도움말 센터 및 File Exchange에서 Linear Algebra에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!