Stan Math Library: stan/math/prim/scal/fun/lmgamma.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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>
5 #include <stan/math/prim/scal/fun/constants.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
stan::math::lgamma
fvar< T > lgamma(const fvar< T > &x)
Definition: lgamma.hpp:15
stan
Definition: log_sum_exp.hpp:8
stan::math::LOG_PI_OVER_FOUR
const double LOG_PI_OVER_FOUR
Log pi divided by 4 .
Definition: constants.hpp:79
constants.hpp
stan::math::lmgamma
fvar< typename stan::return_type< T, int >::type > lmgamma(int x1, const fvar< T > &x2)
Definition: lmgamma.hpp:16

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