Skip to content

Commit

Permalink
Specialize for Integer instead of FloatingPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
malmaud committed Oct 11, 2015
1 parent 35ea25b commit c0eb095
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ end
n>=0 ? power_by_squaring(z,n) : power_by_squaring(inv(z),-n)
^{T<:Integer}(z::Complex{T}, n::Integer) = power_by_squaring(z,n) # DomainError for n<0

function sin{T<:AbstractFloat}(z::Complex{T})
function sin(z::Complex)
zr, zi = reim(z)
if !isfinite(zi) && zr == 0 return Complex(zr, zi) end
if isnan(zr) && !isfinite(zi) return Complex(zr, zi) end
Expand All @@ -554,14 +554,14 @@ function sin{T<:AbstractFloat}(z::Complex{T})
_sin(z)
end

sin(z::Complex) = _sin(z)
sin{T<:Integer}(z::Complex{T}) = _sin(z)

function _sin(z::Complex)
zr, zi = reim(z)
Complex(sin(zr)*cosh(zi), cos(zr)*sinh(zi))
end

function cos{T<:AbstractFloat}(z::Complex{T})
function cos(z::Complex)
zr, zi = reim(z)
if !isfinite(zi) && zr == 0
return Complex(isnan(zi) ? zi : oftype(zi, Inf),
Expand All @@ -577,7 +577,7 @@ function cos{T<:AbstractFloat}(z::Complex{T})
_cos(z)
end

cos(z::Complex) = _cos(z)
cos{T<:Integer}(z::Complex{T}) = _cos(z)

function _cos(z::Complex)
zr, zi = reim(z)
Expand Down

0 comments on commit c0eb095

Please sign in to comment.