Skip to content

Commit 9c05b10

Browse files
committed
AbstractPolynomialZonotope: add 'linear_combination'
1 parent b07bb8e commit 9c05b10

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

docs/src/lib/interfaces/AbstractPolynomialZonotope.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Undocumented implementations:
6060
* [`isboundedtype`](@ref isboundedtype(::Type{LazySet}))
6161
* [`isempty`](@ref isempty(::LazySet))
6262
* [`isuniversal`](@ref isuniversal(::LazySet))
63+
* [`linear_combination`](@ref linear_combination(::LazySet, ::LazySet))
6364

6465
```@meta
6566
CurrentModule = LazySets

docs/src/lib/sets/DensePolynomialZonotope.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ Inherited from [`LazySet`](@ref):
7777
* [`isequivalent`](@ref isequivalent(::LazySet, ::LazySet))
7878
* [``](@ref ⊂(::LazySet, ::LazySet))
7979
* [``](@ref ⊆(::LazySet, ::LazySet))
80-
* [`linear_combination`](@ref linear_combination(::LazySet, ::LazySet))
8180
* [`minkowski_difference`](@ref minkowski_difference(::LazySet, ::LazySet))
8281
* [`minkowski_sum`](@ref minkowski_sum(::LazySet, ::LazySet))
8382

@@ -90,3 +89,4 @@ Inherited from [`AbstractPolynomialZonotope`](@ref):
9089
* [`ngens`](@ref ngens(::AbstractPolynomialZonotope))
9190
* [`order`](@ref dim(::AbstractPolynomialZonotope))
9291
* [`convex_hull`](@ref convex_hull(::AbstractPolynomialZonotope, ::AbstractPolynomialZonotope))
92+
* [`linear_combination`](@ref linear_combination(::AbstractPolynomialZonotope, ::AbstractPolynomialZonotope))

docs/src/lib/sets/SimpleSparsePolynomialZonotope.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ Inherited from [`LazySet`](@ref):
170170
* [`isequivalent`](@ref isequivalent(::LazySet, ::LazySet))
171171
* [``](@ref ⊂(::LazySet, ::LazySet))
172172
* [``](@ref ⊆(::LazySet, ::LazySet))
173-
* [`linear_combination`](@ref linear_combination(::LazySet, ::LazySet))
174173
* [`minkowski_difference`](@ref minkowski_difference(::LazySet, ::LazySet))
175174

176175
Inherited from [`AbstractPolynomialZonotope`](@ref):

docs/src/lib/sets/SparsePolynomialZonotope.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ Inherited from [`LazySet`](@ref):
140140
* [`isequivalent`](@ref isequivalent(::LazySet, ::LazySet))
141141
* [``](@ref ⊂(::LazySet, ::LazySet))
142142
* [``](@ref ⊆(::LazySet, ::LazySet))
143-
* [`linear_combination`](@ref linear_combination(::LazySet, ::LazySet))
144143
* [`minkowski_difference`](@ref minkowski_difference(::LazySet, ::LazySet))
145144

146145
Inherited from [`AbstractPolynomialZonotope`](@ref):
@@ -152,6 +151,7 @@ Inherited from [`AbstractPolynomialZonotope`](@ref):
152151
* [`ngens`](@ref ngens(::AbstractPolynomialZonotope))
153152
* [`order`](@ref order(::AbstractPolynomialZonotope))
154153
* [`convex_hull`](@ref convex_hull(::AbstractPolynomialZonotope, ::AbstractPolynomialZonotope))
154+
* [`linear_combination`](@ref linear_combination(::AbstractPolynomialZonotope, ::AbstractPolynomialZonotope))
155155

156156
Inherited from [`AbstractSparsePolynomialZonotope`](@ref):
157157
* [`ngens_dep`](@ref ngens_dep(::AbstractSparsePolynomialZonotope))

src/ConcreteOperations/linear_combination.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,10 @@ end
2929
@commutative function linear_combination(∅::EmptySet, X::ConvexSet)
3030
return _linear_combination_emptyset(∅, X)
3131
end
32+
33+
function linear_combination(P1::AbstractPolynomialZonotope,
34+
P2::AbstractPolynomialZonotope)
35+
SSPZ1 = convert(SimpleSparsePolynomialZonotope, P1)
36+
SSPZ2 = convert(SimpleSparsePolynomialZonotope, P2)
37+
return linear_combination(SSPZ1, SSPZ2)
38+
end

test/Sets/SparsePolynomialZonotope.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,18 @@ for N in [Float64, Float32, Rational{Int}]
141141
@test isequivalent(overapproximate(PZ, Zonotope), Z)
142142
SSPZ2 = convert(SimpleSparsePolynomialZonotope, PZ)
143143
@test isequivalent(overapproximate(SSPZ2, Zonotope, dom2), Z)
144+
145+
# Example 3.1.29 from thesis
146+
PZ1 = SparsePolynomialZonotope(N[-5, 0], N[2 0 2; 0 2 2], Matrix{N}(undef, 2, 0), [1 0 1; 0 1 1])
147+
PZ2 = SparsePolynomialZonotope(N[3, 3], N[1 -2 2; 2 3 1], hcat(N[1//2; 0]), [1 0 2; 0 1 1])
148+
PZ_lc = linear_combination(PZ1, PZ2)
149+
# no reasonable tests available here
150+
@test PZ_lc isa SimpleSparsePolynomialZonotope{N}
151+
@test center(PZ_lc) == N[-1, 3//2]
152+
PZ_ch = convex_hull(PZ1, PZ2)
153+
# no reasonable tests available here
154+
@test PZ_ch isa SimpleSparsePolynomialZonotope{N}
155+
@test center(PZ_ch) == N[-1, 3//2]
144156
end
145157

146158
for N in [Float64]

0 commit comments

Comments
 (0)