From 5b8f686653fb2dde6708234f6d80134c0c015c01 Mon Sep 17 00:00:00 2001 From: cossio Date: Wed, 9 Mar 2022 02:10:36 +0100 Subject: [PATCH] better comments --- src/basicfuns.jl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/basicfuns.jl b/src/basicfuns.jl index 42b7f24b..a35952ec 100644 --- a/src/basicfuns.jl +++ b/src/basicfuns.jl @@ -195,14 +195,16 @@ should optimize away all computations done here. return (x0, x1, x2) end -#= For Float64, Float32 we can hard-code the thresholds to make absolutely sure they are not +#= +For common types we hard-code the thresholds to make absolutely sure they are not recomputed each time. Also, _log1pexp_thresholds is not completely elided by the -compiler in Julia 1.0 / 1.6 which LogExpFunctions intends to support. -For Float64 we use the same exact thresholds given by Maechler 2012, -since these were the ones used before _log1pexp_thresholds was introduced (which outputs -close but not identical thresholds), to reduce any (small) risk of breakage. -For Float32 and Float16 we use truncated versions of the output of _log1pexp_thresholds. =# -@inline _log1pexp_thresholds(::Float64) = (-37e0, 18e0, 33e0) +compiler in Julia 1.0 / 1.6. We round the outputs of the non-hardcoded version: + +* _log1pexp_thresholds(::Float64) = (-36.7368005696771, 18.021826694558577, 33.23111882352963) +* _log1pexp_thresholds(::Float32) = (-16.635532f0, 7.9711924f0, 13.993f0) +* _log1pexp_thresholds(::Float16) = (-7.625, 3.467, 5.86) +=# +@inline _log1pexp_thresholds(::Float64) = (-37e0, 18e0, 33e0) # same as Maechler 2012 @inline _log1pexp_thresholds(::Float32) = (-17f0, 8f0, 14f0) @inline _log1pexp_thresholds(::Float16) = (Float16(-7.6), Float16(3.5), Float16(5.9))