From be36f9ec5193e12c4bee1725b5c787fc0ab92b33 Mon Sep 17 00:00:00 2001 From: Davide Lasagna Date: Sat, 8 Nov 2014 14:14:32 +0000 Subject: [PATCH] Name atan2 arguments consistently Doing `methods(atan2)` reveals an inconsistency in the names of the arguments x and y. The documentation about atan2 says `atan2(y, x)`, but the names in the functions are inverted. backport of c5d868f1832381d41dd14ad2efe3c706d1b7dc69 Changed argument names for atan2 in float16.jl backport of 0ed59050d6cb2cb489eed004305a8a759cb36cfb --- base/float16.jl | 2 +- base/math.jl | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/base/float16.jl b/base/float16.jl index ea1dfd1b3856b..7f9339ce0e889 100644 --- a/base/float16.jl +++ b/base/float16.jl @@ -141,7 +141,7 @@ for func in (:sin,:cos,:tan,:asin,:acos,:atan,:sinh,:cosh,:tanh,:asinh,:acosh, $func(a::Complex32) = complex32($func(complex64(a))) end end -atan2(a::Float16, b::Float16) = float16(atan2(float32(a), float32(b))) +atan2(y::Float16, x::Float16) = float16(atan2(float32(y), float32(x))) hypot(a::Float16, b::Float16) = float16(hypot(float32(a), float32(b))) ldexp(a::Float16, b::Integer) = float16(ldexp(float32(a), b)) exponent(x::Float16) = exponent(float32(x)) diff --git a/base/math.jl b/base/math.jl index 246437277d8c5..0604fee5e0e52 100644 --- a/base/math.jl +++ b/base/math.jl @@ -165,13 +165,13 @@ function hypot{T<:FloatingPoint}(x::T, y::T) x * sqrt(one(r)+r*r) end -atan2(x::Real, y::Real) = atan2(promote(float(x),float(y))...) -atan2{T<:FloatingPoint}(x::T, y::T) = Base.no_op_err("atan2", T) +atan2(y::Real, x::Real) = atan2(promote(float(y),float(x))...) +atan2{T<:FloatingPoint}(y::T, x::T) = Base.no_op_err("atan2", T) for f in (:atan2, :hypot) @eval begin - ($f)(x::Float64, y::Float64) = ccall(($(string(f)),libm), Float64, (Float64, Float64,), x, y) - ($f)(x::Float32, y::Float32) = ccall(($(string(f,"f")),libm), Float32, (Float32, Float32), x, y) + ($f)(y::Float64, x::Float64) = ccall(($(string(f)),libm), Float64, (Float64, Float64,), y, x) + ($f)(y::Float32, x::Float32) = ccall(($(string(f,"f")),libm), Float32, (Float32, Float32), y, x) @vectorize_2arg Number $f end end