Skip to content

Commit

Permalink
move log functions to JuliaLibm module
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbyrne committed Apr 23, 2015
1 parent 384237c commit ff7a5e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ exp10(x::Integer) = exp10(float(x))
@vectorize_1arg Number exp10

# functions that return NaN on non-NaN argument for domain error
for f in (:sin, :cos, :tan, :asin, :acos, :acosh, :atanh, :log2, :log10,
:lgamma)
for f in (:sin, :cos, :tan, :asin, :acos, :acosh, :atanh, :log, :log2, :log10,
:lgamma, :log1p)
@eval begin
($f)(x::Float64) = nan_dom_err(ccall(($(string(f)),libm), Float64, (Float64,), x), x)
($f)(x::Float32) = nan_dom_err(ccall(($(string(f,"f")),libm), Float32, (Float32,), x), x)
Expand Down Expand Up @@ -369,10 +369,13 @@ function mod2pi(x::Int64)
end

# More special functions
include("special/log.jl")
include("special/trig.jl")
include("special/bessel.jl")
include("special/erf.jl")
include("special/gamma.jl")

module JuliaLibm
include("special/log.jl")
end

end # module
6 changes: 3 additions & 3 deletions test/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,16 @@ for x in X
for T in (Float32,Float64)
xt = T(x)

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

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

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

0 comments on commit ff7a5e3

Please sign in to comment.