|
1 | 1 | module NaNMath
|
2 | 2 |
|
3 |
| -using OpenLibm_jll, Compat |
| 3 | +using OpenLibm_jll |
4 | 4 | const libm = OpenLibm_jll.libopenlibm
|
5 | 5 |
|
6 | 6 | for f in (:sin, :cos, :tan, :asin, :acos, :acosh, :atanh, :log, :log2, :log10,
|
7 | 7 | :lgamma, :log1p)
|
8 | 8 | @eval begin
|
9 |
| - Compat.@assume_effects :total ($f)(x::Float64) = ccall(($(string(f)),libm), Float64, (Float64,), x) |
10 |
| - Compat.@assume_effects :total ($f)(x::Float32) = ccall(($(string(f,"f")),libm), Float32, (Float32,), x) |
| 9 | + @assume_effects :total ($f)(x::Float64) = ccall(($(string(f)),libm), Float64, (Float64,), x) |
| 10 | + @assume_effects :total ($f)(x::Float32) = ccall(($(string(f,"f")),libm), Float32, (Float32,), x) |
11 | 11 | ($f)(x::Real) = ($f)(float(x))
|
12 | 12 | if $f !== :lgamma
|
13 | 13 | ($f)(x) = (Base.$f)(x)
|
|
25 | 25 |
|
26 | 26 | # Would be more efficient to remove the domain check in Base.sqrt(),
|
27 | 27 | # but this doesn't seem easy to do.
|
28 |
| -Compat.@assume_effects :nothrow sqrt(x::T) where {T<:Union{Float16, Float32, Float64}} = x < 0.0 ? T(NaN) : Base.sqrt(x) |
| 28 | +@assume_effects :nothrow sqrt(x::T) where {T<:Union{Float16, Float32, Float64}} = x < 0.0 ? T(NaN) : Base.sqrt(x) |
29 | 29 | sqrt(x::T) where {T<:AbstractFloat} = x < 0.0 ? T(NaN) : Base.sqrt(x)
|
30 | 30 | sqrt(x::Real) = sqrt(float(x))
|
31 | 31 |
|
32 | 32 | # Don't override built-in ^ operator
|
33 |
| -Compat.@assume_effects :total pow(x::Float64, y::Float64) = ccall((:pow,libm), Float64, (Float64,Float64), x, y) |
34 |
| -Compat.@assume_effects :total pow(x::Float32, y::Float32) = ccall((:powf,libm), Float32, (Float32,Float32), x, y) |
| 33 | +@assume_effects :total pow(x::Float64, y::Float64) = ccall((:pow,libm), Float64, (Float64,Float64), x, y) |
| 34 | +@assume_effects :total pow(x::Float32, y::Float32) = ccall((:powf,libm), Float32, (Float32,Float32), x, y) |
35 | 35 | # We `promote` first before converting to floating pointing numbers to ensure that
|
36 | 36 | # e.g. `pow(::Float32, ::Int)` ends up calling `pow(::Float32, ::Float32)`
|
37 | 37 | pow(x::Real, y::Real) = pow(promote(x, y)...)
|
|
0 commit comments