Open antoine-levitt opened 3 months ago
The issue appears to be this somewhat unfortunate interaction:
julia> reinterpret(ComplexF64, ForwardDiff.Dual(1.0,1.0))
1.0 + 1.0im
Reinterpret just takes the number of bits of the ForwardDiff.Dual and makes them into a ComplexF64.
So, this result is very much expected and in my opinion not a bug.
It makes sense technically, but it also means that the above example will fail: reinterpret works on the dual data structure, which is unusual (most operations apply to the primal variable). Is there any use for reinterpreting a dual in this way?
There are many other cases like this. For example, eltype
on a Vector{Dual{Float64}}
will return Dual{Float64}
. Or typeof
of a dual number. At some point you have to be able to talk about the actual program that is running.