Skip to content

Commit 78c73af

Browse files
devmotionoxinabox
andauthored
Add definition for logabsgamma (#585)
* Add definition for `logabsgamma` * Update test/DualTest.jl Co-authored-by: Frames Catherine White <[email protected]> * Update Project.toml Co-authored-by: Frames Catherine White <[email protected]>
1 parent 4ba6c90 commit 78c73af

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 = "ForwardDiff"
22
uuid = "f6369f11-7733-5829-9624-2563aa707210"
3-
version = "0.10.29"
3+
version = "0.10.30"
44

55
[deps]
66
CommonSubexpressions = "bbf7d656-a473-5ed7-a52c-81e309532950"

src/dual.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,15 @@ function LinearAlgebra.eigen(A::SymTridiagonal{<:Dual{Tg,T,N}}) where {Tg,T<:Rea
755755
Eigen(λ,Dual{Tg}.(Q, tuple.(parts...)))
756756
end
757757

758+
# SpecialFunctions.logabsgamma #
759+
# Derivative is not defined in DiffRules #
760+
#----------------------------------------#
761+
762+
function SpecialFunctions.logabsgamma(d::Dual{T,<:Real}) where {T}
763+
x = value(d)
764+
y, s = SpecialFunctions.logabsgamma(x)
765+
return (Dual{T}(y, SpecialFunctions.digamma(x) * partials(d)), s)
766+
end
758767

759768
###################
760769
# Pretty Printing #

test/DualTest.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,9 @@ for N in (0,3), M in (0,4), V in (Int, Float32)
539539
@test dual_isapprox(f(FDNUM, PRIMAL2, PRIMAL3), Dual{TestTag()}(f(PRIMAL, PRIMAL2, PRIMAL3), PRIMAL2*PARTIALS))
540540
@test dual_isapprox(f(PRIMAL, PRIMAL2, FDNUM3), Dual{TestTag()}(f(PRIMAL, PRIMAL2, PRIMAL3), PARTIALS3))
541541
end
542+
543+
@test dual_isapprox(logabsgamma(FDNUM)[1], loggamma(abs(FDNUM)))
544+
@test dual_isapprox(logabsgamma(FDNUM)[2], sign(gamma(FDNUM)))
542545
end
543546

544547
@testset "Exponentiation of zero" begin

0 commit comments

Comments
 (0)