Skip to content

Commit

Permalink
Compare to absolute eps instead of relative eps
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Jun 14, 2024
1 parent ecbd858 commit f3c06a8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/OptimKit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ function safe_sqrt(x::Real)
return if x >= 0
sqrt(x)
else
-x < eps(x)^(3 / 4) || @error "sqrt of negative number: $x"
eps(x)
ϵ = eps(typeof(x))
-x < ϵ^(3 / 4) || @error "sqrt of negative number: $x"
ϵ
end
end

Expand Down

0 comments on commit f3c06a8

Please sign in to comment.