Stan Math Library  2.8.0
reverse mode automatic differentiation
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
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 
10  namespace math {
11 
55  template <typename T>
56  inline typename boost::math::tools::promote_args<T>::type
57  lmgamma(const int k, T x) {
58  using boost::math::lgamma;
59  typename boost::math::tools::promote_args<T>::type result
60  = k * (k - 1) * LOG_PI_OVER_FOUR;
61 
62  for (int j = 1; j <= k; ++j)
63  result += lgamma(x + (1.0 - j) / 2.0);
64  return result;
65  }
66 
67  }
68 }
69 #endif
fvar< T > lgamma(const fvar< T > &x)
Definition: lgamma.hpp:15
const double LOG_PI_OVER_FOUR
Log pi divided by 4 .
Definition: constants.hpp:79
fvar< typename stan::return_type< T, int >::type > lmgamma(int x1, const fvar< T > &x2)
Definition: lmgamma.hpp:16

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