From 5f57c6666af3165c5d57c88b60498424eff8e063 Mon Sep 17 00:00:00 2001 From: Jorge Fernandez-de-Cossio-Diaz Date: Thu, 3 Jan 2019 13:33:38 -0500 Subject: [PATCH] promote is not needed after #30471 --- base/math.jl | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/base/math.jl b/base/math.jl index ad4ccd85faef4..6671c39a519d7 100644 --- a/base/math.jl +++ b/base/math.jl @@ -546,7 +546,7 @@ function hypot(x::Number, y::Number) else r = ay / ax end - rr = ax * sqrt(1 + r * r) + rr = ax * sqrt(oneunit(r) + r * r) if isnan(r) if isinf(x) || isinf(y) @@ -563,14 +563,13 @@ end Compute the hypotenuse ``\\sqrt{\\sum x_i^2}`` avoiding overflow and underflow. """ -hypot(x::Number...) = _hypot(promote(x...)) -function _hypot(x::NTuple{N,<:Number}) where {N} +function hypot(x::Number...) where {N} N == 0 && error("invalid hypot() call without arguments") # speculatively try fast naive approach s = sum(abs2.(float.(x))) if isnan(s) return any(isinf, x) ? oftype(sqrt(s), Inf) : sqrt(s) # IEEE 754 - elseif isinf(s) || s ≤ _floatmin(s) * (N-1) # FIXME: revisit when #30387 is resolved + elseif isinf(s) || float(s) ≤ _floatmin(float(s)) * (N-1) # if overflow/underflow, try normalization ma = maximum(abs.(float.(x))) if iszero(ma) || isinf(ma) @@ -587,7 +586,6 @@ _floatmin(x::AbstractFloat) = _floatmin(typeof(x)) _floatmin(::Type{T}) where {T<:AbstractFloat} = nextfloat(zero(T)) / eps(T) _floatmin(::Type{T}) where {T<:IEEEFloat} = floatmin(T) - atan(y::Real, x::Real) = atan(promote(float(y),float(x))...) atan(y::T, x::T) where {T<:AbstractFloat} = Base.no_op_err("atan", T)