You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
jacobian(f!, y, x) doesn't work if y is complex #832
julia>g!(y, x) = (y .=cis(x[1]));
julia> ForwardDiff.jacobian(g!, Vector{ComplexF64}(undef, 2), [0.0])
ERROR: ArgumentError: Cannot create a dual over scalar type ComplexF64. If the type behaves as a scalar, define ForwardDiff.can_dual(::Type{ComplexF64}) =true.
JacobianConfig(f!, y, x) leaves the output eltype Y unconstrained and allocates similar(y, Dual{T,Y,N}), so for a complex y it tries to build a dual over ComplexF64. It should buffer as Complex{Dual{T,real(Y),N}}, which is how the package already represents a complex value carrying derivative information.
PR #831 adds a dual_buffer_eltype helper for exactly this, so the config side becomes a one-line change once that lands. The extraction side needs #830.
Activity