@@ -11,7 +11,7 @@ julia> xlogx(0)
1111"""
1212function xlogx (x:: Number )
1313 result = x * log (x)
14- ifelse ( iszero (x), zero (result), result)
14+ return iszero (x) ? zero (result) : result
1515end
1616
1717"""
@@ -26,7 +26,7 @@ julia> xlogy(0, 0)
2626"""
2727function xlogy (x:: Number , y:: Number )
2828 result = x * log (y)
29- ifelse ( iszero (x) && ! isnan (y), zero (result), result)
29+ return iszero (x) && ! isnan (y) ? zero (result) : result
3030end
3131
3232# The following bounds are precomputed versions of the following abstract
@@ -60,15 +60,7 @@ logistic(x::Real) = inv(exp(-x) + one(x))
6060function logistic (x:: Union{Float16, Float32, Float64} )
6161 e = exp (x)
6262 lower, upper = _logistic_bounds (x)
63- ifelse (
64- x < lower,
65- zero (x),
66- ifelse (
67- x > upper,
68- one (x),
69- e / (one (x) + e)
70- )
71- )
63+ return x < lower ? zero (x) : x > upper ? one (x) : e / (one (x) + e)
7264end
7365
7466"""
@@ -210,7 +202,7 @@ non-finite values.
210202"""
211203function logaddexp (x:: Real , y:: Real )
212204 # ensure Δ = 0 if x = y = ± Inf
213- Δ = ifelse ( x == y, zero (x - y), abs (x - y) )
205+ Δ = x == y ? zero (x - y) : abs (x - y)
214206 max (x, y) + log1pexp (- Δ)
215207end
216208
0 commit comments