JuliaDiff / DiffRules.jl

A simple shared suite of common derivative definitions
Other
74 stars 38 forks source link

missing `logabsgamma` rules #83

Closed Moelf closed 2 years ago

Moelf commented 2 years ago

https://github.com/JuliaStats/LogExpFunctions.jl/issues/49

I can try to make a PR? is there any example of similar function?

devmotion commented 2 years ago

I added a rule to https://github.com/JuliaDiff/DiffRules.jl/pull/79, seems I forgot to add it in that PR.

Moelf commented 2 years ago

Oh sweet, I will wait for it to merge then

devmotion commented 2 years ago

Oh wait, I don't think it's currently possible to define a rule with DiffRules for this function. AFAIK DiffRules only supports real-valued functions with n real-valued arguments but logabsgamma returns a tuple of real values.

Moelf commented 2 years ago

ehhh, can we make a new function that returns logabsgamma(x)[1] then?

devmotion commented 2 years ago

Maybe we could add first \circ logabsgamma on more recent Julia versions since it's possible to dispatch on it there.

However, I am not sure if DiffRules and inparticular downstream packages can deal with rules where there's not a symbol as function name but an to-be-dispatched expression.

Probably the simpler solution is adding a definition of logabsgamma(::Dual) to ForwardDiff (it already depends on SpecialFunctions). Alternatively, you could use a ChainRulesCore compatible AD system (a rule is defined for CR).

devmotion commented 2 years ago

I opened a PR: https://github.com/JuliaDiff/ForwardDiff.jl/pull/585

devmotion commented 2 years ago

The PR is merged and part of ForwardDiff 0.10.30 which is available soon: https://github.com/JuliaRegistries/General/pull/60502