Skip to content

Commit

Permalink
Merge pull request #1071 from JuliaReach/mforets/1068
Browse files Browse the repository at this point in the history
#1068 - linear map of a LinearMap
  • Loading branch information
mforets authored Jan 25, 2019
2 parents efe33e5 + c39f096 commit 8f09755
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/src/lib/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ isbounded(::LinearMap)
isempty(::LinearMap)
vertices_list(::LinearMap{N}) where {N<:Real}
constraints_list(::LinearMap{N}) where {N<:Real}
linear_map(::AbstractMatrix{N}, ::LinearMap{N}) where {N}
intersection(::LinearMap{N}, ::LazySet{N}) where {N}
```
Inherited from [`LazySet`](@ref):
Expand Down
18 changes: 18 additions & 0 deletions src/LinearMap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,21 @@ We fall back to a concrete set representation and apply `linear_map`.
function constraints_list(lm::LinearMap{N}) where {N<:Real}
return constraints_list(linear_map(lm.M, lm.X))
end

"""
linear_map(M::AbstractMatrix{N}, lm::LinearMap{N}) where {N}
Return the linear map of a lazy linear map.
### Input
- `M` -- matrix
- `lm` -- linear map
### Output
The polytope representing the linear map of the lazy linear map of a set.
"""
function linear_map(M::AbstractMatrix{N}, lm::LinearMap{N}) where {N}
return linear_map(M * lm.M, lm.X)
end
7 changes: 7 additions & 0 deletions test/unit_LinearMap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ for N in [Float64, Rational{Int}, Float32]
@test ρ(d, lm2) ρ(d, p2)
end
end

# concrete linear map of a LinearMap
b = BallInf(N[0, 0], N(1))
M = N[2 3; 1 2]
L = LinearMap(M, b)
V = linear_map(M, LinearMap(M, b))
@test M * M * an_element(b) V
end

# tests that only work with Float64
Expand Down

0 comments on commit 8f09755

Please sign in to comment.