Automatic Differentiation
 
Loading...
Searching...
No Matches
falling_factorial.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_FWD_FUN_FALLING_FACTORIAL_HPP
2#define STAN_MATH_FWD_FUN_FALLING_FACTORIAL_HPP
3
6
9
10namespace stan {
11namespace math {
12
25template <typename T>
26inline fvar<T> falling_factorial(const fvar<T>& x, int n) {
27 T falling_fact(falling_factorial(x.val_, n));
28 return fvar<T>(
29 falling_fact,
30 falling_fact * (digamma(x.val_ + 1) - digamma(x.val_ - n + 1)) * x.d_);
31}
32
33} // namespace math
34} // namespace stan
35#endif
fvar< T > falling_factorial(const fvar< T > &x, int n)
Return autodiff variable with the gradient and result of the falling factorial function applied to th...
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