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
I'm running into the same issue when trying to get a derivative over a complex sqrt operation. Here I was able to reproduce the error in a simplified way:
> x = ForwardDiff.Dual{Nothing}(1,0.0,0.0,0.0)*im
>sqrt(x)
StackOverflowError:
Stacktrace:
[1] Type at ./complex.jl:12 [inlined] (repeats 2 times)
[2] float at ./complex.jl:967 [inlined]
[3] sqrt(::Complex{ForwardDiff.Dual{Nothing,Float64,3}}) at ./complex.jl:461 (repeats 80000 times)
I am trying this out in julia v1.6 and it's sometimes working okay now. sqrt(::Complex) contains a call to ssqs which has a branch that sometimes fails on Dual: the problematic function is Base.exponent which is not defined for Dual
function Base.ssqs(x::T, y::T) where T <:ForwardDiff.Dual
k::Int=0
ρ = x*x + y*y
@show x
if!isfinite(ρ) && (isinf(x) ||isinf(y))
ρ =convert(T, Inf)
elseifisinf(ρ) || (ρ==0&& (x!=0|| y!=0)) || ρ<nextfloat(zero(T))/(2*eps(T)^2)
m::T=max(abs(x), abs(y))
@show m
k = m==0? m : Base.exponent(m)
xk, yk = Base.ldexp(x,-k), Base.ldexp(y,-k)
ρ = xk*xk + yk*yk
end
ρ, k
end
Activity
tkoolen commentedon Jul 3, 2018
This is basically JuliaLang/julia#26552 I believe.
EdoAlvarezR commentedon Jan 20, 2019
I'm running into the same issue when trying to get a derivative over a complex sqrt operation. Here I was able to reproduce the error in a simplified way:
Has anyone found a solution for this?
chriscoey commentedon Apr 19, 2019
I too am running into this
adam-coogan commentedon Jun 28, 2019
This is a problem for me as well. Any ideas about how to deal with this?
jfmoulin commentedon Nov 12, 2019
I run into same error with a just updated Turing/ForwardDiff.
andreasnoack commentedon Nov 12, 2019
See the discussion in #157
baggepinnen commentedon Oct 28, 2020
I am trying this out in julia v1.6 and it's sometimes working okay now.
sqrt(::Complex)contains a call tossqswhich has a branch that sometimes fails onDual: the problematic function isBase.exponentwhich is not defined forDual