Skip to content

Commit

Permalink
use symbols in discretization, renamings
Browse files Browse the repository at this point in the history
  • Loading branch information
mforets committed Mar 18, 2020
1 parent 125ae83 commit def8172
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/Continuous/discretization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function discretize(ivp::IVP{<:CLCS, <:LazySet}, δ::Float64, alg::Forward)
Phi2A_abs = Φ₂(A_abs, δ, alg.phi2_method)

# "forward" algorithm, uses E⁺
@assert alg.sih_method == "concrete"
@assert alg.sih_method == :concrete
# TODO : specialize, add option to compute the concrete linear map
Einit = symmetric_interval_hull(Phi2A_abs * symmetric_interval_hull((A * A) * X0))

Expand All @@ -62,7 +62,7 @@ function discretize(ivp::IVP{<:CLCCS, <:LazySet}, δ::Float64, alg::Forward)
A_abs = _elementwise_abs(A)
Phi2A_abs = Φ₂(A_abs, δ, alg.phi2_method)

@assert alg.sih_method == "concrete"
@assert alg.sih_method == :concrete
# TODO : specialize, add option to compute the concrete linear map
Einit = symmetric_interval_hull(Phi2A_abs * symmetric_interval_hull((A * A) * X0))

Expand Down
40 changes: 20 additions & 20 deletions src/Continuous/exponentiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ using LinearAlgebra: checksquare
@inline _exp(A::IdentityMultiple) = IdentityMultiple(exp(A.M.λ), size(A, 1))

"""
_exp(A::AbstractMatrix, δ::Float64, method::String)
_exp(A::AbstractMatrix, δ::Float64, method::Symbol)
Compute the matrix exponential ``e^{Aδ}``.
### Input
- `A` -- matrix
- `δ` -- step size
- `method` -- the method used to take the matrix exponential of `A`;
- `method` -- symbol with the method used to take the matrix exponential of `A`;
possible options are:
- `"base"` -- use the scaling and squaring method implemented in Julia standard
library; see `?exp` for details
- `"lazy"` -- return a lazy wrapper type around the matrix exponential using
the implementation `LazySets.SparseMatrixExp`
- `"pade"` -- apply Pade approximant method to compute the matrix exponential
of a sparse matrix (requires `Expokit`)
- `:base` -- use the scaling and squaring method implemented in Julia standard
library; see `?exp` for details
- `:lazy` -- return a lazy wrapper type around the matrix exponential using
the implementation `LazySets.SparseMatrixExp`
- `:pade` -- apply Pade approximant method to compute the matrix exponential
of a sparse matrix (requires `Expokit`)
### Output
Expand All @@ -48,15 +48,15 @@ If the algorithm `"lazy"` is used, evaluations of the action of the matrix
exponential are done with the `expmv` implementation from `Expokit`
(but see `LazySets#1312` for the planned generalization to other backends).
"""
function _exp(A::AbstractMatrix, δ::Float64, method::String)
function _exp(A::AbstractMatrix, δ::Float64, method::Symbol)
n = checksquare(A)
if method == "base"
if method == :base
return _exp(A * δ) # TODO use dots ? (requires MathematicalSystems#189 for IdentityMultiple)

elseif method == "lazy"
elseif method == :lazy
return _exp_lazy(A * δ)

elseif method == "pade"
elseif method == :pade
@requires Expokit
return _exp_pade(A * δ)

Expand Down Expand Up @@ -122,15 +122,15 @@ function Φ₁(A::AbstractMatrix, δ::Float64, method::String)
n = checksquare(A)
B = _Aδ_3n(A, δ, n)

if method == "base"
if method == :base
P = _exp(B)
return P[1:n, (n+1):2*n]

elseif method == "lazy"
elseif method == :lazy
P = _exp_lazy(B)
return sparse(get_columns(P, (n+1):2*n)[1:n, :])

elseif method == "pade"
elseif method == :pade
P = _exp_pade(B)
return P[1:n, (n+1):2*n]

Expand Down Expand Up @@ -185,23 +185,23 @@ It can be shown that `Φ₂(A, δ) = P[1:n, (2*n+1):3*n]`.
International Conference on Computer Aided Verification. Springer, Berlin,
Heidelberg, 2011.
"""
function Φ₂(A::AbstractMatrix, δ::Float64, method::String)
if method == "inverse"
function Φ₂(A::AbstractMatrix, δ::Float64, method::Symbol)
if method == :inverse
return _Φ₂_inverse(A, δ)
end

n = checksquare(A)
B = _Aδ_3n(A, δ, n)

if method == "base"
if method == :base
P = _exp(B)
return P[1:n, (2*n+1):3*n]

elseif method == "lazy"
elseif method == :lazy
P = _exp_lazy(B)
return sparse(get_columns(P, (2*n+1):3*n)[1:n, :])

elseif method == "pade"
elseif method == :pade
P = _exp_pade(B)
return P[1:n, (2*n+1):3*n]

Expand Down

0 comments on commit def8172

Please sign in to comment.