Skip to content

Commit

Permalink
Add definition for logabsgamma (#585)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
devmotion and oxinabox authored May 18, 2022
1 parent 4ba6c90 commit 78c73af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ForwardDiff"
uuid = "f6369f11-7733-5829-9624-2563aa707210"
version = "0.10.29"
version = "0.10.30"

[deps]
CommonSubexpressions = "bbf7d656-a473-5ed7-a52c-81e309532950"
Expand Down
9 changes: 9 additions & 0 deletions src/dual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,15 @@ function LinearAlgebra.eigen(A::SymTridiagonal{<:Dual{Tg,T,N}}) where {Tg,T<:Rea
Eigen(λ,Dual{Tg}.(Q, tuple.(parts...)))
end

# SpecialFunctions.logabsgamma #
# Derivative is not defined in DiffRules #
#----------------------------------------#

function SpecialFunctions.logabsgamma(d::Dual{T,<:Real}) where {T}
x = value(d)
y, s = SpecialFunctions.logabsgamma(x)
return (Dual{T}(y, SpecialFunctions.digamma(x) * partials(d)), s)
end

###################
# Pretty Printing #
Expand Down
3 changes: 3 additions & 0 deletions test/DualTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ for N in (0,3), M in (0,4), V in (Int, Float32)
@test dual_isapprox(f(FDNUM, PRIMAL2, PRIMAL3), Dual{TestTag()}(f(PRIMAL, PRIMAL2, PRIMAL3), PRIMAL2*PARTIALS))
@test dual_isapprox(f(PRIMAL, PRIMAL2, FDNUM3), Dual{TestTag()}(f(PRIMAL, PRIMAL2, PRIMAL3), PARTIALS3))
end

@test dual_isapprox(logabsgamma(FDNUM)[1], loggamma(abs(FDNUM)))
@test dual_isapprox(logabsgamma(FDNUM)[2], sign(gamma(FDNUM)))
end

@testset "Exponentiation of zero" begin
Expand Down

2 comments on commit 78c73af

@devmotion
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/60502

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.30 -m "<description of version>" 78c73afd9a21593daf54f61c7d0db67130cf29e1
git push origin v0.10.30

Please sign in to comment.