Closed ptiede closed 1 year ago
Hi,
This is a cross-post with https://github.com/JuliaDiff/ForwardDiff.jl/issues/604. The rule for ldexp(x,y) always returns a Float64 regardless of the type of the first argument x. This is because the rule is given by
ldexp(x,y)
x
@define_diffrule Base.ldexp(x, y) = :( exp2($y) ), :NaN
and since y is an Int exp2 by default return a Float64. @mcabbott pointed out that if we change the rule to
y
Int
exp2
@define_diffrule Base.ldexp(x, y) = :( oftype(float($x), exp2($y) ), :NaN
then we should maintain the Float32 type throughout the computation.
Closed because of #89
Hi,
This is a cross-post with https://github.com/JuliaDiff/ForwardDiff.jl/issues/604. The rule for
ldexp(x,y)
always returns a Float64 regardless of the type of the first argumentx
. This is because the rule is given byand since
y
is anInt
exp2
by default return a Float64. @mcabbott pointed out that if we change the rule tothen we should maintain the Float32 type throughout the computation.