This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Sparse and Complex Generalized Eigenvalue Problem

Tags: None
(comma "," separated)
acgungor
Registered Member
Posts
1
Karma
0
Hi,

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,


Code: Select all
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;

}


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]