Skip to content

Commit 0a71881

Browse files
committed
remove dead code from src/doubletriple
1 parent f00b992 commit 0a71881

File tree

8 files changed

+4
-1217
lines changed

8 files changed

+4
-1217
lines changed

src/doubletriple/double.jl

Lines changed: 0 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,3 @@
1-
function double(::Type{T}, x::BigFloat) where {T<:IEEEFloat}
2-
prec = precision(BigFloat)
3-
setprecision(BigFloat, max(prec, 768))
4-
hi = T(x)
5-
lo = T(x - hi)
6-
setprecision(BigFloat, prec)
7-
return hi, lo
8-
end
9-
10-
function double(::Type{T}, x::String) where {T<:IEEEFloat}
11-
prec = precision(BigFloat)
12-
setprecision(BigFloat, 768)
13-
z = parse(BigFloat, x)
14-
hi = T(z)
15-
lo = T(z - hi)
16-
setprecision(BigFloat, prec)
17-
return hi, lo
18-
end
19-
20-
double64(x::BigFloat) = double(Float64, x)
21-
double32(x::BigFloat) = double(Float32, x)
22-
double16(x::BigFloat) = double(Float16, x)
23-
24-
double64(x::String) = double(Float64, x)
25-
double32(x::String) = double(Float32, x)
26-
double16(x::String) = double(Float16, x)
27-
28-
function double_inv(::Type{T}, x::BigFloat) where {T<:IEEEFloat}
29-
prec = precision(BigFloat)
30-
setprecision(BigFloat, max(prec, 768))
31-
x = inv(x)
32-
hi = T(x)
33-
lo = T(x - hi)
34-
setprecision(BigFloat, prec)
35-
return hi, lo
36-
end
37-
38-
double64inv(x::BigFloat) = double_inv(Float64, x)
39-
double32inv(x::BigFloat) = double_inv(Float32, x)
40-
double16inv(x::BigFloat) = double_inv(Float16, x)
41-
421
#=
432
algorithms from
443
Mioara Joldes, Jean-Michel Muller, Valentina Popescu.
@@ -88,16 +47,6 @@ function TwoSum(a::T, b::T) where {T<:AbstractFloat}
8847
return s, t
8948
end
9049

91-
function TwoDiff(a::T, b::T) where {T<:AbstractFloat}
92-
s = a - b
93-
a1 = s + b
94-
b1 = s - a1
95-
da = a - a1
96-
db = b - b1
97-
t = da + db
98-
return s, t
99-
end
100-
10150
# Algorithm 3 in ref: error-free transformation
10251

10352
@inline function Fast2Mult(a::T, b::T) where {T<:AbstractFloat}
@@ -115,47 +64,6 @@ end
11564
return zₕᵢ, zₗₒ
11665
end
11766

