Skip to content

Commit a48a70e

Browse files
committed
fix 'vertices_list' of zonotopes with immutable center vector
1 parent 34137ac commit a48a70e

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/Interfaces/AbstractZonotope.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,10 @@ function _vertices_list_zonotope_2D_positive(c::AbstractVector{N}, G::AbstractMa
429429
return vlist
430430
end
431431

432-
function _vertices_list_zonotope_iterative(c::VN, G::AbstractMatrix{N};
433-
apply_convex_hull::Bool) where {N,VN<:AbstractVector{N}}
432+
function _vertices_list_zonotope_iterative(c::AbstractVector{N}, G::AbstractMatrix{N};
433+
apply_convex_hull::Bool) where {N}
434434
p = size(G, 2)
435+
VN = vector_type(typeof(c))
435436
vlist = Vector{VN}()
436437
sizehint!(vlist, 2^p)
437438

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

445446
# special case 2D zonotope of order 1/2
446-
function _vertices_list_zonotope_2D_order_one_half(c::VN, G::AbstractMatrix{N};
447-
apply_convex_hull::Bool) where {N,
448-
VN<:AbstractVector{N}}
447+
function _vertices_list_zonotope_2D_order_one_half(c::AbstractVector{N}, G::AbstractMatrix{N};
448+
apply_convex_hull::Bool) where {N}
449+
VN = vector_type(typeof(c))
449450
vlist = Vector{VN}(undef, 2)
450451
g = view(G, :, 1)
451452
@inbounds begin
@@ -456,9 +457,9 @@ function _vertices_list_zonotope_2D_order_one_half(c::VN, G::AbstractMatrix{N};
456457
end
457458

458459
# special case 2D zonotope of order 1
459-
function _vertices_list_zonotope_2D_order_one(c::VN, G::AbstractMatrix{N};
460-
apply_convex_hull::Bool) where {N,
461-
VN<:AbstractVector{N}}
460+
function _vertices_list_zonotope_2D_order_one(c::AbstractVector{N}, G::AbstractMatrix{N};
461+
apply_convex_hull::Bool) where {N}
462+
VN = vector_type(typeof(c))
462463
vlist = Vector{VN}(undef, 4)
463464
a = [one(N), one(N)]
464465
b = [one(N), -one(N)]

test/Sets/Zonotope.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,11 @@ for N in [Float64]
376376
vlistZ = vertices_list(Z)
377377
@test length(vlistZ) == 6
378378

379+
# test vertices_list with SubArray
380+
Z = Zonotope(view(center(Z), 1:2), genmat(Z))
381+
vlistZ = vertices_list(Z)
382+
@test length(vlistZ) == 6
383+
379384
# option to not apply the convex hull operation
380385
vlistZ = LazySets._vertices_list_zonotope_iterative(Z.center, Z.generators;
381386
apply_convex_hull=false)

0 commit comments

Comments
 (0)