From b4aaf2dec0946fd131f71f7fe0780866f385f7b2 Mon Sep 17 00:00:00 2001 From: schillic Date: Tue, 13 Mar 2018 15:14:03 +0100 Subject: [PATCH 1/3] fix slowdown in LinearMap's support vector --- src/LinearMap.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LinearMap.jl b/src/LinearMap.jl index ecaad61b7c..86da9f10e1 100644 --- a/src/LinearMap.jl +++ b/src/LinearMap.jl @@ -150,7 +150,7 @@ If the direction has norm zero, the result depends on the wrapped set. If ``L = M⋅S``, where ``M`` is a matrix and ``S`` is a convex set, it follows that ``σ(d, L) = M⋅σ(M^T d, S)`` for any direction ``d``. """ -function σ(d::AbstractVector{<:Real}, lm::LinearMap)::AbstractVector{<:Real} +function σ(d::V, lm::LinearMap)::V where {N<:Real, V<:AbstractVector{N}} return lm.M * σ(lm.M.' * d, lm.X) end From 5257b46273bd7f392f2e074ddd150b2eb89fd868 Mon Sep 17 00:00:00 2001 From: schillic Date: Tue, 13 Mar 2018 15:27:03 +0100 Subject: [PATCH 2/3] fix unit test --- test/unit_interfaces.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit_interfaces.jl b/test/unit_interfaces.jl index 986aec8f9e..59258c328f 100644 --- a/test/unit_interfaces.jl +++ b/test/unit_interfaces.jl @@ -4,7 +4,7 @@ # support vector @test check_method_implementation(LazySet, σ, - Function[S -> (AbstractVector{Float64}, S)]) + Function[S -> (Vector{Float64}, S)]) # dimension @test check_method_implementation(LazySet, dim, Function[S -> (S,)]) From f395d766d092a6b736e360950bd966b8738fe13c Mon Sep 17 00:00:00 2001 From: schillic Date: Tue, 13 Mar 2018 15:36:27 +0100 Subject: [PATCH 3/3] added benchmark unit test --- test/unit_overapproximate.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unit_overapproximate.jl b/test/unit_overapproximate.jl index 172eb354a6..7b269fe12b 100644 --- a/test/unit_overapproximate.jl +++ b/test/unit_overapproximate.jl @@ -96,3 +96,13 @@ for N in [Float64, Float32] # TODO Rational{Int} @test σ(d, p)[1] ≈ σ(d, b)[1] end end + +# useful for benchmarking overapproximate and LinearMap's support vector +# (see #290) +function overapproximate_lmap(n) + B = BallInf(ones(n), 2.) + π = sparse([1, 2], [1, 2], ones(2), 2, n) + return Approximations.overapproximate(π*B) +end +o = overapproximate_lmap(50) +@test o.center == [1., 1] && o.radius == [2., 2]