1#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_TRIGAMMA_HPP
2#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_TRIGAMMA_HPP
10namespace opencl_kernels {
12static constexpr const char* trigamma_device_function
14 "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_TRIGAMMA\n"
15 "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_TRIGAMMA\n" STRINGIFY(
29 if (x <= 0.0 &&
floor(x) == x) {
37 if (x <= 0 &&
floor(x) != x) {
39 double v_sqrt = M_PI / sinpi(-x);
40 value = -v_sqrt * v_sqrt;
44 double small = 0.0001;
48 value = 1.0 / (x * x);
54 value += 1.0 / (z * z);
59 double b2 = 1.0 / 6.0;
60 double b4 = -1.0 / 30.0;
61 double b6 = 1.0 / 42.0;
62 double b8 = -1.0 / 30.0;
66 double y = 1.0 / (z * z);
68 + (1.0 + y * (b2 + y * (b4 + y * (b6 + y * b8)))) / z;
double trigamma(double x)
Return the trigamma function applied to the argument.
fvar< T > floor(const fvar< T > &x)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...