118-
@inline function DWMinusFP(xₕᵢ::T, xₗₒ::T, y::T) where {T<:AbstractFloat}
119-
sₕᵢ, sₗₒ = TwoDiff(xₕᵢ, y)
120-
v = xₗₒ + sₗₒ
121-
zₕᵢ, zₗₒ = TwoSum(sₕᵢ, v)
122-
return zₕᵢ, zₗₒ
123-
end
124-
125-
# Algorithm 6 in ref: relerr 3u² + 13u³ [reltime 35]
126-
127-
function AccurateDWPlusDW(xₕᵢ::T, xₗₒ::T, yₕᵢ::T, yₗₒ::T) where {T<:AbstractFloat}
128-
sₕᵢ, sₗₒ = TwoSum(xₕᵢ, yₕᵢ)
129-
tₕᵢ, tₗₒ = TwoSum(xₗₒ, yₗₒ)
130-
c = sₗₒ + tₕᵢ
131-
vₕᵢ, vₗₒ = Fast2Sum(sₕᵢ, c)
132-
w = tₗₒ + vₗₒ
133-
zₕᵢ, zₗₒ = Fast2Sum(vₕᵢ, w)
134-
return zₕᵢ, zₗₒ
135-
end
136-
137-
function AccurateDWMinusDW(xₕᵢ::T, xₗₒ::T, yₕᵢ::T, yₗₒ::T) where {T<:AbstractFloat}
138-
sₕᵢ, sₗₒ = TwoDiff(xₕᵢ, yₕᵢ)
139-
tₕᵢ, tₗₒ = TwoDiff(xₗₒ, yₗₒ)
140-
c = sₗₒ + tₕᵢ
141-
vₕᵢ, vₗₒ = Fast2Sum(sₕᵢ, c)
142-
w = tₗₒ + vₗₒ
143-
zₕᵢ, zₗₒ = Fast2Sum(vₕᵢ, w)
144-
return zₕᵢ, zₗₒ
145-
end
146-
147-
148-
# Algorithm 7 in ref: relerr (³/₂)u² + 4u³ [reltime 18]
149-
150-
@inline function DWTimesFP1(xₕᵢ::T, xₗₒ::T, y::T) where {T<:AbstractFloat}
151-
cₕᵢ, c1 = Fast2Mult(xₕᵢ, y)
152-
c2 = xₗₒ * y
153-
tₕᵢ, t1 = Fast2Sum(cₕᵢ, c2)
154-
t2 = t1 + c1
155-
zₕᵢ, zₗₒ = Fast2Sum(tₕᵢ, t2)
156-
return zₕᵢ, zₗₒ
157-
end
158-
15967
# Algorithm 9 in ref: relerr 2u² [reltime 15]
16068

16169
@inline function DWTimesFP3(xₕᵢ::T, xₗₒ::T, y::T) where {T<:AbstractFloat}
@@ -165,86 +73,9 @@ end
16573
return zₕᵢ, zₗₒ
16674
end
16775

168-
# Algorithm 11 in ref: relerr 6u² [reltime 16]
169-
170-
function DWTimesDW2(xₕᵢ::T, xₗₒ::T, yₕᵢ::T, yₗₒ::T) where {T<:AbstractFloat}
171-
cₕᵢ, c1 = Fast2Mult(xₕᵢ, yₕᵢ)
172-
t0 = xₕᵢ * yₗₒ
173-
c2 = fma(xₗₒ, yₕᵢ, t0)
174-
c3 = c1 + c2
175-
zₕᵢ, zₗₒ = Fast2Sum(cₕᵢ, c3)
176-
return zₕᵢ, zₗₒ
177-
end
178-
179-
# Algorithm 12 in ref: relerr 5u² [reltime 17]
180-
181-
function DWTimesDW3(xₕᵢ::T, xₗₒ::T, yₕᵢ::T, yₗₒ::T) where {T<:AbstractFloat}
182-
cₕᵢ, c1 = Fast2Mult(xₕᵢ, yₕᵢ)
183-
t0 = xₗₒ * yₗₒ
184-
t1 = fma(xₕᵢ, yₗₒ, t0)
185-
c2 = fma(xₗₒ, yₕᵢ, t1)
186-
c3 = c1 + c2
187-
zₕᵢ, zₗₒ = Fast2Sum(cₕᵢ, c3)
188-
return zₕᵢ, zₗₒ
189-
end
190-
191-
# Algorithm 15 in ref: relerr 3u² [reltime 27]
192-
193-
function DWDivFP3(xₕᵢ::T, xₗₒ::T, y::T) where {T<:AbstractFloat}
194-
tₕᵢ = xₕᵢ / y
195-
pₕᵢ, pₗₒ = Fast2Mult(tₕᵢ, y)
196-
dₕᵢ = xₕᵢ - pₕᵢ
197-
dₗₒ = dₕᵢ - pₗₒ
198-
d = dₗₒ + xₗₒ
199-
tₗₒ = d / y
200-
zₕᵢ, zₗₒ = Fast2Sum(tₕᵢ, tₗₒ)
201-
return zₕᵢ, zₗₒ
202-
end
203-
204-
# Algorithm 17 in ref: relerr 15u² + 56u³ [reltime 50]
205-
206-
function DWDivDW2(xₕᵢ::T, xₗₒ::T, yₕᵢ::T, yₗₒ::T) where {T<:AbstractFloat}
207-
tₕᵢ = xₕᵢ / yₕᵢ
208-
rₕᵢ, rₗₒ = DWTimesFP1(yₕᵢ, yₗₒ, tₕᵢ)
209-
dₕᵢ = xₕᵢ - rₕᵢ
210-
dₗₒ = xₗₒ - rₗₒ
211-
d = dₕᵢ + dₗₒ
212-
tₗₒ = d / yₕᵢ
213-
zₕᵢ, zₗₒ = Fast2Sum(tₕᵢ, tₗₒ)
214-
return zₕᵢ, zₗₒ
215-
end
216-
217-
# Algorithm 18 in ref: relerr < 10u² (6u² seen) [reltime 107]
218-
# (note DWTimesDW3 replaces DWTimesDW2 per ref)
219-
220-
function DWDivDW3(xₕᵢ::T, xₗₒ::T, yₕᵢ::T, yₗₒ::T) where {T<:AbstractFloat}
221-
tₕᵢ = inv(yₕᵢ)
222-
rₕᵢ = fma(yₕᵢ, -tₕᵢ, one(T))
223-
rₗₒ = -(yₗₒ * tₕᵢ)
224-
eₕᵢ, eₗₒ = Fast2Sum(rₕᵢ, rₗₒ)
225-
dₕᵢ, dₗₒ = DWTimesFP3(eₕᵢ, eₗₒ, tₕᵢ)
226-
mₕᵢ, mₗₒ = DWPlusFP(dₕᵢ, dₗₒ, tₕᵢ)
227-
zₕᵢ, zₗₒ = DWTimesDW3(xₕᵢ, xₗₒ, mₕᵢ, mₗₒ)
228-
return zₕᵢ, zₗₒ
229-
end
230-
23176
# inv(...) using Algorithms 17 and 18
23277

