Stan Math Library  2.12.0
reverse mode automatic differentiation
lmgamma.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_LMGAMMA_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_LMGAMMA_HPP
3 
4 #include <boost/math/tools/promotion.hpp>
6 #include <boost/math/special_functions/gamma.hpp>
7 
8 namespace stan {
9  namespace math {
10 
54  template <typename T>
55  inline typename boost::math::tools::promote_args<T>::type
56  lmgamma(const int k, T x) {
57  using boost::math::lgamma;
58  typename boost::math::tools::promote_args<T>::type result
59  = k * (k - 1) * LOG_PI_OVER_FOUR;
60 
61  for (int j = 1; j <= k; ++j)
62  result += lgamma(x + (1.0 - j) / 2.0);
63  return result;
64  }
65 
66  }
67 }
68 #endif
fvar< T > lgamma(const fvar< T > &x)
Definition: lgamma.hpp:14
const double LOG_PI_OVER_FOUR
Log pi divided by 4 .
Definition: constants.hpp:78
fvar< typename stan::return_type< T, int >::type > lmgamma(int x1, const fvar< T > &x2)
Definition: lmgamma.hpp:15

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