Skip to content

Commit 420cf53

Browse files
committed
simpler explanation
1 parent 0799b12 commit 420cf53

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/Utilities/distance_to_set.jl

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -531,19 +531,16 @@ function distance_to_set(
531531
},
532532
) where {T<:Real}
533533
_check_dimension(x, set)
534-
# Let
535-
# 1) `U` be the matrix of eigenvectors.
536-
# 2) `λ_negative = LinearAlgebra.Diagonal(min.(zero(T), λ))`
537-
# 3) `A = LinearAlgebra.Symmetric(U * λ_negative * U')`
538-
# The upper bound distance is the Frobenius norm of `A` which is the square
539-
# root of the sum of the squares of the negative eigenvalues.
540-
# Indeed:
541-
# `⟨U * λ_negative * U', U * λ_negative * U'⟩`
542-
# which is equal to
543-
# `⟨λ_negative * U' * U, U' * U * λ_negative⟩`
544-
# Since `U'U = I` this is equal to
545-
# `⟨λ_negative, λ_negative⟩`
546-
# So we need the return:
534+
# We should return the norm of `A` defined by:
535+
# ```julia
536+
# λ, U = LinearAlgebra.eigvals(_reshape(x, set))
537+
# λ_negative = LinearAlgebra.Diagonal(min.(zero(T), λ))
538+
# A = LinearAlgebra.Symmetric(U * λ_negative * U')
539+
# ```
540+
# The norm should correspond to `MOI.Utilities.set_dot`
541+
# so it's the Frobenius norm.
542+
# The Frobenius norm of `A` which is Euclidean
543+
# norm of the vector of eigenvalues.
547544
return sum(LinearAlgebra.eigvals(_reshape(x, set))) do λ
548545
min(λ, zero(T))^2
549546
end

0 commit comments

Comments
 (0)