File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 3
3
# written by @oscardssmith
4
4
function cos_sum (x, xn)
5
5
s = x + xn
6
- n, r = Base . Math . rem_pio2_kernel (s)
6
+ n, r = reduce_pi02_med (s)
7
7
lo = r. lo - ((s - x) - xn)
8
8
hi = r. hi + lo
9
9
y = Base. Math. DoubleFloat64 (hi, r. hi- hi+ lo)
21
21
# function to more accurately compute sin(x + xn)
22
22
function sin_sum (x, xn)
23
23
s = x + xn
24
- n, r = Base . Math . rem_pio2_kernel (s)
24
+ n, r = reduce_pi02_med (s)
25
25
lo = r. lo - ((s - x) - xn)
26
26
hi = r. hi + lo
27
27
y = Base. Math. DoubleFloat64 (hi, r. hi- hi+ lo)
@@ -36,3 +36,12 @@ function sin_sum(x, xn)
36
36
return - Base. Math. cos_kernel (y)
37
37
end
38
38
end
39
+ @inline function reduce_pi02_med (x:: Float64 )
40
+ pio2_1 = 1.57079632673412561417e+00
41
+
42
+ fn = round (x* (2 / pi ))
43
+ r = muladd (- fn, pio2_1, x)
44
+ w = fn * 6.07710050650619224932e-11
45
+ y = r- w
46
+ return unsafe_trunc (Int, fn), Base. Math. DoubleFloat64 (y, (r- y)- w)
47
+ end
You can’t perform that action at this time.
0 commit comments