Automatic Differentiation
 
Loading...
Searching...
No Matches
prod.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_REV_PROD_HPP
2#define STAN_MATH_OPENCL_REV_PROD_HPP
3#ifdef STAN_OPENCL
4
9
10namespace stan {
11namespace math {
12
20template <typename T,
21 require_all_kernel_expressions_and_none_scalar_t<T>* = nullptr>
22inline var prod(const var_value<T>& x) {
23 return make_callback_var(prod(value_of(x)), [x](vari& res) mutable {
24 x.adj() += elt_divide(res.adj() * res.val(), x.val());
25 });
26}
27
28} // namespace math
29} // namespace stan
30
31#endif
32#endif
elt_divide_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_divide(T_a &&a, T_b &&b)
value_type_t< T > prod(const T &m)
Calculates product of given kernel generator expression elements.
Definition prod.hpp:21
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
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...