Skip to content

Commit

Permalink
timeroutputs commented out
Browse files Browse the repository at this point in the history
  • Loading branch information
thorek1 committed Dec 18, 2024
1 parent e11e62e commit d315cb2
Show file tree
Hide file tree
Showing 9 changed files with 660 additions and 658 deletions.
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
SymPyPythonCall = "bc8888f7-b21e-4b7c-a06a-5d9c9496438c"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
ThreadedSparseArrays = "59d54670-b8ac-4d81-ab7a-bb56233e17ab"
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[weakdeps]
Expand Down Expand Up @@ -94,7 +93,6 @@ SymPyPythonCall = "0.2, 0.3, 0.4"
Symbolics = "5, 6"
Test = "1"
ThreadedSparseArrays = "0.2.3, 0.3"
TimerOutputs = "0.5"
Turing = "0.30, 0.31, 0.32, 0.33, 0.34, 0.35"
Unicode = "1"
Zygote = "0.6"
Expand Down
222 changes: 113 additions & 109 deletions src/MacroModelling.jl

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions src/algorithms/lyapunov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ function solve_lyapunov_equation(A::AbstractMatrix{Float64},
C::AbstractMatrix{Float64};
lyapunov_algorithm::Symbol = :doubling,
tol::AbstractFloat = 1e-12,
verbose::Bool = false,
timer::TimerOutput = TimerOutput())
@timeit_debug timer "Solve lyapunov equation" begin
@timeit_debug timer "Choose matrix formats" begin
# timer::TimerOutput = TimerOutput(),
verbose::Bool = false)
# @timeit_debug timer "Solve lyapunov equation" begin
# @timeit_debug timer "Choose matrix formats" begin

if lyapunov_algorithm β‰  :bartels_stewart
A = choose_matrix_format(A)
Expand All @@ -25,8 +25,8 @@ function solve_lyapunov_equation(A::AbstractMatrix{Float64},
C = choose_matrix_format(C, density_threshold = 0.0)
# C = collect(C) # C is always dense because the output will be dense in all of these cases as we use this function to compute dense covariance matrices

end # timeit_debug
@timeit_debug timer "Solve" begin
# end # timeit_debug
# @timeit_debug timer "Solve" begin

X, i, reached_tol = solve_lyapunov_equation(A, C,
Val(lyapunov_algorithm),
Expand Down Expand Up @@ -65,8 +65,8 @@ function solve_lyapunov_equation(A::AbstractMatrix{Float64},
end
end

end # timeit_debug
end # timeit_debug
# end # timeit_debug
# end # timeit_debug

# if (reached_tol > tol) println("Lyapunov failed: $reached_tol") end

Expand All @@ -78,8 +78,8 @@ function rrule(::typeof(solve_lyapunov_equation),
C::AbstractMatrix{Float64};
lyapunov_algorithm::Symbol = :doubling,
tol::AbstractFloat = 1e-12,
verbose::Bool = false,
timer::TimerOutput = TimerOutput())
# timer::TimerOutput = TimerOutput(),
verbose::Bool = false)

P, solved = solve_lyapunov_equation(A, C, lyapunov_algorithm = lyapunov_algorithm,
# tol = tol,
Expand All @@ -106,8 +106,8 @@ function solve_lyapunov_equation( A::AbstractMatrix{β„±.Dual{Z,S,N}},
C::AbstractMatrix{β„±.Dual{Z,S,N}};
lyapunov_algorithm::Symbol = :doubling,
tol::AbstractFloat = 1e-12,
verbose::Bool = false,
timer::TimerOutput = TimerOutput()) where {Z,S,N}
# timer::TimerOutput = TimerOutput(),
verbose::Bool = false) where {Z,S,N}
# unpack: AoS -> SoA
AΜ‚ = β„±.value.(A)
CΜ‚ = β„±.value.(C)
Expand Down Expand Up @@ -147,8 +147,8 @@ end
function solve_lyapunov_equation(A::Union{β„’.Adjoint{Float64,Matrix{Float64}},DenseMatrix{Float64}},
C::Union{β„’.Adjoint{Float64,Matrix{Float64}},DenseMatrix{Float64}},
::Val{:bartels_stewart};
tol::AbstractFloat = 1e-12,
timer::TimerOutput = TimerOutput())
# timer::TimerOutput = TimerOutput(),
tol::AbstractFloat = 1e-12)
𝐂 = try
MatrixEquations.lyapd(A, C)
catch
Expand All @@ -175,8 +175,8 @@ end
function solve_lyapunov_equation( A::AbstractSparseMatrix{Float64},
C::AbstractSparseMatrix{Float64},
::Val{:doubling};
tol::Float64 = 1e-14,
timer::TimerOutput = TimerOutput())
# timer::TimerOutput = TimerOutput(),
tol::Float64 = 1e-14)
𝐂 = copy(C)
𝐀 = copy(A)

Expand Down Expand Up @@ -222,8 +222,8 @@ end
function solve_lyapunov_equation( A::Union{β„’.Adjoint{Float64,Matrix{Float64}},DenseMatrix{Float64}},
C::AbstractSparseMatrix{Float64},
::Val{:doubling};
tol::Float64 = 1e-14,
timer::TimerOutput = TimerOutput())
# timer::TimerOutput = TimerOutput(),
tol::Float64 = 1e-14)
𝐂 = copy(C)
𝐀 = copy(A)

Expand Down Expand Up @@ -272,8 +272,8 @@ end
function solve_lyapunov_equation( A::AbstractSparseMatrix{Float64},
C::Union{β„’.Adjoint{Float64,Matrix{Float64}},DenseMatrix{Float64}},
::Val{:doubling};
tol::Float64 = 1e-14,
timer::TimerOutput = TimerOutput())
# timer::TimerOutput = TimerOutput(),
tol::Float64 = 1e-14)
𝐂 = copy(C)
𝐀 = copy(A)
𝐂A = collect(𝐀)
Expand Down Expand Up @@ -334,8 +334,8 @@ end
function solve_lyapunov_equation( A::Union{β„’.Adjoint{Float64,Matrix{Float64}},DenseMatrix{Float64}},
C::Union{β„’.Adjoint{Float64,Matrix{Float64}},DenseMatrix{Float64}},
::Val{:doubling};
tol::Float64 = 1e-14,
timer::TimerOutput = TimerOutput())
# timer::TimerOutput = TimerOutput(),
tol::Float64 = 1e-14)
𝐂 = copy(C)
𝐂¹ = copy(C)
𝐀 = copy(A)
Expand Down Expand Up @@ -391,8 +391,8 @@ end
function solve_lyapunov_equation(A::AbstractMatrix{Float64},
C::Union{β„’.Adjoint{Float64,Matrix{Float64}},DenseMatrix{Float64}},
::Val{:bicgstab};
tol::Float64 = 1e-14,
timer::TimerOutput = TimerOutput())
# timer::TimerOutput = TimerOutput(),
tol::Float64 = 1e-14)
tmpΜ„ = similar(C)
𝐗 = similar(C)

Expand Down Expand Up @@ -431,8 +431,8 @@ end
function solve_lyapunov_equation(A::AbstractMatrix{Float64},
C::Union{β„’.Adjoint{Float64,Matrix{Float64}},DenseMatrix{Float64}},
::Val{:gmres};
tol::Float64 = 1e-14,
timer::TimerOutput = TimerOutput())
# timer::TimerOutput = TimerOutput(),
tol::Float64 = 1e-14)
tmpΜ„ = similar(C)
𝐗 = similar(C)

Expand Down
Loading

0 comments on commit d315cb2

Please sign in to comment.