-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for complex numbers #117
Comments
Hi @zoharl3 - sorry for the delay. Have you tried instead using |
Looks like it's working. Not sure if perfectly, e.g. I can assign (or multiply) VectorXd to (by) VectorXdual, but not VectorXcd to (by) VectorXcdual. Maybe it needs casting or something; but I'll look into it more closely when I need it. For now, I just used real implementation. If you think that it works smoothly, then you may want to consider adding an example to the tutorial, which others may find useful. |
It would be nice if rather than being distributed across a few tutorials and GitHub issues, that the complex support was folded into the library itself. As it stands I'm having a hard time getting it working properly. For example, using std::complex refuses to compile if the code uses derivative(...), while using Dual<std::complex, std::complex> like the tutorial suggests is also somewhat problematic. For example, it doesn't have real() or imag() methods like std::complex does, and things like Eigen want it to. Furthermore, some things seem to be hardcoded in a problematic way, for example, while almost every operator is made generic using UnaryExpr, for conj, real and imag the methods are hardcoded to return the number itself, and 0 respectively i.e. the Dual class will only work correctly for real types. As such, it seems that there need to be some fixes internally before complex numbers work properly |
Hi @petar-andrejic , thanks for your investigation. As discussed in #297, if you work on that Pull Request, I'll be happy to merge. |
Something like:
The text was updated successfully, but these errors were encountered: