Skip to content

Commit 58b451f

Browse files
committed
fix 'vertices_list' of zonotopes with immutable center vector
1 parent 569e12a commit 58b451f

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/Interfaces/AbstractZonotope.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,10 @@ function _vertices_list_zonotope_2D_positive(c::AbstractVector{N}, G::AbstractMa
426426
return vlist
427427
end
428428

429-
function _vertices_list_zonotope_iterative(c::VN, G::AbstractMatrix{N};
430-
apply_convex_hull::Bool) where {N,VN<:AbstractVector{N}}
429+
function _vertices_list_zonotope_iterative(c::AbstractVector{N}, G::AbstractMatrix{N};
430+
apply_convex_hull::Bool) where {N}
431431
p = size(G, 2)
432+
VN = vector_type(typeof(c))
432433
vlist = Vector{VN}()
433434
sizehint!(vlist, 2^p)
434435

@@ -440,9 +441,9 @@ function _vertices_list_zonotope_iterative(c::VN, G::AbstractMatrix{N};
440441
end
441442

442443
# special case 2D zonotope of order 1/2
443-
function _vertices_list_zonotope_2D_order_one_half(c::VN, G::AbstractMatrix{N};
444-
apply_convex_hull::Bool) where {N,
445-
VN<:AbstractVector{N}}
444+
function _vertices_list_zonotope_2D_order_one_half(c::AbstractVector{N}, G::AbstractMatrix{N};
445+
apply_convex_hull::Bool) where {N}
446+
VN = vector_type(typeof(c))
446447
vlist = Vector{VN}(undef, 2)
447448
g = view(G, :, 1)
448449
@inbounds begin
@@ -453,9 +454,9 @@ function _vertices_list_zonotope_2D_order_one_half(c::VN, G::AbstractMatrix{N};
453454
end
454455

455456
# special case 2D zonotope of order 1
456-
function _vertices_list_zonotope_2D_order_one(c::VN, G::AbstractMatrix{N};
457-
apply_convex_hull::Bool) where {N,
458-
VN<:AbstractVector{N}}
457+
function _vertices_list_zonotope_2D_order_one(c::AbstractVector{N}, G::AbstractMatrix{N};
458+
apply_convex_hull::Bool) where {N}
459+
VN = vector_type(typeof(c))
459460
vlist = Vector{VN}(undef, 4)
460461
a = [one(N), one(N)]
461462
b = [one(N), -one(N)]

test/Sets/Zonotope.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,10 @@ for N in @tN([Float64, Float32, Rational{Int}])
407407
[N[2, 3, 4], N[2, 3, -2], N[2, -1, 4], N[2, -1, -2],
408408
N[0, 3, 4], N[0, 3, -2], N[0, -1, 4], N[0, -1, -2]])
409409
end
410+
# SubArray
411+
Z2 = Zonotope(view(c, 1:2), genmat(Z))
412+
vlistZ = vertices_list(Z2)
413+
@test vlistZ == vertices_list(Z)
410414

411415
# vertices
412416
res = collect(vertices(Z))

0 commit comments

Comments
 (0)