Skip to content

Commit 1b10564

Browse files
added a rule and tests for sincospi
1 parent 0d55c54 commit 1b10564

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/rulesets/Base/fastmath_able.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ let
4848
# Trig-Multivariate
4949
@scalar_rule atan(y, x) @setup(u = x ^ 2 + y ^ 2) (x / u, -y / u)
5050
@scalar_rule sincos(x) @setup((sinx, cosx) = Ω) cosx -sinx
51+
# the position of the minus sign below warrants the correct type for π
52+
@scalar_rule sincospi(x) @setup((sinpix, cospix) = Ω) (π * cospix, π * (-sinpix))
5153

5254
# exponents
5355
@scalar_rule cbrt(x) inv(3 * Ω ^ 2)

test/rulesets/Base/fastmath_able.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ const FASTABLE_AST = quote
6464
test_frule(sincos, randn(T))
6565
test_rrule(sincos, randn(T); output_tangent=Δz)
6666
end
67+
@testset "sincospi(x::$T)" for T in (Float64, ComplexF64)
68+
Δz = Tangent{Tuple{T,T}}(randn(T), randn(T))
69+
70+
test_frule(sincospi, randn(T))
71+
test_rrule(sincospi, randn(T); output_tangent=Δz)
72+
end
6773
end
6874
end
6975

0 commit comments

Comments
 (0)