Skip to content

Commit 4ecf0a9

Browse files
committed
Define with_logabsdet_jacobian for unary plus and minus
1 parent c143c49 commit 4ecf0a9

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/with_ladj.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ with_logabsdet_jacobian(::typeof(inv), A::AbstractMatrix) = (inv(A), -2 * _ndof(
118118
with_logabsdet_jacobian(::typeof(adjoint), x) = (adjoint(x), zero(eltype(x)))
119119
with_logabsdet_jacobian(::typeof(transpose), x) = (transpose(x), zero(eltype(x)))
120120

121+
with_logabsdet_jacobian(::typeof(+), x) = (+(x), zero(eltype(x)))
122+
with_logabsdet_jacobian(::typeof(-), x) = (-(x), zero(eltype(x)))
121123

122124
with_logabsdet_jacobian(::typeof(exp), x) = (exp(x), x)
123125
with_logabsdet_jacobian(::typeof(exp2), x) = (exp2(x), log(2) * x + log(log(oftype(x, 2))))

test/test_with_ladj.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ include("getjacobian.jl")
5757
end
5858

5959
@testset "with_logabsdet_jacobian on log and exp functions" begin
60-
for f in (exp, log, exp2, log2, exp10, log10, expm1, log1p)
60+
for f in (+, -, exp, log, exp2, log2, exp10, log10, expm1, log1p)
6161
test_with_logabsdet_jacobian(f, x, getjacobian)
6262
end
6363
end

0 commit comments

Comments
 (0)