1#ifndef STAN_MATH_REV_FUN_HYPERGEOMETRIC_PFQ_HPP
2#define STAN_MATH_REV_FUN_HYPERGEOMETRIC_PFQ_HPP
25template <
typename Ta,
typename Tb,
typename Tz,
26 require_all_vector_t<Ta, Tb>* =
nullptr,
27 require_return_type_t<is_var, Ta, Tb, Tz>* =
nullptr>
29 constexpr bool grad_a = is_autodiff_v<Ta>;
30 constexpr bool grad_b = is_autodiff_v<Tb>;
31 constexpr bool grad_z = is_autodiff_v<Tz>;
37 pfq_val, [arena_a, arena_b, z, pfq_val](
auto& vi)
mutable {
38 auto grad_tuple = grad_pFq<grad_a, grad_b, grad_z>(
39 pfq_val, arena_a.val(), arena_b.val(),
value_of(z));
40 if constexpr (grad_a) {
41 arena_a.adj() += vi.adj() * std::get<0>(grad_tuple);
43 if constexpr (grad_b) {
44 arena_b.adj() += vi.adj() * std::get<1>(grad_tuple);
46 if constexpr (grad_z) {
47 z.adj() += vi.adj() * std::get<2>(grad_tuple);
auto as_column_vector_or_scalar(T &&a)
as_column_vector_or_scalar of a kernel generator expression.
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.
arena_t< T > to_arena(const T &a)
Converts given argument into a type that either has any dynamic allocation on AD stack or schedules i...
FvarT hypergeometric_pFq(Ta &&a, Tb &&b, Tz &&z)
Returns the generalized hypergeometric (pFq) function applied to the input arguments.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...