Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
lmgamma.hpp
Go to the documentation of this file.
1 #ifndef __STAN__MATH__FUNCTIONS__LMGAMMA_HPP__
2 #define __STAN__MATH__FUNCTIONS__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 
28  template <typename T>
29  inline typename boost::math::tools::promote_args<T>::type
30  lmgamma(unsigned int k, T x) {
31  using boost::math::lgamma;
32  typename boost::math::tools::promote_args<T>::type result
33  = k * (k - 1) * LOG_PI_OVER_FOUR;
34 
35  for (unsigned int j = 1; j <= k; ++j)
36  result += lgamma(x + (1.0 - j) / 2.0);
37  return result;
38  }
39 
40  }
41 }
42 #endif

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