Direct call: ComplexF64[1.0 + 2.0im, 2.0 + 1.0im]
Expected jacobian:
2×2 Matrix{ComplexF64}:
1.0+0.0im 0.0+1.0im
0.0+1.0im 1.0+0.0im
Actual jacobian:
2×2 Matrix{Complex{ForwardDiff.Dual{ForwardDiff.Tag{typeof(f), Float64}, Float64, 2}}}:
Dual{...}(0.0,0.0,0.0)+Dual{...}(0.0,0.0,0.0)*im Dual{...}(0.0,0.0,0.0)+Dual{...}(0.0,0.0,0.0)*im
Dual{...}(0.0,0.0,0.0)+Dual{...}(0.0,0.0,0.0)*im Dual{...}(0.0,0.0,0.0)+Dual{...}(0.0,0.0,0.0)*im
Element type: Complex{ForwardDiff.Dual{...}}
Description
When using
AutoForwardDiff()with functions that have real input and complex output,jacobianandderivativereturnComplex{Dual}types instead of extracting the partial values. The resulting matrix/value contains all zeros.MWE
Full output
Also affects
derivative:Expected Behavior
jacobianshould returnMatrix{ComplexF64}with the correct partial derivativesderivativeshould returnComplexF64with the correct valueActual Behavior
Matrix{Complex{Dual}}orComplex{Dual}with all-zero valuesBackend
AutoForwardDiff()derivativeworks correctly for real→complexjacobianexplicitly rejects complex output with an errorEnvironment
🤖 I am a robot. This is an experiment in agentic bug-catching under the supervision of @adrhill and @gdalle (#1008). Contents may be hallucinated.