In a C++ program I computed a large sparse matrix energy_mat
which I know is symemtric.
I am trying to compute its condition number by getting the largest and smallest eigen values like this:
Spectra::SparseGenMatProd<double> op(energy_mat);
Spectra::GenEigsSolver<Spectra::SparseGenMatProd<double>> eigs(op, 3, 6);
// Initialize and compute
eigs.init();
int nconv = eigs.compute(Spectra::SortRule::LargestMagn);
// Retrieve results
Eigen::VectorXcd evalues;
if (eigs.info() == Spectra::CompInfo::Successful)
evalues = eigs.eigenvalues();
std::cout << "Eigenvalues found:\n"
<< evalues << std::endl;
I see:
Eigenvalues found:
I.e. the array is empty. However I know that energy mat
is symmetric (I checked) and I am later using it to solve a linear system of equations, so it's numerically sound (it doesn;t have nans or infs).
Why is spectra fidning no eigen values?
Increasing the number of iterations from 6 to 40 seems to have fixed the issue.