Skip to content

Commit

Permalink
Define method for sincospi
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano committed Sep 8, 2020
1 parent 84a9c52 commit 53fe2bd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
History of Measurements.jl
==========================

v2.4.0 (2020-??-??)
-------------------

### New features

* New method for `sincospi(::Measurement)`, when `sincospi` is defined.

v2.3.0 (2020-09-08)
-------------------

Expand Down
7 changes: 7 additions & 0 deletions src/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,13 @@ function Base.sincos(a::Measurement)
return (result(s, c, a), result(c, -s, a))
end

if isdefined(Base, :sincospi)
function Base.sincospi(a::Measurement)
s, c = sincospi(a.val)
return (result(s, c * pi, a), result(c, -s * pi, a))
end
end

# Tangent: tan, tand, tanh

function Base.tan(a::Measurement)
Expand Down
11 changes: 11 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,18 @@ end
if isdefined(Base, :sincos)
# Check we got the sign of derivatives in `sincos` right.
s, c = @inferred(sincos(a))
@test s sin(a)
@test c cos(a)
@test s + c sin(a) + cos(a)
@test s - c sin(a) - cos(a)
@test s ^ 2 + c ^ 2 one(a)
end
if isdefined(Base, :sincospi)
s, c = @inferred(sincospi(a))
@test s sinpi(a)
@test c cospi(a)
@test s + c sinpi(a) + cospi(a)
@test s - c sinpi(a) - cospi(a)
@test s ^ 2 + c ^ 2 one(a)
end
end
Expand Down

0 comments on commit 53fe2bd

Please sign in to comment.