1#ifndef STAN_MATH_PRIM_FUN_HYPERGEOMETRIC_3F2_HPP
2#define STAN_MATH_PRIM_FUN_HYPERGEOMETRIC_3F2_HPP
19template <
typename Ta,
typename Tb,
typename Tz,
20 typename T_return = return_type_t<Ta, Tb, Tz>,
21 typename ArrayAT = Eigen::Array<scalar_type_t<Ta>, 3, 1>,
22 typename ArrayBT = Eigen::Array<scalar_type_t<Ta>, 3, 1>,
23 require_all_vector_t<Ta, Tb>* =
nullptr,
24 require_stan_scalar_t<Tz>* =
nullptr>
26 double precision = 1
e-6,
27 int max_steps = 1e5) {
31 b_array[0], b_array[1], z);
41 int t_sign = z_sign * a_signs.prod() * b_signs.prod();
44 while (k <= max_steps && log_t >=
log(precision)) {
55 t_acc += t_sign *
exp(log_t);
59 "overflow hypergeometric function did not converge.");
66 t_sign = a_signs.prod() * b_signs.prod() * t_sign;
70 "exceeded iterations, hypergeometric function did not ",
115template <
typename Ta,
typename Tb,
typename Tz,
122 if (z == 1.0 && (
sum(b) -
sum(a)) < 0.0) {
144template <
typename Ta,
typename Tb,
typename Tz,
147 const std::initializer_list<Tb>& b,
const Tz& z) {
select_< as_operation_cl_t< T_condition >, as_operation_cl_t< T_then >, as_operation_cl_t< T_else > > select(T_condition &&condition, T_then &&then, T_else &&els)
Selection operation on kernel generator expressions.
auto append_row(Ta &&a, Tb &&b)
Stack the rows of the first argument on top of the second argument.
auto to_vector(T_x &&x)
Returns input matrix reshaped into a vector.
require_all_t< is_stan_scalar< std::decay_t< Types > >... > require_all_stan_scalar_t
Require all of the types satisfy is_stan_scalar.
require_t< is_stan_scalar< std::decay_t< T > > > require_stan_scalar_t
Require type satisfies is_stan_scalar.
require_all_t< is_vector< std::decay_t< Types > >... > require_all_vector_t
Require all of the types satisfy is_vector.
T_return hypergeometric_3F2_infsum(const Ta &a, const Tb &b, const Tz &z, double precision=1e-6, int max_steps=1e5)
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
auto hypergeometric_3F2(const Ta &a, const Tb &b, const Tz &z)
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,...
T as_array_or_scalar(T &&v)
Returns specified input value.
static constexpr double e()
Return the base of the natural logarithm.
auto sign(const T &x)
Returns signs of the arguments.
fvar< T > log(const fvar< T > &x)
static constexpr double NEGATIVE_INFTY
Negative infinity.
void throw_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.
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
FvarT hypergeometric_pFq(const Ta &a, const Tb &b, const Tz &z)
Returns the generalized hypergeometric (pFq) function applied to the input arguments.
int is_inf(const fvar< T > &x)
Returns 1 if the input's value is infinite and 0 otherwise.
fvar< T > fabs(const fvar< T > &x)
fvar< T > exp(const fvar< T > &x)
typename plain_type< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...