diff --git a/NEWS.md b/NEWS.md index e266dca4..75844aa9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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) ------------------- diff --git a/src/math.jl b/src/math.jl index 7b3b3814..47d1b6ff 100644 --- a/src/math.jl +++ b/src/math.jl @@ -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) diff --git a/test/runtests.jl b/test/runtests.jl index cde55259..7032c4da 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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