Skip to content

Commit

Permalink
use LazySets for expv
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Jun 2, 2023
1 parent 093923e commit fecb219
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
19 changes: 7 additions & 12 deletions src/Discretization/exponentiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/Initialization/init_ExponentialUtilities.jl
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -29,6 +29,5 @@ eval(quote
end
end)

eval(load_Φ₁_krylov())
eval(load_krylov_LGG09_homog())
eval(load_krylov_LGG09_inhomog())

0 comments on commit fecb219

Please sign in to comment.