Skip to content

Commit

Permalink
use fastmath
Browse files Browse the repository at this point in the history
  • Loading branch information
Moelf committed Sep 5, 2021
1 parent 692d567 commit 6b286d8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,14 @@ function _hypot(x, y)
end
return h*scale*oneunit(axu)
end
_hypot(x::Float32, y::Float32) = Float32(sqrt((Float64(x)^2 + Float64(y)^2)))
_hypot(x::Float16, y::Float16) = Float16(sqrt((Float32(x)^2 + Float32(y)^2)))
@inline function _hypot(x::Float32, y::Float32)
_x, _y = Float64(x), Float64(y)
return Float32(sqrt(@fastmath _x*_x + _y*_y))
end
@inline function _hypot(x::Float16, y::Float16)
_x, _y = Float32(x), Float32(y)
return Float16(sqrt(@fastmath _x*_x + _y*_y))
end
_hypot(x::ComplexF16, y::ComplexF16) = Float16(_hypot(ComplexF32(x), ComplexF32(y)))

function _hypot(x...)
Expand Down

0 comments on commit 6b286d8

Please sign in to comment.