1#ifndef STAN_MATH_REV_FUN_HYPERGEOMETRIC_2F1_HPP
2#define STAN_MATH_REV_FUN_HYPERGEOMETRIC_2F1_HPP
29template <
typename Ta1,
typename Ta2,
typename Tb,
typename Tz,
30 require_all_stan_scalar_t<Ta1, Ta2, Tb, Tz>* =
nullptr,
31 require_any_var_t<Ta1, Ta2, Tb, Tz>* =
nullptr>
43 [a1, a2, b, z](
auto& vi)
mutable {
44 auto grad_tuple =
grad_2F1(a1, a2, b, z);
46 if (!is_constant<Ta1>::value) {
47 forward_as<var>(a1).adj() += vi.adj() * std::get<0>(grad_tuple);
49 if (!is_constant<Ta2>::value) {
50 forward_as<var>(a2).adj() += vi.adj() * std::get<1>(grad_tuple);
52 if (!is_constant<Tb>::value) {
53 forward_as<var>(b).adj() += vi.adj() * std::get<2>(grad_tuple);
55 if (!is_constant<Tz>::value) {
56 forward_as<var>(z).adj() += vi.adj() * std::get<3>(grad_tuple);
var_value< plain_type_t< T > > make_callback_var(T &&value, F &&functor)
Creates a new var initialized with a callback_vari with a given value and reverse-pass callback funct...
T value_of(const fvar< T > &v)
Return the value of the specified variable.
return_type_t< Ta1, Ta1, Tb, Tz > hypergeometric_2F1(const Ta1 &a1, const Ta2 &a2, const Tb &b, const Tz &z)
Returns the Gauss hypergeometric function applied to the input arguments: .
auto grad_2F1(const T1 &a1, const T2 &a2, const T3 &b1, const T_z &z, double precision=1e-14, int max_steps=1e6)
Calculate the gradients of the hypergeometric function (2F1) as the power series stopping when the se...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...