Skip to content

Commit

Permalink
Showing 16 changed files with 95 additions and 91 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1256,6 +1256,8 @@ Deprecated or removed

* `setrounding` has been deprecated for `Float32` and `Float64`, as the behaviour was too unreliable ([#26935]).

* `atan2` is now a 2-argument method of `atan` ([#27248]).

Command-line option changes
---------------------------

@@ -1591,3 +1593,4 @@ Command-line option changes
[#27164]: https://github.com/JuliaLang/julia/issues/27164
[#27189]: https://github.com/JuliaLang/julia/issues/27189
[#27212]: https://github.com/JuliaLang/julia/issues/27212
[#27248]: https://github.com/JuliaLang/julia/issues/27248
8 changes: 4 additions & 4 deletions base/complex.jl
Original file line number Diff line number Diff line change
@@ -513,7 +513,7 @@ julia> rad2deg(angle(-1 - im))
-135.0
```
"""
angle(z::Complex) = atan2(imag(z), real(z))
angle(z::Complex) = atan(imag(z), real(z))

function log(z::Complex{T}) where T<:AbstractFloat
T1::T = 1.25
@@ -809,7 +809,7 @@ function asin(z::Complex)
end
ξ = zr == 0 ? zr :
!isfinite(zr) ? oftype(zr,pi)/2 * sign(zr) :
atan2(zr, real(sqrt(1-z)*sqrt(1+z)))
atan(zr, real(sqrt(1-z)*sqrt(1+z)))
η = asinh(copysign(imag(sqrt(conj(1-z))*sqrt(1+z)), imag(z)))
Complex(ξ,η)
end
@@ -830,7 +830,7 @@ function acos(z::Complex{<:AbstractFloat})
elseif zr==-Inf && zi===-0.0
return Complex(oftype(zi,pi), -zr)
end
ξ = 2*atan2(real(sqrt(1-z)), real(sqrt(1+z)))
ξ = 2*atan(real(sqrt(1-z)), real(sqrt(1+z)))
η = asinh(imag(sqrt(conj(1+z))*sqrt(1-z)))
if isinf(zr) && isinf(zi) ξ -= oftype(η,pi)/4 * sign(zr) end
Complex(ξ,η)
@@ -891,7 +891,7 @@ function acosh(z::Complex)
return Complex(oftype(zr,Inf), oftype(zi, -pi))
end
ξ = asinh(real(sqrt(conj(z-1))*sqrt(z+1)))
η = 2atan2(imag(sqrt(z-1)),real(sqrt(z+1)))
η = 2*atan(imag(sqrt(z-1)),real(sqrt(z+1)))
if isinf(zr) && isinf(zi)
η -= oftype(η,pi)/4 * sign(zi) * sign(zr)
end
3 changes: 3 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
@@ -1705,6 +1705,9 @@ end

@eval @deprecate $(Symbol("@schedule")) $(Symbol("@async"))

@deprecate atan2(y, x) atan(y, x)


# END 0.7 deprecations

# BEGIN 1.0 deprecations
1 change: 0 additions & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
@@ -212,7 +212,6 @@ export
asind,
asinh,
atan,
atan2,
atand,
atanh,
big,
9 changes: 4 additions & 5 deletions base/fastmath.jl
Original file line number Diff line number Diff line change
@@ -57,7 +57,6 @@ const fast_op =
:asin => :asin_fast,
:asinh => :asinh_fast,
:atan => :atan_fast,
:atan2 => :atan2_fast,
:atanh => :atanh_fast,
:cbrt => :cbrt_fast,
:cis => :cis_fast,
@@ -293,9 +292,9 @@ pow_fast(x::Float32, y::Float32) =
pow_fast(x::Float64, y::Float64) =
ccall(("pow",libm), Float64, (Float64,Float64), x, y)

atan2_fast(x::Float32, y::Float32) =
atan_fast(x::Float32, y::Float32) =
ccall(("atan2f",libm), Float32, (Float32,Float32), x, y)
atan2_fast(x::Float64, y::Float64) =
atan_fast(x::Float64, y::Float64) =
ccall(("atan2",libm), Float64, (Float64,Float64), x, y)

asin_fast(x::FloatTypes) = asin(x)
@@ -349,7 +348,7 @@ sincos_fast(v) = (sin_fast(v), cos_fast(v))
acos_fast(x::T) where {T<:ComplexTypes} =
convert(T,π)/2 + im*log(im*x + sqrt(1-x*x))
acosh_fast(x::ComplexTypes) = log(x + sqrt(x+1) * sqrt(x-1))
angle_fast(x::ComplexTypes) = atan2(imag(x), real(x))
angle_fast(x::ComplexTypes) = atan(imag(x), real(x))
asin_fast(x::ComplexTypes) = -im*asinh(im*x)
asinh_fast(x::ComplexTypes) = log(x + sqrt(1+x*x))
atan_fast(x::ComplexTypes) = -im*atanh(im*x)
@@ -387,7 +386,7 @@ for f in (:acos, :acosh, :angle, :asin, :asinh, :atan, :atanh, :cbrt,
end
end

for f in (:^, :atan2, :hypot, :max, :min, :minmax, :log)
for f in (:^, :atan, :hypot, :max, :min, :minmax, :log)
f_fast = fast_op[f]
@eval begin
# fall-back implementation for non-numeric types
26 changes: 14 additions & 12 deletions base/math.jl
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ export sin, cos, sincos, tan, sinh, cosh, tanh, asin, acos, atan,
sech, csch, coth, asech, acsch, acoth,
sinpi, cospi, sinc, cosc,
cosd, cotd, cscd, secd, sind, tand,
acosd, acotd, acscd, asecd, asind, atand, atan2,
acosd, acotd, acscd, asecd, asind, atand,
rad2deg, deg2rad,
log, log2, log10, log1p, exponent, exp, exp2, exp10, expm1,
cbrt, sqrt, significand,
@@ -250,9 +250,17 @@ Compute hyperbolic tangent of `x`.
tanh(x::Number)

"""
atan(x)
atan(y)
atan(y, x)
Compute the inverse tangent of `x`, where the output is in radians.
Compute the inverse tangent of `y` or `y/x`, respectively.
For one argument, this is the angle in radians between the positive *x*-axis and the point
(1, *y*), returning a value in the interval ``[-\\pi/2, \\pi/2]``.
For two arguments, this is the angle in radians between the positive *x*-axis and the
point (*x*, *y*), returning a value in the interval ``[-\\pi, \\pi]``. This corresponds to a
standard [`atan2`](https://en.wikipedia.org/wiki/Atan2) function.
"""
atan(x::Number)

@@ -565,14 +573,8 @@ Compute the hypotenuse ``\\sqrt{\\sum x_i^2}`` avoiding overflow and underflow.
"""
hypot(x::Number...) = sqrt(sum(abs2(y) for y in x))

"""
atan2(y, x)
Compute the inverse tangent of `y/x`, using the signs of both `x` and `y` to determine the
quadrant of the return value.
"""
atan2(y::Real, x::Real) = atan2(promote(float(y),float(x))...)
atan2(y::T, x::T) where {T<:AbstractFloat} = Base.no_op_err("atan2", 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)

max(x::T, y::T) where {T<:AbstractFloat} = ifelse((y > x) | (signbit(y) < signbit(x)),
ifelse(isnan(x), x, y), ifelse(isnan(y), y, x))
@@ -1021,7 +1023,7 @@ for func in (:sin,:cos,:tan,:asin,:acos,:atan,:sinh,:cosh,:tanh,:asinh,:acosh,
end
end

for func in (:atan2,:hypot)
for func in (:atan,:hypot)
@eval begin
$func(a::Float16,b::Float16) = Float16($func(Float32(a),Float32(b)))
end
4 changes: 2 additions & 2 deletions base/mpfr.jl
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import
sum, sqrt, string, print, trunc, precision, exp10, expm1,
gamma, lgamma, log1p,
eps, signbit, sin, cos, sincos, tan, sec, csc, cot, acos, asin, atan,
cosh, sinh, tanh, sech, csch, coth, acosh, asinh, atanh, atan2,
cosh, sinh, tanh, sech, csch, coth, acosh, asinh, atanh,
cbrt, typemax, typemin, unsafe_trunc, realmin, realmax, rounding,
setrounding, maxintfloat, widen, significand, frexp, tryparse, iszero,
isone, big, beta, RefValue
@@ -677,7 +677,7 @@ end

lgamma_r(x::BigFloat) = (lgamma(x), lgamma_signp[])

function atan2(y::BigFloat, x::BigFloat)
function atan(y::BigFloat, x::BigFloat)
z = BigFloat()
ccall((:mpfr_atan2, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Ref{BigFloat}, Int32), z, y, x, ROUNDING_MODE[])
return z
2 changes: 1 addition & 1 deletion base/number.jl
Original file line number Diff line number Diff line change
@@ -191,7 +191,7 @@ copysign(x::Real, y::Real) = ifelse(signbit(x)!=signbit(y), -x, +x)
conj(x::Real) = x
transpose(x::Number) = x
adjoint(x::Number) = conj(x)
angle(z::Real) = atan2(zero(z), z)
angle(z::Real) = atan(zero(z), z)

"""
inv(x)
2 changes: 1 addition & 1 deletion base/special/trig.jl
Original file line number Diff line number Diff line change
@@ -564,7 +564,7 @@ ATAN2_PI_LO(::Type{Float64}) = 1.2246467991473531772E-16
ATAN2_RATIO_BIT_SHIFT(::Type{Float64}) = 20
ATAN2_RATIO_THRESHOLD(::Type{Float64}) = 60

function atan2(y::T, x::T) where T<:Union{Float32, Float64}
function atan(y::T, x::T) where T<:Union{Float32, Float64}
# Method :
# M1) Reduce y to positive by atan2(y,x)=-atan2(-y,x).
# M2) Reduce x to positive by (if x and y are unexceptional):
1 change: 0 additions & 1 deletion doc/src/base/math.md
Original file line number Diff line number Diff line change
@@ -72,7 +72,6 @@ Base.tanh(::Number)
Base.asin(::Number)
Base.acos(::Number)
Base.atan(::Number)
Base.Math.atan2
Base.Math.asind
Base.Math.acosd
Base.Math.atand
7 changes: 3 additions & 4 deletions doc/src/manual/mathematical-operations.md
Original file line number Diff line number Diff line change
@@ -528,12 +528,11 @@ sin cos tan cot sec csc
sinh cosh tanh coth sech csch
asin acos atan acot asec acsc
asinh acosh atanh acoth asech acsch
sinc cosc atan2
sinc cosc
```

These are all single-argument functions, with the exception of [atan2](https://en.wikipedia.org/wiki/Atan2),
which gives the angle in [radians](https://en.wikipedia.org/wiki/Radian) between the *x*-axis
and the point specified by its arguments, interpreted as *x* and *y* coordinates.
These are all single-argument functions, with [`atan`](@ref) also accepting two arguments
corresponding to a traditional [`atan2`](https://en.wikipedia.org/wiki/Atan2) function.

Additionally, [`sinpi(x)`](@ref) and [`cospi(x)`](@ref) are provided for more accurate computations
of [`sin(pi*x)`](@ref) and [`cos(pi*x)`](@ref) respectively.
24 changes: 12 additions & 12 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
@@ -174,10 +174,10 @@ let x = [1, 3.2, 4.7],
@test sin.(α) == broadcast(sin, α)
@test sin.(3.2) == broadcast(sin, 3.2) == sin(3.2)
@test factorial.(3) == broadcast(factorial, 3)
@test atan2.(x, y) == broadcast(atan2, x, y)
@test atan2.(x, y') == broadcast(atan2, x, y')
@test atan2.(x, α) == broadcast(atan2, x, α)
@test atan2.(α, y') == broadcast(atan2, α, y')
@test atan.(x, y) == broadcast(atan, x, y)
@test atan.(x, y') == broadcast(atan, x, y')
@test atan.(x, α) == broadcast(atan, x, α)
@test atan.(α, y') == broadcast(atan, α, y')
end

# issue 14725
@@ -215,13 +215,13 @@ end
# PR #17300: loop fusion
@test (x->x+1).((x->x+2).((x->x+3).(1:10))) == 7:16
let A = [sqrt(i)+j for i = 1:3, j=1:4]
@test atan2.(log.(A), sum(A, dims=1)) == broadcast(atan2, broadcast(log, A), sum(A, dims=1))
@test atan.(log.(A), sum(A, dims=1)) == broadcast(atan, broadcast(log, A), sum(A, dims=1))
end
let x = sin.(1:10)
@test atan2.((x->x+1).(x), (x->x+2).(x)) == broadcast(atan2, x.+1, x.+2)
@test sin.(atan2.([x.+1,x.+2]...)) == sin.(atan2.(x.+1 ,x.+2)) == @. sin(atan2(x+1,x+2))
@test sin.(atan2.(x, 3.7)) == broadcast(x -> sin(atan2(x,3.7)), x)
@test atan2.(x, 3.7) == broadcast(x -> atan2(x,3.7), x) == broadcast(atan2, x, 3.7)
@test atan.((x->x+1).(x), (x->x+2).(x)) == broadcast(atan, x.+1, x.+2)
@test sin.(atan.([x.+1,x.+2]...)) == sin.(atan.(x.+1 ,x.+2)) == @. sin(atan(x+1,x+2))
@test sin.(atan.(x, 3.7)) == broadcast(x -> sin(atan(x,3.7)), x)
@test atan.(x, 3.7) == broadcast(x -> atan(x,3.7), x) == broadcast(atan, x, 3.7)
end
# Use side effects to check for loop fusion.
let g = Int[]
@@ -235,11 +235,11 @@ end
# fusion with splatted args:
let x = sin.(1:10), a = [x]
@test cos.(x) == cos.(a...)
@test atan2.(x,x) == atan2.(a..., a...) == atan2.([x, x]...)
@test atan2.(x, cos.(x)) == atan2.(a..., cos.(x)) == broadcast(atan2, x, cos.(a...)) == broadcast(atan2, a..., cos.(a...))
@test atan.(x,x) == atan.(a..., a...) == atan.([x, x]...)
@test atan.(x, cos.(x)) == atan.(a..., cos.(x)) == broadcast(atan, x, cos.(a...)) == broadcast(atan, a..., cos.(a...))
@test ((args...)->cos(args[1])).(x) == cos.(x) == ((y,args...)->cos(y)).(x)
end
@test atan2.(3, 4) == atan2(3, 4) == (() -> atan2(3, 4)).()
@test atan.(3, 4) == atan(3, 4) == (() -> atan(3, 4)).()
# fusion with keyword args:
let x = [1:4;]
f17300kw(x; y=0) = x + y
2 changes: 1 addition & 1 deletion test/fastmath.jl
Original file line number Diff line number Diff line change
@@ -122,7 +122,7 @@ end
end
end
for f in (:+, :-, :*, :/, :%, :(==), :!=, :<, :<=, :>, :>=, :^,
:atan2, :hypot, :max, :min, :log)
:atan, :hypot, :max, :min, :log)
@eval begin
@test @fastmath($f($half, $third)) $f($half, $third)
@test @fastmath($f($third, $half)) $f($third, $half)
Loading
Oops, something went wrong.

2 comments on commit 91d2071

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something went wrong when running your job:

NanosoldierError: failed to run benchmarks against primary commit: failed process: Process(`sudo cset shield -e su nanosoldier -- -c ./benchscript.sh`, ProcessExited(1)) [1]

Logs and partial data can be found here
cc @ararslan

Please sign in to comment.