eigen value problem for sparse matrices
20 次查看(过去 30 天)
显示 更早的评论
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 个评论
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
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 个评论
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|.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
