Stan Math Library  2.20.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 
5 #include <boost/math/tools/promotion.hpp>
8 
9 namespace stan {
10 namespace math {
11 
54 template <typename T>
55 inline typename boost::math::tools::promote_args<T>::type lmgamma(int k, T x) {
56  typename boost::math::tools::promote_args<T>::type result
57  = k * (k - 1) * LOG_PI_OVER_FOUR;
58 
59  for (int j = 1; j <= k; ++j)
60  result += lgamma(x + (1.0 - j) / 2.0);
61  return result;
62 }
63 
64 } // namespace math
65 } // namespace stan
66 #endif
fvar< T > lgamma(const fvar< T > &x)
Return the natural logarithm of the gamma function applied to the specified argument.
Definition: lgamma.hpp:21
const double LOG_PI_OVER_FOUR
Definition: constants.hpp:146
fvar< typename stan::return_type< T, int >::type > lmgamma(int x1, const fvar< T > &x2)
Definition: lmgamma.hpp:13

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