Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
log_rising_factorial.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__FWD__FUNCTIONS__LOG_RISING_FACTORIAL_HPP
2 #define STAN__AGRAD__FWD__FUNCTIONS__LOG_RISING_FACTORIAL_HPP
3 
5 #include <stan/meta/traits.hpp>
7 #include <boost/math/special_functions/digamma.hpp>
8 
9 namespace stan {
10 
11  namespace agrad {
12 
13  template<typename T>
14  inline
15  fvar<T>
16  log_rising_factorial(const fvar<T>& x, const fvar<T>& n) {
19 
21  (digamma(x.val_ + n.val_) * (x.d_ + n.d_) - digamma(x.val_) * x.d_));
22  }
23 
24  template<typename T>
25  inline
26  fvar<T>
27  log_rising_factorial(const fvar<T>& x, const double n) {
30 
31  return fvar<T>(log_rising_factorial(x.val_,n),
32  (digamma(x.val_ + n) - digamma(x.val_)) * x.d_);
33 
34  }
35 
36  template<typename T>
37  inline
38  fvar<T>
39  log_rising_factorial(const double x, const fvar<T>& n) {
42 
43  return fvar<T>(log_rising_factorial(x,n.val_),
44  (digamma(x + n.val_) * n.d_));
45  }
46  }
47 }
48 #endif
boost::math::tools::promote_args< T1, T2 >::type log_rising_factorial(const T1 x, const T2 n)
fvar< T > digamma(const fvar< T > &x)
Definition: digamma.hpp:16
fvar< T > log_rising_factorial(const fvar< T > &x, const fvar< T > &n)

     [ Stan Home Page ] © 2011–2014, Stan Development Team.