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

printing only real eigenvalues

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

printing only real eigenvalues

Thu Mar 19, 2015 2:24 am
I am dealing with Hermitian matrices so all the eigenvalues will be real. I use EigenSolver<MatrixXd> es(Hnm) and print es.eigenvalues(). What i get from this is a list of my eigenvalues but they are printed in the form (15, 0) (27, 0), ... I need to plot these and with matrices of size of over 200 it takes me a long time to manually remove the brackets and the complex part of 0. Is there another method to display only the real eigenvalues? Sorry if this is easy to lookup but I am not experienced with coding and the resources are greek to me. Thanks.
johndaily
Registered Member
Posts
3
Karma
0

Re: printing only real eigenvalues

Sat Mar 21, 2015 3:14 am
Just print instead (e.g., stream)
Code: Select all
cout << es.eigenvalues().real();

similarly there is an imag() method for the imaginary part.

The dox pages have a search feature:
http://eigen.tuxfamily.org/dox/AsciiQuickReference.txt
http://eigen.tuxfamily.org/dox/classEigen_1_1MatrixBase.html#accfa15407b80807dab914b1844c725e5
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: printing only real eigenvalues

Mon Mar 23, 2015 1:03 pm
Since your matrix is Hermitian, better use the SelfAdjointEigenSolver instead of the EigenSolver class.


Bookmarks



Who is online

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