Skip to content

Commit ca7806c

Browse files
authored
Add derivatives for log1pmx and logmxp1 (#47)
1 parent 31dbd7e commit ca7806c

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LogExpFunctions"
22
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
33
authors = ["StatsFun.jl contributors, Tamas K. Papp <[email protected]>"]
4-
version = "0.3.12"
4+
version = "0.3.13"
55

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

src/chainrules.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ ChainRulesCore.@scalar_rule(log1pexp(x::Real), (logistic(x),))
4848
ChainRulesCore.@scalar_rule(log1mexp(x::Real), (-exp(x - Ω),))
4949
ChainRulesCore.@scalar_rule(log2mexp(x::Real), (-exp(x - Ω),))
5050
ChainRulesCore.@scalar_rule(logexpm1(x::Real), (exp(x - Ω),))
51+
ChainRulesCore.@scalar_rule(log1pmx(x::Real), (-x / (x + 1),))
52+
ChainRulesCore.@scalar_rule(logmxp1(x::Real), ((1 - x) / x,))
5153

5254
ChainRulesCore.@scalar_rule(logaddexp(x::Real, y::Real), (exp(x - Ω), exp(y - Ω)))
5355
ChainRulesCore.@scalar_rule(

test/chainrules.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@
8484
test_rrule(logexpm1, x; rtol=1f-3, atol=1f-3)
8585
end
8686

87+
test_scalar(log1pmx, rand())
88+
89+
test_scalar(logmxp1, 0.5 + rand())
90+
8791
for x in (-randexp(), randexp()), y in (-randexp(), randexp())
8892
test_frule(logaddexp, x, y)
8993
test_rrule(logaddexp, x, y)

0 commit comments

Comments
 (0)