Skip to content

Commit 47df5cf

Browse files
authored
Merge pull request #497 from RainerHeintzmann/master
Add rule for `sincospi`
2 parents 0d55c54 + 23a4001 commit 47df5cf

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ChainRules"
22
uuid = "082447d4-558c-5d27-93f4-14fc19e9eca2"
3-
version = "1.5.1"
3+
version = "1.6.0"
44

55
[deps]
66
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/rulesets/Base/fastmath_able.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ 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+
if VERSION v"1.6"
53+
@scalar_rule sincospi(x) @setup((sinpix, cospix) = Ω) (π * cospix) (π * (-sinpix))
54+
end
5155

5256
# exponents
5357
@scalar_rule cbrt(x) inv(3 * Ω ^ 2)

test/rulesets/Base/fastmath_able.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ const FASTABLE_AST = quote
6464
test_frule(sincos, randn(T))
6565
test_rrule(sincos, randn(T); output_tangent=Δz)
6666
end
67+
if VERSION v"1.6"
68+
@testset "sincospi(x::$T)" for T in (Float64, ComplexF64)
69+
Δz = Tangent{Tuple{T,T}}(randn(T), randn(T))
70+
71+
test_frule(sincospi, randn(T))
72+
test_rrule(sincospi, randn(T); output_tangent=Δz)
73+
end
74+
end
6775
end
6876
end
6977

0 commit comments

Comments
 (0)