233-
# Algorithm 17 in ref: relerr 15u² + 56u³ [reltime 48]
234-
235-
function DWInvDW2(yₕᵢ::T, yₗₒ::T) where {T<:AbstractFloat}
236-
tₕᵢ = one(T) / yₕᵢ
237-
rₕᵢ, rₗₒ = DWTimesFP1(yₕᵢ, yₗₒ, tₕᵢ)
238-
dₕᵢ = one(T) - rₕᵢ
239-
dₗₒ = -rₗₒ
240-
d = dₕᵢ + dₗₒ
241-
tₗₒ = d / yₕᵢ
242-
zₕᵢ, zₗₒ = Fast2Sum(tₕᵢ, tₗₒ)
243-
return zₕᵢ, zₗₒ
244-
end
245-
24678
# Algorithm 18 in ref: relerr < 10u² (6u² seen) [reltime 72]
247-
# (note DWTimesDW3 replaces DWTimesDW2 per ref)
24879

24980
function DWInvDW3(yₕᵢ::T, yₗₒ::T) where {T<:AbstractFloat}
25081
tₕᵢ = inv(yₕᵢ)

src/doubletriple/double_consts.jl

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,8 @@
1-
const one_d64 = (1.0, 0.0)
2-
31
const pi_4o1_d64 = (12.56637061435917200, 4.8985871965894130e-16)
42
const pi_2o1_d64 = ( 6.28318530717958600, 2.4492935982947064e-16)
53
const pi_1o1_d64 = ( 3.14159265358979300, 1.2246467991473532e-16)
64
const pi_1o2_d64 = ( 1.57079632679489660, 6.1232339957367660e-17)
7-
const pi_15o32_d64 = ( 1.47262155637021560, -5.3616983752483473e-17)
8-
const pi_7o16_d64 = ( 1.37444678594553450, 5.3578297462696700e-17)
9-
const pi_1o3_d64 = ( 1.04719755119659790, -1.0720817664510910e-16)
105
const pi_1o4_d64 = ( 0.78539816339744830, 3.0616169978683830e-17)
11-
const pi_1o6_d64 = ( 0.52359877559829890, -5.3604088322554550e-17)
12-
const pi_1o8_d64 = ( 0.39269908169872414, 1.5308084989341915e-17)
13-
const pi_1o12_d64 = ( 0.26179938779914946, -2.6802044161277275e-17)
14-
const pi_1o16_d64 = ( 0.19634954084936207, 7.6540424946709580e-18)
15-
const pi_1o24_d64 = ( 0.13089969389957473, -1.3401022080638637e-17)
16-
const pi_1o32_d64 = ( 0.09817477042468103, 3.8270212473354790e-18)
17-
const pi_1o64_d64 = ( 0.04908738521234052, 1.9135106236677394e-18)
18-
const pi_1o128_d64 = ( 0.02454369260617026, 9.5675531183386970e-19)
19-
const pi_1o256_d64 = ( 0.01227184630308513, 4.7837765591693480e-19)
20-
21-
22-
const inv_pi_4o1_d64 = ( 0.07957747154594767, -4.9196691687956215e-18)
23-
const inv_pi_2o1_d64 = ( 0.15915494309189535, -9.8393383375912430e-18)
24-
const inv_pi_1o1_d64 = ( 0.31830988618379070, -1.9678676675182486e-17)
25-
const inv_pi_1o2_d64 = ( 0.63661977236758140, -3.9357353350364970e-17)
26-
const inv_pi_15o32_d64 = ( 0.67906109052542010, 2.4632204570453420e-17)
27-
const inv_pi_7o16_d64 = ( 0.72756545413437870, 2.6011543692324530e-18)
28-
const inv_pi_1o3_d64 = ( 0.95492965855137200, -3.5248787942896340e-18)
29-
const inv_pi_1o4_d64 = ( 1.27323954473516280, -7.8714706700729940e-17)
30-
const inv_pi_1o6_d64 = ( 1.90985931710274400, -7.0497575885792670e-18)
31-
const inv_pi_1o8_d64 = ( 2.54647908947032550, -1.5742941340145989e-16)
32-
const inv_pi_1o12_d64 = ( 3.81971863420548800, -1.4099515177158535e-17)
33-
const inv_pi_1o16_d64 = ( 5.09295817894065100, -3.1485882680291977e-16)
34-
const inv_pi_1o24_d64 = ( 7.63943726841097600, -2.8199030354317070e-17)
35-
const inv_pi_1o32_d64 = ( 10.18591635788130200, -6.2971765360583950e-16)
36-
const inv_pi_1o64_d64 = ( 20.37183271576260400, -1.2594353072116790e-15)
37-
const inv_pi_1o128_d64 = ( 40.74366543152521000, -2.5188706144233580e-15)
38-
const inv_pi_1o256_d64 = ( 81.48733086305042000, -5.0377412288467160e-15)
396

