Registered Member
|
So, apologies in advance for what I know has to be a total newbie question.
I'm trying to extract eigenvalues into a simple array just to do an additional manipulation and then be able to write them neatly to a file. The problem is that, when using EigenSolver, the (default?) output type of the vector of eigenvalues is complex double (since the array was type double) so I get an error from type mis-match. Is there any way to force EigenSolver to output only the real part of the eigenvectors, or alternatively is there any way to cast complex objects to real in Eigen? As I said, I'm not an incredibly proficient programmer so most of the documentation here has been too abstract for me to get anything out of. Edit: The 3.0 change log says that complex numbers are vectorized which should me I would be able to access the real part using the [] operator, but that just returns an error. |
Moderator
|
If you known the eigenvalues must be real, then you can do:
EigenSolver<...> eig(A); VectorXd eivals = eig.eigenvalues().real(); ".real()" returns a "view" on the real parts. |
Registered Member
|
Ok, it was really just that easy. Thank you, that was exactly what I was looking for.
|
Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Yahoo [Bot]