Skip to content

Commit c4cb4b6

Browse files
authored
Update distance_to_set.jl
1 parent 109ab3d commit c4cb4b6

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Utilities/distance_to_set.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -533,15 +533,14 @@ function distance_to_set(
533533
_check_dimension(x, set)
534534
# We should return the norm of `A` defined by:
535535
# ```julia
536-
# λ, U = LinearAlgebra.eigvals(_reshape(x, set))
536+
# λ, U = LinearAlgebra.eigen(_reshape(x, set))
537537
# λ_negative = LinearAlgebra.Diagonal(min.(zero(T), λ))
538538
# A = LinearAlgebra.Symmetric(U * λ_negative * U')
539+
# LinearAlgebra.norm(A, 2)
539540
# ```
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.
541+
# The norm should correspond to `MOI.Utilities.set_dot` so it's the
542+
# Frobenius norm, which is the Euclidean norm of the vector of eigenvalues.
544543
eigvals = LinearAlgebra.eigvals(_reshape(x, set))
545-
neg_eigvals = min.(zero(T), eigvals)
546-
return LinearAlgebra.norm(neg_eigvals, 2)
544+
eigvals .= min.(zero(T), eigvals)
545+
return LinearAlgebra.norm(eigvals, 2)
547546
end

0 commit comments

Comments
 (0)