-
-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathlgamma_stirling.hpp
More file actions
42 lines (37 loc) · 1.17 KB
/
lgamma_stirling.hpp
File metadata and controls
42 lines (37 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LGAMMA_STIRLING_HPP
#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LGAMMA_STIRLING_HPP
#ifdef STAN_OPENCL
#include <stan/math/opencl/stringify.hpp>
#include <string>
namespace stan {
namespace math {
namespace opencl_kernels {
// \cond
static constexpr const char* lgamma_stirling_device_function
= "\n"
"#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LGAMMA_STIRLING\n"
"#define "
"STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LGAMMA_STIRLING\n" STRINGIFY(
// \endcond
/**
* Return the Stirling approximation to the lgamma function.
*
\f[
\mbox{lgamma_stirling}(x) =
\frac{1}{2} \log(2\pi) + (x-\frac{1}{2})*\log(x) - x
\f]
*
* @param x value
* @return Stirling's approximation to lgamma(x).
*/
double lgamma_stirling(double x) {
return 0.5 * (M_LN2 + log(M_PI)) + (x - 0.5) * log(x) - x;
}
// \cond
) "\n#endif\n"; // NOLINT
// \endcond
} // namespace opencl_kernels
} // namespace math
} // namespace stan
#endif
#endif