Skip to content

Commit 0f038e3

Browse files
committed
Update for 0.7 and 1.0
1 parent 21b5793 commit 0f038e3

File tree

12 files changed

+64
-67
lines changed

12 files changed

+64
-67
lines changed

.travis.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
7+
- 0.7
8+
- 1
89
- nightly
910
notifications:
1011
email: false
11-
# uncomment the following lines to override the default test script
12-
#script:
13-
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
14-
# - julia -e 'versioninfo(); Pkg.clone(pwd()); Pkg.build("SLEEF"); Pkg.test("SLEEF"; coverage=true)'
1512
after_success:
1613
# push coverage results
1714
- julia -e 'cd(Pkg.dir("SLEEF")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder()); Codecov.submit(Codecov.process_folder())'

Project.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name = "SLEEF"
2+
uuid = "3e6341c9-01f6-5312-b33f-f8894a2e817a"
3+
license = "MIT"
4+
repo = "https://github.com/musm/SLEEF.jl.git"
5+
version = "v0.5.0"
6+
7+
[extras]
8+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
9+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
10+
11+
[targets]
12+
test = ["Test","Printf"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ julia> SLEEF.exp(3f0)
4242

4343
The available functions include (within 1 ulp)
4444
```julia
45-
sin, cos, tan, asin, acos, atan, atan2, sincos, sinh, cosh, tanh,
45+
sin, cos, tan, asin, acos, atan, sincos, sinh, cosh, tanh,
4646
asinh, acosh, atanh, log, log2, log10, log1p, ilogb, exp, exp2, exp10, expm1, ldexp, cbrt, pow
4747
```
4848

REQUIRE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
julia 0.6
2-
Compat 0.33
1+
julia 0.7

benchmark/benchmark.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using SLEEF
22
using BenchmarkTools
33
using JLD, DataStructures
4+
using Printf
45

56
const RETUNE = false
67
const VERBOSE = true
@@ -110,17 +111,17 @@ end
110111
println("Running micro benchmarks...")
111112
results = run(suite; verbose=VERBOSE, seconds = 2)
112113

113-
print_with_color(:blue, "Benchmarks: median ratio SLEEF/Base\n")
114+
printstyled("Benchmarks: median ratio SLEEF/Base\n", color = :blue)
114115
for f in keys(micros)
115-
print_with_color(:magenta, string(f))
116+
printstyled(string(f) color = :magenta)
116117
for T in test_types
117118
println()
118119
print("time: ", )
119120
tratio = ratio(median(results["SLEEF"][f][string(T)]), median(results["Base"][f][string(T)])).time
120121
tcolor = tratio > 3 ? :red : tratio < 1.5 ? :green : :blue
121-
print_with_color(tcolor, @sprintf("%.2f",tratio), " ", string(T))
122+
printstyled(@sprintf("%.2f",tratio), " ", string(T), color = tcolor)
122123
if DETAILS
123-
print_with_color(:blue, "details SLEEF/Base\n")
124+
printstyled("details SLEEF/Base\n", color=:blue)
124125
println(results["SLEEF"][f][string(T)])
125126
println(results["Base"][f][string(T)])
126127
println()

src/SLEEF.jl

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
__precompile__()
2-
31
module SLEEF
42

5-
# export sin, cos, tan, asin, acos, atan, atan2, sincos, sinh, cosh, tanh,
3+
# export sin, cos, tan, asin, acos, atan, sincos, sinh, cosh, tanh,
64
# asinh, acosh, atanh, log, log2, log10, log1p, ilogb, exp, exp2, exp10, expm1, ldexp, cbrt, pow
75

86
# fast variants (within 3 ulp)
97
# export sin_fast, cos_fast, tan_fast, sincos_fast, asin_fast, acos_fast, atan_fast, atan2_fast, log_fast, cbrt_fast
108

11-
using Base.Math: @horner, exponent_bias, exponent_mask, significand_bits, IEEEFloat, exponent_raw_max
9+
using Base.Math: uinttype, @horner, exponent_bias, exponent_mask, significand_bits, IEEEFloat, exponent_raw_max
1210

13-
if VERSION < v"0.7.0-DEV.1430"
14-
using Base.Math: fpinttype
15-
else
16-
using Base: uinttype
17-
end
1811
## constants
1912

2013
const MLN2 = 6.931471805599453094172321214581765680755001343602552541206800094933936219696955e-01 # log(2)
@@ -113,7 +106,7 @@ for func in (:sin, :cos, :tan, :asin, :acos, :atan, :sinh, :cosh, :tanh,
113106
end
114107
end
115108

116-
for func in (:atan2, :hypot)
109+
for func in (:atan, :hypot)
117110
@eval begin
118111
$func(y::Real, x::Real) = $func(promote(float(y), float(x))...)
119112
$func(a::Float16, b::Float16) = Float16($func(Float32(a), Float32(b)))

src/log.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Compute the natural logarithm of `x`. The inverse of the natural logarithm is
109109
the natural expoenential function `exp(x)`
110110
"""
111111
function log(d::T) where {T<:Union{Float32,Float64}}
112-
o = d < realmin(T)
112+
o = d < floatmin(T)
113113
o && (d *= T(Int64(1) << 32) * T(Int64(1) << 32))
114114

115115
e = ilogb2k(d * T(1.0/0.75))
@@ -179,7 +179,7 @@ Compute the natural logarithm of `x`. The inverse of the natural logarithm is
179179
the natural expoenential function `exp(x)`
180180
"""
181181
function log_fast(d::T) where {T<:Union{Float32,Float64}}
182-
o = d < realmin(T)
182+
o = d < floatmin(T)
183183
o && (d *= T(Int64(1) << 32) * T(Int64(1) << 32))
184184

185185
e = ilogb2k(d * T(1.0/0.75))

src/priv.jl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ end
5050
end
5151

5252
@inline function ldexp3k(x::T, e::Int) where {T<:Union{Float32,Float64}}
53-
@static if VERSION < v"0.7.0-DEV.1430"
54-
reinterpret(T, reinterpret(Unsigned, x) + (Int64(e) << significand_bits(T)) % fpinttype(T))
55-
else
56-
reinterpret(T, reinterpret(Unsigned, x) + (Int64(e) << significand_bits(T)) % uinttype(T))
57-
end
53+
reinterpret(T, reinterpret(Unsigned, x) + (Int64(e) << significand_bits(T)) % uinttype(T))
5854
end
5955

6056
# threshold values for `ilogbk`
@@ -325,7 +321,7 @@ end
325321
end
326322

327323
@inline function logk(d::T) where {T<:Union{Float32,Float64}}
328-
o = d < realmin(T)
324+
o = d < floatmin(T)
329325
o && (d *= T(Int64(1) << 32) * T(Int64(1) << 32))
330326

331327
e = ilogb2k(d * T(1.0/0.75))

src/trig.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -764,11 +764,11 @@ const under_atan2(::Type{Float64}) = 5.5626846462680083984e-309
764764
const under_atan2(::Type{Float32}) = 2.9387372783541830947f-39
765765

766766
"""
767-
atan2(x, y)
767+
atan(x, y)
768768
769769
Compute the inverse tangent of `x/y`, using the signs of both `x` and `y` to determine the quadrant of the return value.
770770
"""
771-
function atan2(x::T, y::T) where {T<:Union{Float32,Float64}}
771+
function atan(x::T, y::T) where {T<:Union{Float32,Float64}}
772772
abs(y) < under_atan2(T) && (x *= T(Int64(1) << 53); y *= T(Int64(1) << 53))
773773
r = T(atan2k(Double(abs(x)), Double(y)))
774774

@@ -791,7 +791,7 @@ end
791791
792792
Compute the inverse tangent of `x/y`, using the signs of both `x` and `y` to determine the quadrant of the return value.
793793
"""
794-
function atan2_fast(x::T, y::T) where {T<:Union{Float32,Float64}}
794+
function atan_fast(x::T, y::T) where {T<:Union{Float32,Float64}}
795795
r = atan2k_fast(abs(x), y)
796796
r = flipsign(r, y)
797797
if isinf(y) || y == 0

test/accuracy.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,14 @@ IntF(::Type{Float32}) = Int32
4848
tol = 4
4949
test_acc(T, fun_table, xx, tol)
5050

51-
52-
sin_sincos_fast(x) = SLEEF.sincos_fast(x)[1]
53-
cos_sincos_fast(x) = SLEEF.sincos_fast(x)[2]
51+
global sin_sincos_fast(x) = (SLEEF.sincos_fast(x))[1]
52+
global cos_sincos_fast(x) = (SLEEF.sincos_fast(x))[2]
5453
fun_table = Dict(sin_sincos_fast => Base.sin, cos_sincos_fast => Base.cos)
5554
tol = 4
5655
test_acc(T, fun_table, xx, tol)
5756

58-
sin_sincos(x) = SLEEF.sincos(x)[1]
59-
cos_sincos(x) = SLEEF.sincos(x)[2]
57+
global sin_sincos(x) = (SLEEF.sincos(x))[1]
58+
global cos_sincos(x) = (SLEEF.sincos(x))[2]
6059
fun_table = Dict(sin_sincos => Base.sin, cos_sincos => Base.cos)
6160
tol = 1
6261
test_acc(T, fun_table, xx, tol)
@@ -88,11 +87,11 @@ IntF(::Type{Float32}) = Int32
8887
xx4 = map(Tuple{T,T}, [zip(-100:0.51:100, -100:0.52:100)...])
8988
xx = vcat(xx1, xx2, xx3, xx4)
9089

91-
fun_table = Dict(SLEEF.atan2_fast => Base.atan2)
90+
fun_table = Dict(SLEEF.atan_fast => Base.atan)
9291
tol = 2.5
9392
test_acc(T, fun_table, xx, tol)
9493

95-
fun_table = Dict(SLEEF.atan2 => Base.atan2)
94+
fun_table = Dict(SLEEF.atan => Base.atan)
9695
tol = 1
9796
test_acc(T, fun_table, xx, tol)
9897

0 commit comments

Comments
 (0)