1#ifndef STAN_MATH_PRIM_FUN_TRIGAMMA_HPP
2#define STAN_MATH_PRIM_FUN_TRIGAMMA_HPP
38 double small = 0.0001;
46 double b4 = -
inv(30.0);
47 double b6 =
inv(42.0);
48 double b8 = -
inv(30.0);
52 if (x <= 0.0 &&
floor(x) == x) {
59 if (x <= 0 &&
floor(x) != x) {
81 value += 0.5 * y + (1.0 + y * (b2 + y * (b4 + y * (b6 + y * b8)))) / z;
140 template <
typename T>
141 static inline auto fun(
const T& x) {
require_not_t< is_nonscalar_prim_or_rev_kernel_expression< std::decay_t< T > > > require_not_nonscalar_prim_or_rev_kernel_expression_t
Require type does not satisfy is_nonscalar_prim_or_rev_kernel_expression.
fvar< T > sin(const fvar< T > &x)
static constexpr double positive_infinity()
Return positive infinity.
fvar< T > inv_square(const fvar< T > &x)
T trigamma_impl(const T &x)
Return the trigamma function applied to the argument.
fvar< T > trigamma(const fvar< T > &u)
Return the value of the trigamma function at the specified argument (i.e., the second derivative of t...
fvar< T > floor(const fvar< T > &x)
static constexpr double pi()
Return the value of pi.
fvar< T > inv(const fvar< T > &x)
fvar< T > square(const fvar< T > &x)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Base template class for vectorization of unary scalar functions defined by a template class F to a sc...
static auto fun(const T &x)
Return the trigamma() function applied to the argument.
Structure to wrap trigamma() so it can be vectorized.