Automatic Differentiation
 
Loading...
Searching...
No Matches
hypergeometric_1F0.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUN_HYPERGEOMETRIC_1F0_HPP
2#define STAN_MATH_REV_FUN_HYPERGEOMETRIC_1F0_HPP
3
10
11namespace stan {
12namespace math {
13
31template <typename Ta, typename Tz,
32 require_all_stan_scalar_t<Ta, Tz>* = nullptr,
33 require_any_var_t<Ta, Tz>* = nullptr>
34var hypergeometric_1f0(const Ta& a, const Tz& z) {
35 double a_val = value_of(a);
36 double z_val = value_of(z);
37 double rtn = hypergeometric_1f0(a_val, z_val);
38 return make_callback_var(rtn, [rtn, a, z, a_val, z_val](auto& vi) mutable {
40 forward_as<var>(a).adj() += vi.adj() * -rtn * log1m(z_val);
41 }
43 forward_as<var>(z).adj() += vi.adj() * rtn * a_val * inv(1 - z_val);
44 }
45 });
46}
47
48} // namespace math
49} // namespace stan
50#endif
FvarT hypergeometric_1f0(const Ta &a, const Tz &z)
Returns the Hypergeometric 1F0 function applied to the input arguments: .
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.
Definition value_of.hpp:18
fvar< T > log1m(const fvar< T > &x)
Definition log1m.hpp:12
fvar< T > inv(const fvar< T > &x)
Definition inv.hpp:12
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Extends std::true_type when instantiated with zero or more template parameters, all of which extend t...