Automatic Differentiation
 
Loading...
Searching...
No Matches
log_rising_factorial.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_FWD_FUN_LOG_RISING_FACTORIAL_HPP
2#define STAN_MATH_FWD_FUN_LOG_RISING_FACTORIAL_HPP
3
8
9namespace stan {
10namespace math {
11
12template <typename T>
13inline fvar<T> log_rising_factorial(const fvar<T>& x, const fvar<T>& n) {
14 return fvar<T>(
16 digamma(x.val_ + n.val_) * (x.d_ + n.d_) - digamma(x.val_) * x.d_);
17}
18
19template <typename T>
20inline fvar<T> log_rising_factorial(const fvar<T>& x, double n) {
22 (digamma(x.val_ + n) - digamma(x.val_)) * x.d_);
23}
24
25template <typename T>
26inline fvar<T> log_rising_factorial(double x, const fvar<T>& n) {
27 return fvar<T>(log_rising_factorial(x, n.val_), digamma(x + n.val_) * n.d_);
28}
29
30} // namespace math
31} // namespace stan
32#endif
fvar< T > log_rising_factorial(const fvar< T > &x, const fvar< T > &n)
fvar< T > digamma(const fvar< T > &x)
Return the derivative of the log gamma function at the specified argument.
Definition digamma.hpp:23
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Scalar val_
The value of this variable.
Definition fvar.hpp:49
Scalar d_
The tangent (derivative) of this variable.
Definition fvar.hpp:61
This template class represents scalars used in forward-mode automatic differentiation,...
Definition fvar.hpp:40