Skip to content

Commit cec8fce

Browse files
authored
Merge pull request #92 from JuliaMath/oscardssmith-better-sin_sum
Varargs don't specialize
2 parents ab48a96 + d03ff7f commit cec8fce

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/misc.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Base.Math: sin_kernel, cos_kernel, sincos_kernel, rem_pio2_kernel, DoubleF
44
computes sin(sum(xs)) where xs are sorted by absolute value
55
Doing this is much more accurate than the naive sin(sum(xs))
66
"""
7-
function sin_sum(xs::Vararg{T})::T where T<:Base.IEEEFloat
7+
function sin_sum(xs::Vararg{T, N})::T where {T<:Base.IEEEFloat, N}
88
n, y = rem_pio2_sum(xs...)
99
n &= 3
1010
if n == 0
@@ -22,7 +22,7 @@ end
2222
computes sincos(sum(xs)) where xs are sorted by absolute value
2323
Doing this is much more accurate than the naive sincos(sum(xs))
2424
"""
25-
function sincos_sum(xs::Vararg{T})::T where T<:Base.IEEEFloat
25+
function sincos_sum(xs::Vararg{T, N})::T where {T<:Base.IEEEFloat, N}
2626
n, y = rem_pio2_sum(xs...)
2727
n &= 3
2828
si, co = sincos_kernel(y)
@@ -37,7 +37,7 @@ function sincos_sum(xs::Vararg{T})::T where T<:Base.IEEEFloat
3737
end
3838
end
3939

40-
function rem_pio2_sum(xs::Vararg{Float64})
40+
function rem_pio2_sum(xs::Vararg{Float64, N}) where N
4141
n = 0
4242
hi, lo = 0.0, 0.0
4343
for x in xs
@@ -65,7 +65,7 @@ function rem_pio2_sum(xs::Vararg{Float64})
6565
return n, DoubleFloat64(hi, lo)
6666
end
6767

68-
function rem_pio2_sum(xs::Vararg{Float32})
68+
function rem_pio2_sum(xs::Vararg{Float32, N}) where N
6969
y = 0.0
7070
n = 0
7171
# The minimum cosine or sine of any Float32 that gets reduced is 1.6e-9
@@ -85,7 +85,7 @@ function rem_pio2_sum(xs::Vararg{Float32})
8585
return n + n_i, DoubleFloat32(y.hi)
8686
end
8787

88-
function rem_pio2_sum(xs::Vararg{Float16})
88+
function rem_pio2_sum(xs::Vararg{Float16, N}) where N
8989
y = sum(Float64, xs) #Float16 can be losslessly accumulated in Float64
9090
n, y = rem_pio2_kernel(y)
9191
return n, DoubleFloat32(y.hi)

0 commit comments

Comments
 (0)