From a682c6702a54197a1323b4f07942bd1c45154c04 Mon Sep 17 00:00:00 2001 From: schillic Date: Sat, 4 May 2024 12:38:27 +0200 Subject: [PATCH] outsource SingleEntryVector code to ReachabilityBase --- src/Flowpipes/arrayops.jl | 68 ------------------------------------- src/ReachabilityAnalysis.jl | 1 - 2 files changed, 69 deletions(-) delete mode 100644 src/Flowpipes/arrayops.jl diff --git a/src/Flowpipes/arrayops.jl b/src/Flowpipes/arrayops.jl deleted file mode 100644 index e66661e52..000000000 --- a/src/Flowpipes/arrayops.jl +++ /dev/null @@ -1,68 +0,0 @@ -# ======================================================================== -# Specialized functions on SingleEntryVector -# TODO refactor to LazySets.jl -# ======================================================================== - -# difference between single entry vectors (SEV); it is type unstable because -# it may return either a SEV or a regular Vector depending on the indices -# but it is much faster than the fallback if the indices match -function minus(e1::SingleEntryVector{N}, e2::SingleEntryVector{N}) where {N} - e1.n == e2.n || - throw(DimensionMismatch("dimensions must match, but they are $(length(e1)) and $(length(e2)) respectively")) - - if e1.i == e2.i - return SingleEntryVector(e1.i, e1.n, e1.v - e2.v) - else - out = zeros(N, e1.n) - @inbounds begin - out[e1.i] = e1.v - out[e2.i] = -e2.v - end - return out - end -end - -# addition between single entry vectors (SEV); it is type unstable because -# it may return either a SEV or a regular Vector depending on the indices -# but it is much faster than the fallback if the indices match -function plus(e1::SingleEntryVector{N}, e2::SingleEntryVector{N}) where {N} - e1.n == e2.n || - throw(DimensionMismatch("dimensions must match, but they are $(length(e1)) and $(length(e2)) respectively")) - - if e1.i == e2.i - return SingleEntryVector(e1.i, e1.n, e1.v + e2.v) - else - out = zeros(N, e1.n) - @inbounds begin - out[e1.i] = e1.v - out[e2.i] = e2.v - end - return out - end -end - -# norm of the difference of two SEV ||x - y|| in the (vector p norm) -function normdiff(e1::SingleEntryVector{N}, e2::SingleEntryVector{N}, p::Real=2) where {N} - e1.n == e2.n || - throw(DimensionMismatch("dimensions must match, but they are $(length(e1)) and $(length(e2)) respectively")) - - if e1.i == e2.i - δ = e1.v - e2.v - return abs(δ) - - else - a = abs(e1.v) - b = abs(e2.v) - if isinf(p) - return max(a, b) - else - s = a^p + b^p - return s^(1 / p) - end - end -end - -# fallback -function normdiff(x::AbstractVector{N}, y::AbstractVector{N}, p::Real=2) where {N} - return norm(x - y, p) -end diff --git a/src/ReachabilityAnalysis.jl b/src/ReachabilityAnalysis.jl index 68738c4c1..32020eb04 100644 --- a/src/ReachabilityAnalysis.jl +++ b/src/ReachabilityAnalysis.jl @@ -19,7 +19,6 @@ include("Discretization/discretization.jl") include("Flowpipes/setops.jl") include("ReachSets/reachsets.jl") include("Flowpipes/flowpipes.jl") -include("Flowpipes/arrayops.jl") include("Flowpipes/clustering.jl") include("Flowpipes/solutions.jl")