Skip to content

Commit

Permalink
getter function for the generator of a Zonotope
Browse files Browse the repository at this point in the history
Update Zonotope.jl

Update Zonotope.jl

Update representations.md

Update unit_Zonotope.jl
  • Loading branch information
aa25desh committed May 1, 2019
1 parent 8230c8c commit 5013aee
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/src/lib/representations.md
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ constraints_list(::Zonotope{N}) where {N<:Real}
constraints_list(::Zonotope{N}) where {N<:AbstractFloat}
center(::Zonotope{N}) where {N<:Real}
order(::Zonotope)
generators(Z::Zonotope)
minkowski_sum(::Zonotope{N}, ::Zonotope{N}) where {N<:Real}
linear_map(::AbstractMatrix{N}, ::Zonotope{N}) where {N<:Real}
translate(::Zonotope{N}, ::AbstractVector{N}) where {N<:Real}
Expand Down
19 changes: 18 additions & 1 deletion src/Zonotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export Zonotope,
scale,
ngens,
reduce_order,
constraints_list
constraints_list,
generators

"""
Zonotope{N<:Real} <: AbstractCentrallySymmetricPolytope{N}
Expand Down Expand Up @@ -129,6 +130,22 @@ function center(Z::Zonotope{N})::Vector{N} where {N<:Real}
return Z.center
end

"""
generators(Z::Zonotope)
Return the generators of a zonotope.
### Input
- `Z` -- zonotope
### Output
The generators of the zonotope.
"""
function generators(Z::Zonotope)
return Z.generators
end

# --- AbstractPolytope interface functions ---

Expand Down
1 change: 1 addition & 0 deletions test/unit_Zonotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ for N in [Float64, Rational{Int}, Float32]
# test number of generators
Z = Zonotope(N[2, 1], N[-0.5 1.5 0.5 1; 0.5 1.5 1 0.5])
@test ngens(Z) == 4
@test generators(Z) == Z.generators
# test order reduction
Zred1 = reduce_order(Z, 1)
@test ngens(Zred1) == 2
Expand Down

0 comments on commit 5013aee

Please sign in to comment.