eigen value problem for sparse matrices
이전 댓글 표시
Hi, I need to calculate all eigen values and eigen vectors of a very large sparse matrix(above 20k*20k) but an out of memory error will occure! how can I overcome this problem? thank you.
댓글 수: 8
Matt J
2018년 8월 22일
What are you going to use the eigenvectors/values for?
And how much memory do you have? 20k x 20k isn't all that large. Only 3GB.
KSSV
2018년 8월 22일
Have a look on eigs.
amirhossein amirabadi
2018년 8월 22일
편집: amirhossein amirabadi
2018년 8월 22일
amirhossein amirabadi
2018년 8월 22일
amirhossein amirabadi
2018년 8월 28일
amirhossein amirabadi
2018년 8월 28일
편집: amirhossein amirabadi
2018년 8월 28일
Andrew Knyazev
2018년 9월 21일
If the matrix is real symmetric or Hermitian, you may also want to try https://www.mathworks.com/matlabcentral/fileexchange/48-lobpcg-m
채택된 답변
추가 답변 (2개)
Christine Tobler
2018년 8월 22일
편집: Christine Tobler
2018년 8월 22일
The problem is that the eigenvectors of a sparse matrix are dense (in all practically relevant cases), so to store them would require 3GB. Additionally, the algorithm requires some workspace, which will also be several GB.
One thing you can try is to use the 'vector' option, which saves memory because the eigenvalues are returned as a vector instead of a diagonal matrix (will need 3GB less memory):
[U, D] = eig(full(yourMatrix), 'vector');
I tried on my computer with this formula, and it took about 10GB of memory (and ran for 8 minutes), so you'll need a machine with more than this to compute all eigenvalues and eigenvectors of this matrix.
Note I'm assuming your matrix is symmetric; a non-symmetric matrix may require more memory than this.
Christine Tobler
2018년 8월 23일
0 개 추천
There aren't any practical algorithms for computing eigenvalues one by one. You can compute a subset of eigenvalues around a given value using eigs (assuming that you can solve a linear system with your matrix without going out of memory). This way, you could run through the spectrum of the matrix, and try to get all the eigenvalues, but this is quite a messy approach.
If the matrix is too large to solve a linear system with in memory, there is no way to compute anything except a set of its extreme eigenvalues using eig and eigs in MATLAB.
There are some iterative methods available that, instead of solving a linear system, would require a preconditioner (a matrix that is very similar to the inverse of the original matrix, but can be applied more quickly). It's typically quite tricky to find a good preconditioner, and very dependent on the structure of the matrix coming in.
댓글 수: 2
amirhossein amirabadi
2018년 8월 23일
편집: amirhossein amirabadi
2018년 8월 23일
Christine Tobler
2018년 8월 24일
So if you have enough memory to compute all the eigenvalues (can you really do this for your 350k problem?), you could use the fact that A*x - d*x = 0, and solve the linear system (A - d*I) * x = 0. This has the problem that the matrix on the left-hand side matrix is singular - but you can instead choose a number a bit off from d, (maybe 1e-5? Depends on the other sizes), and calling eigs to compute the closest few eigenvalues and eigenvectors to that shift.
This will not be cheap, because the shifted matrix A - d*I has to be factorized for each shift, but it does compute each eigenvector separately (assuming that you can factorize A - d*I i memory|.
카테고리
도움말 센터 및 File Exchange에서 Linear Algebra에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
