From 467481a05e42aba58581dbc1746068a7ba7f4167 Mon Sep 17 00:00:00 2001 From: mforets Date: Fri, 25 Jan 2019 16:27:45 -0300 Subject: [PATCH 1/4] add linear map of LinearMap --- docs/src/lib/operations.md | 1 + src/LinearMap.jl | 18 ++++++++++++++++++ test/unit_LinearMap.jl | 7 +++++++ 3 files changed, 26 insertions(+) diff --git a/docs/src/lib/operations.md b/docs/src/lib/operations.md index ebcaaed4d5..6805f10d6a 100644 --- a/docs/src/lib/operations.md +++ b/docs/src/lib/operations.md @@ -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} ``` Inherited from [`LazySet`](@ref): * [`norm`](@ref norm(::LazySet, ::Real)) diff --git a/src/LinearMap.jl b/src/LinearMap.jl index dfb5d4eb0d..7beec721cd 100644 --- a/src/LinearMap.jl +++ b/src/LinearMap.jl @@ -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 \ No newline at end of file diff --git a/test/unit_LinearMap.jl b/test/unit_LinearMap.jl index 647a8fc24e..c90d346bac 100644 --- a/test/unit_LinearMap.jl +++ b/test/unit_LinearMap.jl @@ -102,4 +102,11 @@ for N in [Float64, Rational{Int}, Float32] @test ρ(d, lm2) ≈ ρ(d, p2) end end + + # concrete linera map of a LinearMap + b = BallInf(N[0, 0], N(1)) + M = rand(N, 2, 2) + L = LinearMap(M, b) + V = linear_map(M, LinearMap(M, b)) + @test M * M * an_element(L) ∈ V end From 33636305238256cc2180d7f9c2ddb334c9bcf8e5 Mon Sep 17 00:00:00 2001 From: schillic Date: Fri, 25 Jan 2019 20:35:30 +0100 Subject: [PATCH 2/4] line break --- src/LinearMap.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LinearMap.jl b/src/LinearMap.jl index 7beec721cd..dd6060b9c9 100644 --- a/src/LinearMap.jl +++ b/src/LinearMap.jl @@ -393,4 +393,4 @@ 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 \ No newline at end of file +end From d5e3021196170b88770f060ff221d46a96c8d953 Mon Sep 17 00:00:00 2001 From: schillic Date: Fri, 25 Jan 2019 20:36:25 +0100 Subject: [PATCH 3/4] fix test --- test/unit_LinearMap.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit_LinearMap.jl b/test/unit_LinearMap.jl index c90d346bac..caebe8e730 100644 --- a/test/unit_LinearMap.jl +++ b/test/unit_LinearMap.jl @@ -108,5 +108,5 @@ for N in [Float64, Rational{Int}, Float32] M = rand(N, 2, 2) L = LinearMap(M, b) V = linear_map(M, LinearMap(M, b)) - @test M * M * an_element(L) ∈ V + @test M * M * an_element(b) ∈ V end From d98b3b582abe05671da3a1a32e426341522d85f3 Mon Sep 17 00:00:00 2001 From: schillic Date: Fri, 25 Jan 2019 21:43:08 +0100 Subject: [PATCH 4/4] fix test --- test/unit_LinearMap.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit_LinearMap.jl b/test/unit_LinearMap.jl index caebe8e730..fb492ee403 100644 --- a/test/unit_LinearMap.jl +++ b/test/unit_LinearMap.jl @@ -103,9 +103,9 @@ for N in [Float64, Rational{Int}, Float32] end end - # concrete linera map of a LinearMap + # concrete linear map of a LinearMap b = BallInf(N[0, 0], N(1)) - M = rand(N, 2, 2) + M = N[2 3; 1 2] L = LinearMap(M, b) V = linear_map(M, LinearMap(M, b)) @test M * M * an_element(b) ∈ V