Skip to content

Commit 661ee35

Browse files
committed
Convert irrational manually with oftype
1 parent 02d5e64 commit 661ee35

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

src/chainrules.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ChainRulesCore.@scalar_rule(erf(x, y), (- (2 * exp(-x^2)) / sqrtπ, (2 * exp(-y^
4040
ChainRulesCore.@scalar_rule(erfc(x), - (2 * exp(-x^2)) / sqrtπ)
4141
ChainRulesCore.@scalar_rule(logerfc(x), - (2 * exp(-x^2 - Ω)) / sqrtπ)
4242
ChainRulesCore.@scalar_rule(erfcinv(x), - (sqrtπ * (exp^2) / 2)))
43-
ChainRulesCore.@scalar_rule(erfcx(x), 2 * x * Ω - 2 / sqrtπ)
43+
ChainRulesCore.@scalar_rule(erfcx(x), 2 * (x * Ω - inv(oftype(Ω, sqrtπ))))
4444
ChainRulesCore.@scalar_rule(logerfcx(x), 2 * (x - exp(-Ω) / sqrtπ))
4545
ChainRulesCore.@scalar_rule(erfi(x), (2 * exp(x^2)) / sqrtπ)
4646
ChainRulesCore.@scalar_rule(erfinv(x), sqrtπ * (exp^2) / 2))

test/chainrules.jl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
# https://github.com/JuliaMath/SpecialFunctions.jl/issues/307
148148
@testset "promotions" begin
149149
# one argument
150-
for f in (erf, erfc, logerfc, erfcinv, logerfcx, erfi, erfinv, sinint)
150+
for f in (erf, erfc, logerfc, erfcinv, erfcx, logerfcx, erfi, erfinv, sinint)
151151
_, ẏ = frule((NoTangent(), 1f0), f, 1f0)
152152
@testisa Float32
153153
_, back = rrule(f, 1f0)
@@ -161,13 +161,5 @@
161161
_, back = rrule(erf, 1f0, 1f0)
162162
_, x̄ = back(1f0)
163163
@testisa Float32
164-
165-
# currently broken, can be fixed if `invsqrtπ` is available:
166-
# https://github.com/JuliaMath/IrrationalConstants.jl/pull/8#issuecomment-925828753
167-
_, ẏ = frule((NoTangent(), 1f0), erfcx, 1f0)
168-
@test_brokenisa Float32
169-
_, back = rrule(erfcx, 1f0)
170-
_, x̄ = back(1f0)
171-
@testisa Float32
172164
end
173165
end

0 commit comments

Comments
 (0)