Fast Computation of Eigenvectors of a Sparse Matrix - matlab

I am working on a project that involves the computation of the eigenvectors of a very large sparse matrix.
To be more specific I have a Matrix that is the laplacian of a big graph and I am interested in finding the eigenvector associated to the second smallest eigenvalue.
Of course Matlab takes ages to compute the eigenvectors, even because it computes all of them.
Any suggestions?
Thank you very much
Andrea

Have you tried this usage of eigs:
[v,c]=eigs(A,2,'sm');
for example:
A = delsq(numgrid('C',256));
[v,c]=eigs(A,2,'sm');
generates a ~50K x 50K sparse matrix and find its 2 smallerst eigenvalues and eigenvectors in about 1 second in my old laptop...

Related

How expensive is it to compute the largest eigenvalue and corresponding eigenvector of n-by-n Hermitian matrix?

There was a similar question: How expensive is it to compute the eigenvalues of a matrix?
And the answer was big-Oh(n^3) for square and symmetric matrices.
What about the largest eigenvalue and corresponding eigenvector of n-by-n matrix?
Here I assume that matrix is square and Hermitian. I think it is still must be faster than big-Oh(n^3) because we are interested only on the largest eigenvalue and the corresponding eigenvector.
This is the Matlab code that I currently use, but I don't think it is best, because I still compute all eigenvalues instead of largest and sort them.
A=2.*rand(3,3)-1*ones(3,3)+i*(2.*rand(3,3) -1*ones(3,3));
[v,e]=eig(A+A');
[d,ind] = sort(diag(e),'descend');
e=d(1)
v = v(:,ind);
v(1:3,1)
Try this:
A=2.*rand(3,3)-1*ones(3,3)+i*(2.*rand(3,3) -1*ones(3,3));
[v,e]=eigs(A+A',1,'largestabs');
Please, let me know how it goes!

Solving eigenvectors/eigenvalues of sparse matrix in different ranges successively

I'm looking for eigenvalues/eigenvectors of a huge sparse matrix A (250k*250k) that lie in different eigenvalue ranges without calculating all the eigenvalues in between since it would just take too much time.
My consideration was
Step1:
I'm trying to find k certain eigenvalues/eigenvectors of the matrix A close to a defined value sigma1. Therefor I'm using [V1,D1] = eigs(A,k,sigma1). So far it's not a big deal.
Step2: I do the same for a sigma2 < sigma1 (So I'm skipping the eigenvalues between sigma1 and sigma2) [V2,D2] = eigs(A,k,sigma2).
Unfortunately the eigenvectors V2 of Step2 are not othogonal with respect to the eigenvectors V1 of Step1. They don't seem to have the same basis as the eigenvectors V1. Is there a way to force Matlab to the same basis or somehow feed the eigs command with the eigenvectors found in Step1 ?
Using the same starting vector for Step1 and Step2 unfortunately did't help. Thank you in advance for your help!

MATLAB: Eig algorithm and alternatives

I am simulating a physical system, where I need to calculate the eigenvalues and vectors of a very large (~10000x10000) matrix.
So far I have used the in-built Eig algorithm in MATLAB but it is very slow for large matrices. Is there other algorithms in MATLAB that would do a better job or can I somehow improve the performance of Eig? Specifically it turns out that I only need the first ~100 eigenvectors of the matrix starting from the smallest numerical eigenvalue. Is there a way to get the algorithm to calculate only the first N eigenvectors and eigenvalues to save computation time? Of course this would only work if the eigenvectors come out sorted but they seem to do so, because of the symmetry of the Matrix I am using.
Your matrix has mostly zeros, so you should make it a sparse matrix. You'll then be able to use EIGS to calculate a smaller number of eigenvalues and eigenvectors.
http://www.mathworks.com/help/matlab/ref/eigs.html

MATLAB: Get small eigenvalues from `eigs` in sorted order

For example, eigs(A,k,'sm') returns the k smallest magnitude eigenvalues. However, eigs does not take care of the sign. Edit: eigs(A,k,'sr')takes care of it.
Say A is 500 by 500 sparse matrix. Without getting all eigenvalues like in eig, how to get the smallest 3 eigenvalues (not magnitude) and the corresponding eigenvectors for eigs in a sorted way efficiently?
This can be done easily by getting all eigenvalues in eig by sorting but I cannot use eig for some reasons as it takes a long time and huge memory to convert to full matrix and compute all eigenvalues.
Edit: This can also be done by eigs(A,k,'sr') and do the sorting myself. But is there a faster method or option in eigs to do so?
It should not do that unless there is a syntax error or your matrix has all the eigenvalues with positive real part. This gives the correct negative signed smallest real part (I guess that's what you mean by small) eigenvalues on R2016a. Note that smallest eigs are complex conjugates and one pair is given by only its negative imaginary part.
A = sprand(100,100,0.5);
[V,D] = eigs(A,3,'sr')

Matlab - calculating max eigenvalue of a big sparse (A'*A) matrix

I have a big (400K*400K) sparse matrix and I need to calculate the largest eigenvalue of A'*A.
The problem is that Matlab can't even calculate A' due to memory problems.
I also tried [a,b,c] = find(A) and then transpose by creating a transpose sparse matrix, but although the find() works, the sprase creation doesn't.
Is there a nice solution for this? it can be either in a matlab function or in another technique to calculate the largest eigenvalue for this kind of multiplication.
Thanks.
If A is sparse, see this thread and some discussion in this documentation (basically do it part by part) for a way to transpose it etc.
But now you need to calculate B=A'*A. The question is, is it still sparse? assuming it is, there shouldn't be a problem to proceed using the previous technique mentioned in the link.
Then after you've obtained B=A'*A, use eigs
eigs(B,1)
to obtain the largest magnitude eigenvalue.