From fecb2191871684d78fc5e4919610865eeb169fb8 Mon Sep 17 00:00:00 2001 From: schillic Date: Sat, 22 Apr 2023 22:37:20 +0200 Subject: [PATCH] use LazySets for expv --- src/Discretization/exponentiation.jl | 19 +++++++------------ .../init_ExponentialUtilities.jl | 3 +-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/Discretization/exponentiation.jl b/src/Discretization/exponentiation.jl index 99d8191f74..98a60aa13a 100644 --- a/src/Discretization/exponentiation.jl +++ b/src/Discretization/exponentiation.jl @@ -323,18 +323,13 @@ function _Φ₁_u(A, δ, alg, u::AbstractVector, Φ=nothing) return A \ x end -function load_Φ₁_krylov() - return quote - - # compute Φ₁(A, δ)u = A^{-1}(exp(Aδ) - I) u without explicitly computing exp(Aδ) - # and assuming that A is invertible - function _Φ₁_u(A, δ, alg::LazyExpAlg, u::AbstractVector, ::Nothing) - w = expv(1.0 * δ, A, u; m=alg.m, tol=alg.tol) - x = w - u - return A \ x - end - end -end # quote / load_Φ₁_krylov() +# compute Φ₁(A, δ)u = A^{-1}(exp(Aδ) - I) u without explicitly computing exp(Aδ) +# and assuming that A is invertible +function _Φ₁_u(A, δ, alg::LazyExpAlg, u::AbstractVector, ::Nothing) + w = LazySets._expmv(δ, A, u; m=alg.m, tol=alg.tol) + x = w - u + return A \ x +end """ Φ₂(A::AbstractMatrix, δ, [alg]::AbstractExpAlg=BaseExp, [isinv]::Bool=false, [Φ]=nothing) diff --git a/src/Initialization/init_ExponentialUtilities.jl b/src/Initialization/init_ExponentialUtilities.jl index 7c12c2466c..11078ef305 100644 --- a/src/Initialization/init_ExponentialUtilities.jl +++ b/src/Initialization/init_ExponentialUtilities.jl @@ -1,5 +1,5 @@ eval(quote - using .ExponentialUtilities: expv, expv!, phiv!, arnoldi!, KrylovSubspace + using .ExponentialUtilities: expv!, phiv!, arnoldi!, KrylovSubspace # Compute out <- exp(A * NSTEPS * dt) * b function _expv(A, b, NSTEPS, dt; hermitian=false, m=min(30, size(A, 1)), tol=1e-7) @@ -29,6 +29,5 @@ eval(quote end end) -eval(load_Φ₁_krylov()) eval(load_krylov_LGG09_homog()) eval(load_krylov_LGG09_inhomog())