ForwardDiff.jl icon indicating copy to clipboard operation
ForwardDiff.jl copied to clipboard

Implement partials/value for complex duals

Open dlfivefifty opened this issue 11 months ago • 5 comments

At the moment values/partials give useless (and probably "wrong") answers for complex-duals:

julia> ForwardDiff.value(ForwardDiff.Dual(1,2) + im*ForwardDiff.Dual(3,4))
Dual{Nothing}(1,2) + Dual{Nothing}(3,4)*im


julia> ForwardDiff.value(ForwardDiff.Dual(1,2) + im*ForwardDiff.Dual(3,4))
Dual{Nothing}(1,2) + Dual{Nothing}(3,4)*im

julia>  ForwardDiff.partials(ForwardDiff.Dual(1,2) + im*ForwardDiff.Dual(3,4))
0-element ForwardDiff.Partials{0, Complex{ForwardDiff.Dual{Nothing, Int64, 1}}}

julia>  ForwardDiff.partials(ForwardDiff.Dual(1,2) + im*ForwardDiff.Dual(3,4),1)
Dual{Nothing}(0,0) + Dual{Nothing}(0,0)*im

This PR implements correct versions of these functions.

dlfivefifty avatar Dec 12 '24 21:12 dlfivefifty