1 #ifndef STAN_MATH_PRIM_SCAL_FUN_F32_HPP 2 #define STAN_MATH_PRIM_SCAL_FUN_F32_HPP 51 T
F32(
const T& a1,
const T& a2,
const T& a3,
const T& b1,
const T& b2,
52 const T& z,
double precision = 1
e-6,
int max_steps = 1e5) {
64 for (
int k=0; k <= max_steps; ++k) {
65 T p = (a1 + k) * (a2 + k) * (a3 + k) / ((b1 + k) * (b2 + k) * (k + 1));
70 t_sign = p >= 0.0 ? t_sign : -t_sign;
71 T t_new = t_sign > 0.0 ?
exp(log_t) : -
exp(log_t);
74 if (
fabs(t_new) <= precision)
79 "overflow ",
" hypergeometric function did not converge.");
82 domain_error(
"F32",
"k (internal counter)", max_steps,
"exceeded ",
83 " iterations, hypergeometric function did not converge.");
fvar< T > fabs(const fvar< T > &x)
T F32(const T &a1, const T &a2, const T &a3, const T &b1, const T &b2, const T &z, double precision=1e-6, int max_steps=1e5)
Hypergeometric function (3F2).
void check_3F2_converges(const char *function, const T_a1 &a1, const T_a2 &a2, const T_a3 &a3, const T_b1 &b1, const T_b2 &b2, const T_z &z)
Check if the hypergeometric function (3F2) called with supplied arguments will converge, assuming arguments are finite values.
fvar< T > log(const fvar< T > &x)
fvar< T > exp(const fvar< T > &x)
void domain_error(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.
int is_inf(const fvar< T > &x)
Returns 1 if the input's value is infinite and 0 otherwise.
double e()
Return the base of the natural logarithm.