Skip to content

Commit cbf9441

Browse files
devmotiontpapp
andauthored
Check type stability and return type of logaddexp (#42)
* Check type stability and return type of `logaddexp` * Update test/basicfuns.jl Co-authored-by: Tamas K. Papp <[email protected]> Co-authored-by: Tamas K. Papp <[email protected]>
1 parent d9dc1c9 commit cbf9441

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/basicfuns.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,19 @@ end
176176
end
177177

178178
@testset "logsumexp" begin
179-
@test logaddexp(2.0, 3.0) log(exp(2.0) + exp(3.0))
180-
@test logaddexp(10002, 10003) 10000 + logaddexp(2.0, 3.0)
179+
Ts = (Int, Float32, Float64)
180+
for T1 in Ts, T2 in Ts
181+
a = T1(2)
182+
b = T2(3)
183+
184+
x = @inferred(logaddexp(a, b))
185+
@test x log(exp(a) + exp(b))
186+
@test typeof(x) === float(Base.promote_typeof(a, b))
187+
188+
y = @inferred(logaddexp(a + 10_000, b + 10_000))
189+
@test y 10_000 + log(exp(a) + exp(b))
190+
@test typeof(y) === typeof(x)
191+
end
181192

182193
for x in ([1.0], Complex{Float64}[1.0])
183194
@test @inferred(logsumexp(x)) == 1.0

0 commit comments

Comments
 (0)