In matlab, there are 2 commands named "eig" for full matrices and "eigs" for sparse matrices to compute eigenvalues of a matrix. And eig(A) computes all the eigenvalues of a full matrix and eigs(A) computes the 6 largest magnitude eigenvalues of matrix A. If we want to compute all the eigenvalues of a sparse matrix, so we must convert the matrix to full type, i.e., using eig(full(A)) when A is sparse. But this will fail becaues of CPU memory. My question is that if I want to compute all the eigenvalues of a large sparse matrix, say (matrix size is 10000). How to implement this? I know we should not compute all the eigenvalues of a large sparse matrix. But sometimes, in Krylove subspace iterative methods, we need to plot the spectral distributions of a preconditioned matrix to investigate the convergence rate. so I need plot the spectral distributions. How to do that? Thanks very much.
Below is my random example and fails. And the matrix is from Poisson equation using centered difference in 2D:
clc;clear;
n=100;
A = gallery('poisson',n);% system size is n*n
R = ichol(A);
P = R'*R;% construct preconditioner
% consider the eigenvalue distribution of preconditioned matrix inv(P)*A
a = eig(full(A),full(P));
plot(real(a),imag(a))