Skip to content

Commit

Permalink
add mixed zono/polyzono 'linear_combination'
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Jan 5, 2025
1 parent 3d8a80f commit 84965b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ConcreteOperations/linear_combination.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ function linear_combination(P1::AbstractPolynomialZonotope,
SSPZ2 = convert(SimpleSparsePolynomialZonotope, P2)
return linear_combination(SSPZ1, SSPZ2)
end

@commutative function linear_combination(Z::AbstractZonotope, P::AbstractPolynomialZonotope)
return linear_combination(convert(SparsePolynomialZonotope, Z), P)
end
3 changes: 3 additions & 0 deletions test/Sets/SparsePolynomialZonotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ for N in [Float64, Float32, Rational{Int}]
# no reasonable tests available here
@test PZ_ch isa SimpleSparsePolynomialZonotope{N}
@test center(PZ_ch) == N[-1, 3//2]
# mixed linear_combination
PZ_lc = linear_combination(PZ1, ZeroSet{N}(2))
@test PZ_lc isa SimpleSparsePolynomialZonotope{N}
end

for N in [Float64]
Expand Down

0 comments on commit 84965b8

Please sign in to comment.