Skip to content

Commit

Permalink
finish linear_map of Hyperplane
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Jul 24, 2024
1 parent fb3b8da commit 309f53d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Sets/Hyperplane/init_LazySets.jl
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
using .LazySets.HalfSpaceModule: HalfSpace
using .LazySets.HPolyhedronModule: HPolyhedron
using .LazySets.UniverseModule: Universe
4 changes: 3 additions & 1 deletion src/Sets/Hyperplane/linear_map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ function _linear_map_hrep_helper(M::AbstractMatrix{N}, P::Hyperplane{N},

return Universe{N}(size(M, 1))
else
error("unexpected number of $(length(constraints)) constraints")
require(@__MODULE__, :LazySets; fun_name="linear_map")

return HPolyhedron(constraints)
end
end
15 changes: 13 additions & 2 deletions test/Sets/Hyperplane.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,19 @@ for N in [Float64, Rational{Int}, Float32]
@test lm.a == N[0 // 1, -1 // 1] && lm.b == N(0 // 1)
end
end
M = zeros(N, 2, 2) # result is a singleton
@test_broken linear_map(M, H)
# regular linear map
M = N[2 0; 0 4]
P = linear_map(M, H)
@test P == Hyperplane(N[1//2, -1//4], N(0))
# result is a singleton (but represented as a polyhedron)
M = zeros(N, 2, 2)
P = linear_map(M, H)
@test P isa HPolyhedron && isequivalent(P, ZeroSet{N}(2))
# non-origin singleton
H = Hyperplane(N[1, 0], N(1))
M = N[1 0; 0 0]
P = linear_map(M, H)
@test P isa HPolyhedron && isequivalent(P, Singleton(N[1, 0]))

# projection
H = Hyperplane(N[1, -1], N(0)) # x = y
Expand Down

0 comments on commit 309f53d

Please sign in to comment.