-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Labels
refactoring 🔧Internal code changes, typically no impact on APIInternal code changes, typically no impact on APIsimplification 👶Simplifies codeSimplifies code
Description
LazySets.jl/src/Approximations/symmetric_interval_hull.jl
Lines 27 to 34 in 0a220f7
function symmetric_interval_hull(S::LazySet{N}) where {N} | |
# fallback returns a hyperrectangular set | |
(c, r) = box_approximation_helper(S) | |
if r[1] < 0 | |
return EmptySet{N}(dim(S)) | |
end | |
return Hyperrectangle(zeros(N, length(c)), abs.(c) .+ r) | |
end |
LazySets.jl/src/Approximations/symmetric_interval_hull.jl
Lines 62 to 74 in 0a220f7
# hyperrectangle specialization | |
@inline function _maxabs(c::N, r::N) where {N} | |
return c >= zero(N) ? c + r : -c + r | |
end | |
function symmetric_interval_hull(H::Hyperrectangle{N}) where {N} | |
n = dim(H) | |
r = Vector{N}(undef, n) | |
@inbounds for i in 1:n | |
r[i] = _maxabs(H.center[i], H.radius[i]) | |
end | |
return Hyperrectangle(zeros(N, n), r) | |
end |
One of them is probably faster. Both methods should use that same code (add a new helper function with arguments c
and r
).
We should also try out yet another version with low
and high
, which may be even faster than box_approximation_helper
in general.
Metadata
Metadata
Assignees
Labels
refactoring 🔧Internal code changes, typically no impact on APIInternal code changes, typically no impact on APIsimplification 👶Simplifies codeSimplifies code