Hi !
This code is working:
struct MP v::Float64 end
Base.:(*)(x::MP, y::MP) = MP(x.v + y.v)
Base.:(*)(x::MP, y::Real) = MP(x.v + y)
Base.:(*)(x::Real, y::MP) = MP(x + y.v)
But on a corner case, this is giving me correct result point of view a computer science :
julia> MP(-Inf) * MP(Inf)
MP(NaN)
But I want to force it to return a different result in accordance to my algebra => MP(-Inf)
. I tried to follow the idea base on literal_pow
but without success:
@inline Base.:(*)(::Val{MP(Inf)}, ::Val{MP(-Inf)}) = MP(-Inf)
@inline Base.:(*)(::Val{MP(-Inf)}, ::Val{MP(Inf)}) = MP(-Inf)
Still returning me NaN. I succeeded with literal_pow but for operators + and * seems the compiler is not working in the same manner. How to reach the same result without adding an if-then-else in my function ?
Thanks in advance !