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

Solving eigenmodes with type long double

Tags: None
(comma "," separated)
sbarth
Registered Member
Posts
2
Karma
0
Hello,

I need to extend the precision of Eigen's complex matrix eigenmode solver -- long double is 16 bytes on my compiler, so this seems sufficient. I see in this thread (https://forum.kde.org/viewtopic.php?f=74&t=85550) that Eigen can be straightforwardly modified to support complex long double matrices.

However, if I correspondingly call (the currently fictitious) eigenmode solver ComplexEigenSolver<MatrixXcld>, will the computations automatically be done in extended precision (long double format), or will I need to modify those methods as well?

Thanks
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Just use MatrixXcld everywhere you need it, nothing to change within Eigen!
sbarth
Registered Member
Posts
2
Karma
0
Thanks for the help, ggael. I'm a novice at C++ and programming, and I'm not too sure about templating.

From what I can tell, all I needed to do is insert the template (as done here: https://forum.kde.org/viewtopic.php?f=74&t=124589)
Code: Select all
typedef Matrix<std::complex<long double>,Dynamic,Dynamic> MatrixXcld;
, and then use MatrixXcld everywhere where I previously would have had MatrixXcd. However, my compiler is now complaining that
Use of overloaded operator '*' is ambiguous (with operand types 'complex<double>' and 'MatrixXcld' (aka 'Matrix<complex<long double>, Dynamic, Dynamic>'))

I assume this means I have to define basic mathematical operation for my new MatrixXcld class as well -- is there a straightforward way to do this?

[Solved]

The std::complex was to blame. It didn't know what to do with multiplying complex<double> with a MatrixXcld (long double). Converting the numbers to complex<long double>() solved the problems!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Indeed, implicit conversion of the nested scalar type is not allowed.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient