0

I have been trying to solve a complex and sparse generalized eigenvalue problem. As far as I see in the documentation, it should be possible to do with Eigen. So I wanted to perform this with a test case with A and B matrices are 2 by 2 but still stored in sparse format. So for the following matrices

A= [1.0 0.0; 0.0 1.0 ]

B= [2.0 0.0; 0.0 2.0i ]

I know the solutions of generalized eigenvalue problem should give 0.5 and -0.5i as eigenvalues.

What I have tried so far is as below. And unfortunately I couldn't make this work as 'ges' refuses to work with complex data types. I was wondering if there is a way to solve this issue or if someone could lead me to the right direction. Thanks in advance,

typedef Eigen::SparseMatrix<std::complex<float>, Eigen::RowMajor> SpMatC;

main {
int NfreeC = 2;
SpMatC matAC(NfreeC, NfreeC), matBC(NfreeC, NfreeC);
matAC.coeffRef(0, 0) = std::complex <float>(1.0, 0.0);   matAC.coeffRef(0, 1) = std::complex <float>(0.0, 0.0);
matAC.coeffRef(1, 0) = std::complex <float>(0.0, 0.0);   matAC.coeffRef(1, 1) = std::complex <float>(1.0, 0.0);

matBC.coeffRef(0, 0) = std::complex <float>(2.0, 0.0);   matBC.coeffRef(0, 1) = std::complex <float>(0.0, 0.0);
matBC.coeffRef(1, 0) = std::complex <float>(0.0, 0.0);   matBC.coeffRef(1, 1) = std::complex <float>(0.0, 2.0);

Eigen::GeneralizedEigenSolver<SpMatC> ges;
ges.compute(matAC, matBC);
cout << "The (complex) generalized eigenvalues are (alphas./beta): " << ges.eigenvalues().transpose() << endl;

}
Arjo
  • 1
  • You're right that Eigen doesn't directly support a complex generalized eigenvalue solver. They do support a complex, self-adjoint complex eigenvalue solver (Eigen::GeneralizedSelfAdjointEigenSolver), which just cleverly rearranges the problem into standard form using a cholesky decomposition. However, the greater issue is that the eigenvalue solvers don't appear to support sparse matrices There are sparse eigenvalue solvers out there, but I have no experience using them. Depending on what your sparsity pattern is, you may have some luck with MKL – Charlie S Jul 02 '20 at 16:05
  • https://software.intel.com/content/www/us/en/develop/documentation/mkl-developer-reference-c/top/lapack-routines/lapack-least-squares-and-eigenvalue-problem-routines/lapack-least-squares-and-eigenvalue-problem-computational-routines/generalized-symmetric-definite-eigenvalue-problems-lapack-computational-routines.html – Charlie S Jul 02 '20 at 16:05

0 Answers0