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
With NaN-safe mode enabled (nansafe_mode = true), fma and muladd propagate NaN partials for dual numbers with zero partials, unlike the equivalent x * y + z:
julia>using ForwardDiff: Dual # nansafe_mode = true
julia> x, y, z =Dual(Inf, 0.0), Dual(2.0, 0.0), Dual(0.0, 0.0);
julia> x * y + z
Dual{Nothing}(Inf,0.0)
julia>muladd(x, y, z)
Dual{Nothing}(Inf,NaN)
julia>fma(x, y, z)
Dual{Nothing}(Inf,NaN)
julia> x, y, z =Dual(1.0, 0.0), Inf, Dual(0.0, 1.0);
julia> x * y + z
Dual{Nothing}(Inf,1.0)
julia>muladd(x, y, z)
Dual{Nothing}(Inf,NaN)
julia>fma(x, y, z)
Dual{Nothing}(Inf,NaN)
The methods for three dual arguments, and for dual-real-dual arguments, compute the partials with fma/muladd directly instead of going through the NaN-safe multiplication. Related: #857, #858.
ForwardDiff master (a3c0f4f), Julia 1.13.1, macOS aarch64.
Activity