-
Notifications
You must be signed in to change notification settings - Fork 10
/
MultiFloatsBenchmark.jl
52 lines (44 loc) · 1.37 KB
/
MultiFloatsBenchmark.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using Random
using LinearAlgebra
using GenericLinearAlgebra
using MultiFloats # Float64x2
using DoubleFloats # Double64
using Quadmath # Float128
using DecFP # Dec128
using ArbNumerics # ArbFloat
setextrabits(0)
setprecision(BigFloat, 106)
setprecision(ArbFloat, 106)
function test_qr(::Type{T}, n::Int) where {T}
Random.seed!(0)
A = T.(rand(Float64, n, n))
result, elapsed_time, _, _, _ = @timed qr(A)
num_correct_digits = -log10(Float64(sum(abs.(result.Q * result.R - A))))
println(rpad(T, 30), " | qr | ", round(num_correct_digits, digits=1), " | ", elapsed_time)
end
function test_pinv(::Type{T}, m::Int, n::Int) where {T}
Random.seed!(0)
A = T.(rand(Float64, m, n))
Apinv, elapsed_time, _, _, _ = @timed pinv(A)
num_correct_digits = -log10(Float64(sum(abs.(A * Apinv * A - A))))
println(rpad(T, 30), " | pinv | ", round(num_correct_digits, digits=1), " | ", elapsed_time)
end
const N = 400
const M = 250
function main()
while true
test_qr(Float64x2, N)
test_qr(Double64, N)
test_qr(Float128, N)
test_qr(Dec128, N)
test_qr(BigFloat, N)
test_qr(ArbFloat, N)
test_pinv(Float64x2, N, M)
test_pinv(Double64, N, M)
test_pinv(Float128, N, M)
# test_pinv(Dec128, N, M)
test_pinv(BigFloat, N, M)
# test_pinv(ArbFloat, N, M)
end
end
main()