Skip to content

Commit 47d078f

Browse files
Update quadword.jl
1 parent 3b04d45 commit 47d078f

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

src/doubletriple/quadword.jl

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,65 @@ function vec_sum(x0::T, x1::T, x2::T, x3::T) where {T}
55
s0, e1 = two_sum(x0, s1)
66
return s0,e1,e2,e3
77
end
8+
9+
function vsum_errbranch(x::NTuple{4,T}) where {T}
10+
y = zeros(T, 4)
11+
r = zeros(T, 4)
12+
e = zeros(T, 4)
13+
j = 1
14+
e[1] = x[1]
15+
for i = 1:2
16+
r[i], t = two_sum(e[i], x[i+1])
17+
if t !== zero(T)
18+
y[j] = r[i]
19+
e[i+1] = t
20+
j += 1
21+
else
22+
e[i+1] = r[i]
23+
end
24+
end
25+
y[j], y[j+1] = two_sum(e[3], x[4])
26+
return y
27+
end
28+
29+
function quadword(x1::T, x2::T, x3::T, x4::T) where {T}
30+
a1, a2 = two_sum(x1, x2)
31+
b1, b2 = two_sum(x3, x4)
32+
c1, c2 = two_sum(a1, b1)
33+
d1, d2 = two_sum(a2, b2)
34+
e1to4 = vec_sum(c1,c2,d1,d2)
35+
y = vsum_errbranch(e1to4)
36+
return (y...,)
37+
end
38+
39+
#=
40+
function vec_sum_errbranch(x0::T, x1::T, x2::T, x3::T) where {T}
41+
# n = 4
42+
j = zero(T)
43+
e0 = x0
44+
r0, et1 = two_sum(e0, x1)
45+
if !iszero(e1)
46+
y0 = r0
47+
e1 = et1
48+
j += 1
49+
else
50+
e1 = r0
51+
end
52+
r1, et2 = two_sum(e1, x2)
53+
if !iszero(e2)
54+
if iszero(j)
55+
y0 = r1
56+
y1 = zero(T)
57+
else
58+
y1 = r1
59+
end
60+
e2 = et2
61+
j += 1
62+
else
63+
e2 = r1
64+
end
65+
yj, yj+1 = two_sum(e2, e3)
66+
yj+2,..y3 = zero(T)
67+
return y0,y1,y2,y3
68+
end
69+
=#

0 commit comments

Comments
 (0)