Skip to content

Commit

Permalink
more refined robustness criteria
Browse files Browse the repository at this point in the history
thorek1 committed Oct 20, 2024
1 parent c8b1eec commit 42ebad0
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions src/algorithms/lyapunov.jl
Original file line number Diff line number Diff line change
@@ -27,16 +27,22 @@ function solve_lyapunov_equation(A::AbstractMatrix{Float64},
end # timeit_debug
@timeit_debug timer "Solve" begin

X, solved, i, reached_tol = solve_lyapunov_equation(A, C, Val(lyapunov_algorithm), tol = tol, timer = timer)
X, solved, i, reached_tol = solve_lyapunov_equation(A, C,
Val(lyapunov_algorithm),
tol = tol,
timer = timer)

if verbose
println("Lyapunov equation - converged to tol $tol: $solved; iterations: $i; reached tol: $reached_tol; algorithm: $lyapunov_algorithm")
end

if reached_tol < sqrt(tol) || A isa AbstractSparseMatrix
if (reached_tol < sqrt(tol) || A isa AbstractSparseMatrix) && lyapunov_algorithm :bicgstab
C = collect(C)

X, solved, i, reached_tol = solve_lyapunov_equation(A, C, Val(:bicgstab), tol = tol, timer = timer)
X, solved, i, reached_tol = solve_lyapunov_equation(A, C,
Val(:bicgstab),
tol = tol,
timer = timer)

if verbose
println("Lyapunov equation - converged to tol $tol: $solved; iterations: $i; reached tol: $reached_tol; algorithm: gmres")
@@ -46,7 +52,10 @@ function solve_lyapunov_equation(A::AbstractMatrix{Float64},

C = collect(C)

X, solved, i, reached_tol = solve_lyapunov_equation(A, C, Val(:lyapunov), tol = tol, timer = timer)
X, solved, i, reached_tol = solve_lyapunov_equation(A, C,
Val(:lyapunov),
tol = tol,
timer = timer)

if verbose
println("Lyapunov equation - converged to tol $tol: $solved; iterations: $i; reached tol: $reached_tol; algorithm: lyapunov")
2 changes: 1 addition & 1 deletion src/algorithms/sylvester.jl
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ function solve_sylvester_equation(A::M,
println("Sylvester equation - converged to tol $tol: $solved; iterations: $i; reached tol: $reached_tol; algorithm: $sylvester_algorithm")
end

if reached_tol < sqrt(tol)
if reached_tol < sqrt(tol) && sylvester_algorithm :bicgstab
a = collect(A)

c = collect(C)

0 comments on commit 42ebad0

Please sign in to comment.