-
Notifications
You must be signed in to change notification settings - Fork 149
complex number support #455
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if it makes sense to define these methods in ForwardDiff.jl, since they should all be generic callbacks that are independent of Dual
, right?
Co-authored-by: Yingbo Ma <[email protected]>
Co-authored-by: Yingbo Ma <[email protected]>
Is this not all covered by JuliaLang/julia#36030 ? |
Looking at the two PRs, it seems like @YingboMa upstreamed it all to Base where it should go (correct me if I'm wrong and anything was left out). So complex AD is thus fixed on v1.6. However, the tests are still definitely useful from here. So I'd suggest the following:
and everything is good to go. The other alternative would be to move these behind an |
Handled by JuliaLang/julia#36030 |
Thanks! @ChrisRackauckas |
Hello, ERROR: ArgumentError: Cannot create a dual over scalar type ComplexF64. If the type behaves as a scalar, define ForwardDiff.can_dual(::Type{ComplexF64}) = true. |
Not entirely handled, complex valued functions of multiple real arguments don't work, e.g. julia> ForwardDiff.gradient(x->exp(im * (x[1] + x[2])), [1.0,2.0])
ERROR: DimensionMismatch: gradient(f, x) expects that f(x) is a real number. Perhaps you meant jacobian(f, x)? |
I also still get the same error. Is there a way to manually change the way forward differentiation is handled? |
For DiffEq? You just set |
Sorry, it was not clear from my question. Of course, setting |
It uses |
Exactly, but right now, this throws an error, when trying to autodiff a complex ODE. |
So then I don't get the question? |
Right now, afaik, ForwardDiff does not handle automatic differentiation for complex functions out-of-the-box. However, DiffEq relies on ForwardDiff when computing jacobians and more. Is there any solution to still use automatic differentiation (eg using a different package) for DiffEq? |
Yes, just use |
Related Issues
#157
#324
#364
This is a quick fix for some complex valued functions. Any thoughts?
NOTE: I copied some functions from Base, because they fixed the type to foating point numbers.