Skip to content

Commit b7b88cc

Browse files
authored
Update distance_to_set.jl
1 parent 420cf53 commit b7b88cc

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Utilities/distance_to_set.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ function distance_to_set(
541541
# so it's the Frobenius norm.
542542
# The Frobenius norm of `A` which is Euclidean
543543
# norm of the vector of eigenvalues.
544-
return sum(LinearAlgebra.eigvals(_reshape(x, set))) do λ
545-
min(λ, zero(T))^2
546-
end
544+
eigvals = LinearAlgebra.eigvals(_reshape(x, set))
545+
return sqrt(sum(min.(zero(T), eigvals).^2))
547546
end

0 commit comments

Comments
 (0)