407
const pi_4o1_d32 = (12.566371f0, -3.496911f-7)
418
const pi_4o1_d16 = (Float16(12.56), Float16(0.00387))
@@ -71,14 +38,3 @@ pi1o2(::Type{Double16}) = Double16(pi_1o2_d16)
7138
pi1o4(::Type{Double64}) = Double64(pi_1o4_d64)
7239
pi1o4(::Type{Double32}) = Double32(pi_1o4_d32)
7340
pi1o4(::Type{Double16}) = Double16(pi_1o4_d16)
74-
75-
# below is to be removed
76-
const twopi_d64 = (6.283185307179586, 2.4492935982947064e-16)
77-
const onepi_d64 = (3.141592653589793, 1.2246467991473532e-16)
78-
const halfpi_d64 = (1.5707963267948966, 6.123233995736766e-17)
79-
const qrtrpi_d64 = (0.7853981633974483, 3.061616997868383e-17)
80-
81-
const inv_twopi_d64 = (0.15915494309189535, -9.839338337591243e-18)
82-
const inv_onepi_d64 = (0.3183098861837907, -1.9678676675182486e-17)
83-
const inv_halfpi_d64 = (0.6366197723675814, -3.935735335036497e-17)
84-
const inv_qrtrpi_d64 = (1.2732395447351628, -7.871470670072994e-17)

src/doubletriple/quadword.jl

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)