Skip to content

Commit

Permalink
Use JuliaLibm log functions in Main.Math. (#24750)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkofod authored and StefanKarpinski committed Feb 11, 2018
1 parent e59dabe commit 11c08ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
5 changes: 5 additions & 0 deletions base/deprecated.jl
Expand Up @@ -1365,6 +1365,11 @@ end
link_pipe!(pipe, reader_supports_async = julia_only_read, writer_supports_async = julia_only_write),
false)

# Remember to delete the module when removing this
@eval Base.Math module JuliaLibm
Base.@deprecate log Base.log
end

# END 0.7 deprecations

# BEGIN 1.0 deprecations
Expand Down
11 changes: 1 addition & 10 deletions base/math.jl
Expand Up @@ -376,9 +376,6 @@ atanh(x::Number)
Compute the natural logarithm of `x`. Throws [`DomainError`](@ref) for negative
[`Real`](@ref) arguments. Use complex negative arguments to obtain complex results.
There is an experimental variant in the `Base.Math.JuliaLibm` module, which is typically
faster and more accurate.
"""
log(x::Number)

Expand Down Expand Up @@ -422,9 +419,6 @@ log10(x)
Accurate natural logarithm of `1+x`. Throws [`DomainError`](@ref) for [`Real`](@ref)
arguments less than -1.
There is an experimental variant in the `Base.Math.JuliaLibm` module, which is typically
faster and more accurate.
# Examples
```jldoctest
julia> log1p(-0.5)
Expand All @@ -435,7 +429,7 @@ julia> log1p(0)
```
"""
log1p(x)
for f in (:acosh, :atanh, :log, :log2, :log10, :lgamma, :log1p)
for f in (:acosh, :atanh, :log2, :log10, :lgamma)
@eval begin
@inline ($f)(x::Float64) = nan_dom_err(ccall(($(string(f)), libm), Float64, (Float64,), x), x)
@inline ($f)(x::Float32) = nan_dom_err(ccall(($(string(f, "f")), libm), Float32, (Float32,), x), x)
Expand Down Expand Up @@ -988,9 +982,6 @@ include(joinpath("special", "exp10.jl"))
include(joinpath("special", "trig.jl"))
include(joinpath("special", "gamma.jl"))
include(joinpath("special", "rem_pio2.jl"))

module JuliaLibm
include(joinpath("special", "log.jl"))
end

end # module
8 changes: 4 additions & 4 deletions test/math.jl
Expand Up @@ -564,7 +564,7 @@ end
end

@testset "log/log1p" begin
# if using Tang's algorithm, should be accurate to within 0.56 ulps
# using Tang's algorithm, should be accurate to within 0.56 ulps
X = rand(100)
for x in X
for n = -5:5
Expand All @@ -573,16 +573,16 @@ end
for T in (Float32,Float64)
xt = T(x)

y = Base.Math.JuliaLibm.log(xt)
y = log(xt)
yb = log(big(xt))
@test abs(y-yb) <= 0.56*eps(T(yb))

y = Base.Math.JuliaLibm.log1p(xt)
y = log1p(xt)
yb = log1p(big(xt))
@test abs(y-yb) <= 0.56*eps(T(yb))

if n <= 0
y = Base.Math.JuliaLibm.log1p(-xt)
y = log1p(-xt)
yb = log1p(big(-xt))
@test abs(y-yb) <= 0.56*eps(T(yb))
end
Expand Down

2 comments on commit 11c08ad

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.