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 might not be understanding the semantics of float() correctly, so maybe that should be fixed. But in general, we need to create an extension to fully support all the functions in LogExpFunctions. I will look into that next week.
However, it's hard to detect and throw error in these cases, because the freedom of multiple dispatch actually allow one to specify slightly different semantics to the same function interface. Therefore when combining two different packages, they might "just work" but also might not.
The comment on that line says "# ensures that BigInt/BigFloat, Int/Float64 etc. dispatch to the same algorithm", so float() for them is simply used to convert ints to floats, you you use it to return a true float.
You could look at what float() dispatches to on forwardiff's Dual{} type for example, to decide what to do. Thanks for your fast answer anyway, waiting for your input :)
Activity
[-]Support for LogExpFunctions[/-][+]Support for LogExpFunctions && better errors[/+]tansongchen commentedon Sep 7, 2025
The problem is at https://github.com/JuliaStats/LogExpFunctions.jl/blob/master/src/basicfuns.jl#L259 where it defines
log1pexp(x::Real) = _log1pexp(float(x)). In TaylorDiff.jl,float()converts a TaylorScalar to its primal type...I might not be understanding the semantics of
float()correctly, so maybe that should be fixed. But in general, we need to create an extension to fully support all the functions inLogExpFunctions. I will look into that next week.However, it's hard to detect and throw error in these cases, because the freedom of multiple dispatch actually allow one to specify slightly different semantics to the same function interface. Therefore when combining two different packages, they might "just work" but also might not.
lrnv commentedon Sep 8, 2025
Understood about the difficulty to error, indeed.
The comment on that line says "# ensures that BigInt/BigFloat, Int/Float64 etc. dispatch to the same algorithm", so float() for them is simply used to convert ints to floats, you you use it to return a true float.
You could look at what float() dispatches to on forwardiff's Dual{} type for example, to decide what to do. Thanks for your fast answer anyway, waiting for your input :)
tansongchen commentedon Sep 8, 2025
I agree, looking at ForwardDiff should be a good reference.