How to diagonalize a large sparse symmetric matrix to get the eigenvalues and eigenvectors

How does one diagonalize a large sparse symmetric matrix to get the eigenvalues and the eigenvectors?

The problem is the matrix could be very large (though it is sparse), at most $2500\times 2500$. Is there a good algorithm to do that and most importantly, one that I can implement it into my own code? Thanks a lot!


Solution 1:

$2500 \times 2500$ is a small matrix by current standards. The standard eig command of matlab should be able to handle this size with ease. Iterative sparse matrix eigensolvers like those implemented in ARPACK, or SLEPc will become more preferable if the matrix is much larger.

Also, if you want to implement an eigensolver into your own code, just use the LAPACK library that comes with very well developed routines for such purpose. Matlab also ultimately invokes LAPACK routines for doing most of its numerical linear algebra.

Semi-related note: the matrix need not be explicitly available for the large sparse solvers, because they usually just depend on being able to compute $A*x$ and $A'*x$.