1#ifndef STAN_MATH_PRIM_FUN_TRIGAMMA_HPP
2#define STAN_MATH_PRIM_FUN_TRIGAMMA_HPP
41 double small = 0.0001;
49 double b4 = -
inv(30.0);
50 double b6 =
inv(42.0);
51 double b8 = -
inv(30.0);
55 if (x <= 0.0 &&
floor(x) == x) {
62 if (x <= 0 &&
floor(x) != x) {
84 value += 0.5 * y + (1.0 + y * (b2 + y * (b4 + y * (b6 + y * b8)))) / z;
143 template <
typename T>
144 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.