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
Hi there!
I'm using this package in a local package of mine and I noticed that Zeros.Zero() isn't propagating in the muladd function:
julia>muladd(Zeros.Zero(),2.0,Zeros.Zero())
0.0
I see in the source code some definitions for muladd but they are commented out. Why is that?
In my package I'm using the following method definitions to get my desired behavior:
for op in [:fma:muladd]
@eval$op(::Zero, ::Zero, ::Zero) =Zero()
@eval$op(::Zero,::Number,::Zero) =Zero()
@eval$op(::Number,::Zero,::Zero) =Zero()
@eval$op(x::Number, y::Number, ::Zero) = x*y
@eval$op(::One, x::Number, y::Number) = x+y
@eval$op(x::Number, ::One, y::Number) = x+y
for T in (Real, Complex) # Special definitions for Real and Complex to avoid method ambiguities.@eval$op(::Zero,::$T,::Zero) =Zero()
@eval$op(::$T,::Zero,::Zero) =Zero()
for T2 in (Real, Complex)
@eval$op(x::$T, y::$T2, ::Zero) = x*y
@eval$op(::One, x::$T, y::$T2) = x+y
@eval$op(x::$T, ::One, y::$T2) = x+y
endendend
And it works as expected:
julia>muladd(𝟎,2.0,𝟎)
𝟎
Wouldn't having this method's definition in Zeros.jl be desirable?
The text was updated successfully, but these errors were encountered:
Hi there!
I'm using this package in a local package of mine and I noticed that
Zeros.Zero()
isn't propagating in themuladd
function:I see in the source code some definitions for muladd but they are commented out. Why is that?
In my package I'm using the following method definitions to get my desired behavior:
And it works as expected:
Wouldn't having this method's definition in
Zeros.jl
be desirable?The text was updated successfully, but these errors were encountered: