From 388662866b0d1bf03135424e58607898683e89eb Mon Sep 17 00:00:00 2001 From: schillic Date: Fri, 7 Apr 2023 22:18:48 +0200 Subject: [PATCH] faster brute-force search support vector VPolygon --- src/Sets/VPolygon.jl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Sets/VPolygon.jl b/src/Sets/VPolygon.jl index 9be1496027..b6978c3a8f 100644 --- a/src/Sets/VPolygon.jl +++ b/src/Sets/VPolygon.jl @@ -327,14 +327,16 @@ function _brute_force_support_vector(d::AbstractVector, P::VPolygon) end function _brute_force_support_vector(d::AbstractVector{M}, vlist::Vector{VT}) where {M, T, VT<:AbstractVector{T}} - i_max = 1 - N = promote_type(M, T) + max_idx = 1 + @inbounds max_ρ = dot(d, vlist[1]) @inbounds for i in 2:length(vlist) - if dot(d, vlist[i] - vlist[i_max]) > zero(N) - i_max = i + ρ_i = dot(d, vlist[i]) + if ρ_i > max_ρ + max_idx = i + max_ρ = ρ_i end end - return i_max + return max_idx end function _binary_support_vector(d::AbstractVector, P::VPolygon)