Skip to content

Commit 3042236

Browse files
authored
Merge pull request #1156 from JuliaReach/mforets/promote_linear_map
Use promotion for linear map of polyhedra
2 parents 589f9d4 + d88ef8c commit 3042236

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/AbstractPolyhedron_functions.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,18 @@ function linear_map(M::AbstractMatrix{N},
318318
end
319319
end
320320

321+
# handle different numeric types
322+
function linear_map(M::AbstractMatrix{NM},
323+
P::AbstractPolyhedron{NP};
324+
kwargs...) where {NM<:Real, NP<:Real}
325+
N = promote_type(NM, NP)
326+
if N != NP
327+
error("conversion between numeric types of polyhedra not implemented yet (see #1181)")
328+
else
329+
return linear_map(N.(M), P; kwargs...)
330+
end
331+
end
332+
321333
function _linear_map_vrep(M::AbstractMatrix{N}, P::AbstractPolyhedron{N}) where {N<:Real}
322334
if !isbounded(P)
323335
throw(ArgumentError("the linear map in vertex representation for an unbounded set is not defined"))

src/HPolytope.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ HPolytope{N}(A::AbstractMatrix{N}, b::AbstractVector{N};
5555
check_boundedness::Bool=false) where {N<:Real} =
5656
HPolytope(A, b; check_boundedness=check_boundedness)
5757

58-
5958
# --- LazySet interface functions ---
6059

6160

test/unit_Polytope.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ for N in [Float64, Rational{Int}, Float32]
135135
L4 = linear_map(M, P, check_invertibility=false)
136136
@test L4 isa VPolygon
137137

138+
# linear map for mixed types
139+
M = [2 1; 0 1] # Int's
140+
LM = linear_map(M, P)
141+
@test LM isa HPolytope{N}
142+
138143
# -----
139144
# V-rep
140145
# -----

0 commit comments

Comments
 (0)