From 5013aeeb8ddc90276c9f6eb8177d377954502e97 Mon Sep 17 00:00:00 2001 From: Aadesha Date: Mon, 29 Apr 2019 22:31:26 +0530 Subject: [PATCH] getter function for the generator of a Zonotope Update Zonotope.jl Update Zonotope.jl Update representations.md Update unit_Zonotope.jl --- docs/src/lib/representations.md | 1 + src/Zonotope.jl | 19 ++++++++++++++++++- test/unit_Zonotope.jl | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/src/lib/representations.md b/docs/src/lib/representations.md index be65d7807d..787c45c1b3 100644 --- a/docs/src/lib/representations.md +++ b/docs/src/lib/representations.md @@ -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} diff --git a/src/Zonotope.jl b/src/Zonotope.jl index 2085f31824..4590adf224 100644 --- a/src/Zonotope.jl +++ b/src/Zonotope.jl @@ -9,7 +9,8 @@ export Zonotope, scale, ngens, reduce_order, - constraints_list + constraints_list, + generators """ Zonotope{N<:Real} <: AbstractCentrallySymmetricPolytope{N} @@ -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 --- diff --git a/test/unit_Zonotope.jl b/test/unit_Zonotope.jl index c88db5912c..c782af13fb 100644 --- a/test/unit_Zonotope.jl +++ b/test/unit_Zonotope.jl @@ -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