Skip to content

AbstractAffineMap: add isuniversal method #3744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/src/lib/interfaces/AbstractAffineMap.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ isempty(::AbstractAffineMap)
CurrentModule = LazySets.API
```
```@docs; canonical=false
isuniversal(::LazySet)
```
```@meta
CurrentModule = LazySets
```
```@docs
isuniversal(::AbstractAffineMap)
```
```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
∈(::AbstractVector, ::LazySet)
```
```@meta
Expand Down
22 changes: 22 additions & 0 deletions src/Interfaces/AbstractAffineMap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,28 @@ function constraints_list(am::AbstractAffineMap)
vector(am))
end

"""
# Extended help

isuniversal(am::AbstractAffineMap)

### Algorithm

An affine map is universal iff the wrapped set is universal and the matrix does
not map any dimension to zero.
"""
function isuniversal(am::AbstractAffineMap)
if isuniversal(set(am))
for row in eachrow(matrix(am))
if all(isapproxzero, row)
return false
end
end
return true
end
return false
end

function linear_map(M::AbstractMatrix, am::AbstractAffineMap)
return affine_map(M * matrix(am), set(am), M * vector(am))
end
8 changes: 8 additions & 0 deletions test/LazyOperations/AffineMap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ for N in [Float64, Rational{Int}, Float32]
@test !isempty(am)
@test isempty(AffineMap(M, EmptySet{N}(2), v))

# isuniversal
@test !isuniversal(am)
U = Universe{N}(3)
M = N[1 0 0; 0 0 0; 0 0 1]
@test !isuniversal(M * U + v)
M = N[1 2 3; -1 -2 -3; 0 0 1]
@test isuniversal(M * U + v)

# containment
L = LineSegment(N[1, 0], N[2, 0])
b2 = N[1, 0]
Expand Down
Loading