Skip to content

Commit

Permalink
Merge pull request #3130 from JuliaReach/schillic/exact_sum
Browse files Browse the repository at this point in the history
Revise exact_sum code
  • Loading branch information
schillic authored Oct 17, 2022
2 parents 28d4501 + b558012 commit f4e5a5f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/src/lib/binary_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ convex_hull(::SimpleSparsePolynomialZonotope, ::SimpleSparsePolynomialZonotope)
## Exact sum

```@docs
exact_sum(::SparsePolynomialZonotope, ::SparsePolynomialZonotope)
```

Expand Down
16 changes: 13 additions & 3 deletions src/ConcreteOperations/exact_sum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ Compute the exact sum of sparse polyomial zonotopes ``P₁`` and ``P₂``.
### Output
exact sum ``P₁ ⊞ P₂``
A `SparsePolynomialZonotope` representing the exact sum ``P₁ ⊞ P₂``.
"""
function exact_sum(P1::SparsePolynomialZonotope, P2::SparsePolynomialZonotope)

indexvector(P1) == indexvector(P2) || throw(ArgumentError("Exact sum currently only implemented for Sparse Polynomial Zonotopes with the same index vector"))
indexvector(P1) == indexvector(P2) || throw(ArgumentError("the exact sum " *
"is currently only implemented for sparse polynomial zonotopes with " *
"the same index vector"))

c = center(P1) + center(P2)
G = hcat(genmat_dep(P1), genmat_dep(P2))
Expand All @@ -28,4 +29,13 @@ function exact_sum(P1::SparsePolynomialZonotope, P2::SparsePolynomialZonotope)
return SparsePolynomialZonotope(c, G, GI, E, idx)
end

"""
⊞(X::LazySet, Y::LazySet)
Unicode alias constructor ⊕ (`oplus`) for the (concrete) `exact_sum` function.
### Notes
Write `\\boxplus[TAB]` to enter this symbol.
"""
const = exact_sum

0 comments on commit f4e5a5f

Please sign in to comment.