Skip to content

Commit 960e09e

Browse files
authored
Add cispi and sincospi (#533)
1 parent 665dc5a commit 960e09e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/quantities.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,10 @@ sqrt(x::AbstractQuantity) = Quantity(sqrt(x.val), sqrt(unit(x)))
206206
cbrt(x::AbstractQuantity) = Quantity(cbrt(x.val), cbrt(unit(x)))
207207

208208
for _y in (:sin, :cos, :tan, :asin, :acos, :atan, :sinh, :cosh, :tanh, :asinh, :acosh, :atanh,
209-
:sinpi, :cospi, :sinc, :cosc, :cis)
210-
@eval ($_y)(x::DimensionlessQuantity) = ($_y)(uconvert(NoUnits, x))
209+
:sinpi, :cospi, :sinc, :cosc, :cis, :cispi, :sincospi)
210+
if isdefined(Base, _y)
211+
@eval Base.$(_y)(x::DimensionlessQuantity) = Base.$(_y)(uconvert(NoUnits, x))
212+
end
211213
end
212214

213215
atan(y::AbstractQuantity{T1,D,U1}, x::AbstractQuantity{T2,D,U2}) where {T1,T2,D,U1,U2} =

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,12 @@ end
710710
@test @inferred(cospi(1rad)) == -1
711711
@test @inferred(sinc(1rad)) === 0
712712
@test @inferred(cosc(1ft/3inch)) === 0.25
713+
if isdefined(Base, :cispi)
714+
@test @inferred(cispi(rad/2)) === complex(0.0, 1.0)
715+
end
716+
if isdefined(Base, :sincospi)
717+
@test @inferred(sincospi(rad/2)) === (1.0, 0.0)
718+
end
713719

714720
@test @inferred(atan(m*sqrt(3),1m)) 60°
715721
@test @inferred(atan(m*sqrt(3),1.0m)) 60°

0 commit comments

Comments
 (0)