Skip to content

Commit

Permalink
Change dispatch logic slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaraldi committed Aug 9, 2023
1 parent 640c735 commit 9fcc63f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@ sincos(a::Float16) = Float16.(sincos(Float32(a)))
for f in (:sin, :cos, :tan, :asin, :atan, :acos,
:sinh, :cosh, :tanh, :asinh, :acosh, :atanh,
:exp, :exp2, :exp10, :expm1, :log, :log2, :log10, :log1p,
:exponent, :sqrt, :cbrt)
:exponent, :sqrt, :cbrt, :sinpi, :cospi, :sincospi, :tanpi)
@eval function ($f)(x::Real)
xf = float(x)
x === xf && throw(MethodError($f, (x,)))
Expand Down
8 changes: 4 additions & 4 deletions base/special/trig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -932,10 +932,10 @@ cospi(x::Integer) = isodd(x) ? -one(float(x)) : one(float(x))
tanpi(x::Integer) = x >= 0 ? (isodd(x) ? -zero(float(x)) : zero(float(x))) :
(isodd(x) ? zero(float(x)) : -zero(float(x)))
sincospi(x::Integer) = (sinpi(x), cospi(x))
sinpi(x::Real) = sin(pi*x)
cospi(x::Real) = cos(pi*x)
sincospi(x::Real) = sincos(pi*x)
tanpi(x::Real) = tan(pi*x)
sinpi(x::AbstractFloat) = sin(pi*x)
cospi(x::AbstractFloat) = cos(pi*x)
sincospi(x::AbstractFloat) = sincos(pi*x)
tanpi(x::AbstractFloat) = tan(pi*x)
tanpi(x::Complex) = sinpi(x) / cospi(x) # Is there a better way to do this?

function sinpi(z::Complex{T}) where T
Expand Down

0 comments on commit 9fcc63f

Please sign in to comment.