Automatic Differentiation
 
Loading...
Searching...
No Matches
tgamma.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUN_TGAMMA_HPP
2#define STAN_MATH_REV_FUN_TGAMMA_HPP
3
8
9namespace stan {
10namespace math {
11
48inline var tgamma(const var& a) {
49 return make_callback_var(tgamma(a.val()), [a](auto& vi) mutable {
50 a.adj() += vi.adj() * vi.val() * digamma(a.val());
51 });
52}
53
61template <typename T, require_var_matrix_t<T>* = nullptr>
62inline auto tgamma(const T& a) {
63 return make_callback_var(tgamma(a.val()), [a](auto& vi) mutable {
64 a.adj().array()
65 += vi.adj().array() * vi.val().array() * digamma(a.val()).array();
66 });
67}
68
69} // namespace math
70} // namespace stan
71#endif
var_value< plain_type_t< T > > make_callback_var(T &&value, F &&functor)
Creates a new var initialized with a callback_vari with a given value and reverse-pass callback funct...
fvar< T > tgamma(const fvar< T > &x)
Return the result of applying the gamma function to the specified argument.
Definition tgamma.hpp:21
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...