Skip to content

Fix vertices_list of zonotopes with immutable center vector #3823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/Interfaces/AbstractZonotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,10 @@ function _vertices_list_zonotope_2D_positive(c::AbstractVector{N}, G::AbstractMa
return vlist
end

function _vertices_list_zonotope_iterative(c::VN, G::AbstractMatrix{N};
apply_convex_hull::Bool) where {N,VN<:AbstractVector{N}}
function _vertices_list_zonotope_iterative(c::AbstractVector{N}, G::AbstractMatrix{N};
apply_convex_hull::Bool) where {N}
p = size(G, 2)
VN = vector_type(typeof(c))
vlist = Vector{VN}()
sizehint!(vlist, 2^p)

Expand All @@ -443,9 +444,9 @@ function _vertices_list_zonotope_iterative(c::VN, G::AbstractMatrix{N};
end

# special case 2D zonotope of order 1/2
function _vertices_list_zonotope_2D_order_one_half(c::VN, G::AbstractMatrix{N};
apply_convex_hull::Bool) where {N,
VN<:AbstractVector{N}}
function _vertices_list_zonotope_2D_order_one_half(c::AbstractVector{N}, G::AbstractMatrix{N};
apply_convex_hull::Bool) where {N}
VN = vector_type(typeof(c))
vlist = Vector{VN}(undef, 2)
g = view(G, :, 1)
@inbounds begin
Expand All @@ -456,9 +457,9 @@ function _vertices_list_zonotope_2D_order_one_half(c::VN, G::AbstractMatrix{N};
end

# special case 2D zonotope of order 1
function _vertices_list_zonotope_2D_order_one(c::VN, G::AbstractMatrix{N};
apply_convex_hull::Bool) where {N,
VN<:AbstractVector{N}}
function _vertices_list_zonotope_2D_order_one(c::AbstractVector{N}, G::AbstractMatrix{N};
apply_convex_hull::Bool) where {N}
VN = vector_type(typeof(c))
vlist = Vector{VN}(undef, 4)
a = [one(N), one(N)]
b = [one(N), -one(N)]
Expand Down
5 changes: 5 additions & 0 deletions test/Sets/Zonotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,11 @@ for N in [Float64]
vlistZ = vertices_list(Z)
@test length(vlistZ) == 6

# test vertices_list with SubArray
Z = Zonotope(view(center(Z), 1:2), genmat(Z))
vlistZ = vertices_list(Z)
@test length(vlistZ) == 6

# option to not apply the convex hull operation
vlistZ = LazySets._vertices_list_zonotope_iterative(Z.center, Z.generators;
apply_convex_hull=false)
Expand Down
Loading