Skip to content

Commit c9b4449

Browse files
committed
Benchmarks fix 3
1 parent 3d9b138 commit c9b4449

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/Manifest.toml
2-
/testscripts
2+
/testscripts
3+
/benchmark/tune.json

benchmark/example_benchmark.jl

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,32 @@ A[13,21] = A[21,13] = 1
7777
A[16,30] = A[30,16] = 1
7878
A[20,36] = A[36,20] = 1
7979

80-
81-
system = System{Float64}(A, ones(Int,size(A)[1])*6)
82-
8380
function randomize_posdef!(system)
84-
randomize!(system)
85-
F = full_matrix(system)
86-
while !isposdef(F)
87-
for i=1:size(A)[1]
88-
system.matrix_entries[i,i].value += I
89-
end
90-
F = full_matrix(system)
81+
randomize!(system,rand)
82+
for i=1:size(A)[1]
83+
system.matrix_entries[i,i].value += 1000*I
9184
end
9285
end
9386

87+
88+
system = System{Float64}(A, ones(Int,size(A)[1])*3)
89+
systemldlt = System{Float64}(A, ones(Int,size(A)[1])*3, symmetric=true)
90+
systemllt = System{Float64}(A, ones(Int,size(A)[1])*3, symmetric=true)
91+
9492
SUITE["ldu"] = @benchmarkable ldu_solve!($system) samples=2 setup=(randomize!($system))
9593
SUITE["lu"] = @benchmarkable lu_solve!($system) samples=2 setup=(randomize!($system))
96-
SUITE["ldlt"] = @benchmarkable ldlt_solve!($system) samples=2 setup=(randomize!($system))
97-
SUITE["llt"] = @benchmarkable llt_solve!($system) samples=2 setup=(randomize_posdef!($system))
94+
SUITE["ldlt"] = @benchmarkable ldlt_solve!($systemldlt) samples=2 setup=(randomize!($systemldlt))
95+
SUITE["llt"] = @benchmarkable llt_solve!($systemllt) samples=2 setup=(randomize_posdef!($systemllt))
96+
97+
# A = [
98+
# 0 1 1 1 1
99+
# 1 0 1 1 1
100+
# 1 1 0 1 1
101+
# 1 1 1 0 1
102+
# 1 1 1 1 0
103+
# ]
104+
105+
106+
107+
108+

src/solvers/llt.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ function llt_factorization_cyclic!(entry_lu, offdiagonal_lu, offdiagonal_ul)
1616
entry_lu.value -= offdiagonal_lu.value * offdiagonal_ul.value'
1717
return
1818
end
19+
# TODO currently allocates memory
20+
function llt_diagonal_root!(diagonal)
21+
diagonal.value = sqrt(diagonal.value)
22+
end
1923

2024

2125
function llt_factorization!(system::System)
@@ -36,7 +40,7 @@ function llt_factorization!(system::System)
3640
end
3741
llt_factorization_acyclic!(matrix_entries[v,v], matrix_entries[v,c], matrix_entries[c,c], diagonal_inverses[c])
3842
end
39-
matrix_entries[v,v].value = sqrt(matrix_entries[v,v].value)
43+
llt_diagonal_root!(matrix_entries[v,v])
4044
end
4145
return
4246
end

0 commit comments

Comments
 (0)