Skip to content

Commit 1d7395d

Browse files
committed
AbstractAffineMap: add 'isuniversal' method
1 parent e93bb75 commit 1d7395d

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

docs/src/lib/interfaces/AbstractAffineMap.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ isempty(::AbstractAffineMap)
8989
CurrentModule = LazySets.API
9090
```
9191
```@docs; canonical=false
92+
isuniversal(::LazySet)
93+
```
94+
```@meta
95+
CurrentModule = LazySets
96+
```
97+
```@docs
98+
isuniversal(::AbstractAffineMap)
99+
```
100+
```@meta
101+
CurrentModule = LazySets.API
102+
```
103+
```@docs; canonical=false
92104
∈(::AbstractVector, ::LazySet)
93105
```
94106
```@meta

src/Interfaces/AbstractAffineMap.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,28 @@ function constraints_list(am::AbstractAffineMap)
267267
vector(am))
268268
end
269269

270+
"""
271+
# Extended help
272+
273+
isuniversal(am::AbstractAffineMap)
274+
275+
### Algorithm
276+
277+
An affine map is universal iff the wrapped set is universal and the matrix does
278+
not map any dimension to zero.
279+
"""
280+
function isuniversal(am::AbstractAffineMap)
281+
if isuniversal(set(am))
282+
for row in eachrow(matrix(am))
283+
if all(isapproxzero, row)
284+
return false
285+
end
286+
end
287+
return true
288+
end
289+
return false
290+
end
291+
270292
function linear_map(M::AbstractMatrix, am::AbstractAffineMap)
271293
return affine_map(M * matrix(am), set(am), M * vector(am))
272294
end

test/LazyOperations/AffineMap.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ for N in [Float64, Rational{Int}, Float32]
5353
@test !isempty(am)
5454
@test isempty(AffineMap(M, EmptySet{N}(2), v))
5555

56+
# isuniversal
57+
@test !isuniversal(am)
58+
U = Universe{N}(3)
59+
M = N[1 0 0; 0 0 0; 0 0 1]
60+
@test !isuniversal(M * U + v)
61+
M = N[1 2 3; -1 -2 -3; 0 0 1]
62+
@test isuniversal(M * U + v)
63+
5664
# containment
5765
L = LineSegment(N[1, 0], N[2, 0])
5866
b2 = N[1, 0]

0 commit comments

Comments
 (0)