When eigs uses a custom function as input, it cannot compute an eigenvalue near a specified sigma
조회 수: 2 (최근 30일)
이전 댓글 표시
As the title says, the eigs function is used to compute the eigenvalues of a 10 by 10 symmetric matrix, specify a sigma, and obtain several eigenvalues near the sigma.
The following three methods are used, the first is to solve the first five smallest eigenvalues, the second is to specify a sigma, calculate the five nearby eigenvalues, this method is no problem.
However, the third method, which turns the matrix into a custom function input to the eigs and calculates the eigenvalues near sigma, results in an error, and does not get the correct eigenvalues, the results are some numbers close to sigma.
n = 10;
A = randn(n);
A = A + A';
while rank(A) < n
A = randn(n);
A = A + A';
end
[V1,E1]=eigs(A,5,'sa');
sigma = E1(2,2)+1;
[V2,E2]=eigs(A,5,sigma);
[V3, E3] = eigs(@(x) customFunction(A, x), size(A, 1), 5, sigma);
digits = 3;
E1 = round(E1, digits)
E2 = round(E2, digits)
E3 = round(E3, digits)
function y = customFunction(A, x)
y = A*x;
end
댓글 수: 1
Christine Tobler
2024년 3월 13일
When EIGS uses a custom function and the mode is not "largestabs", this custom function must solve a linear system with the matrix A, shifted by sigma. See the doc.
You can also use the "Display" option which will tell you what EIGS assumes your function handle is computing.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!