1#ifndef STAN_MATH_OPENCL_REV_VARIANCE_HPP
2#define STAN_MATH_OPENCL_REV_VARIANCE_HPP
23 require_all_kernel_expressions_and_none_scalar_t<T>* =
nullptr>
28 double A_mean =
mean(A.val());
31 auto diff_expr = A.val() - A_mean;
37 [A, diff](
vari& res)
mutable {
38 A.adj() += elt_divide(2.0 * res.adj(), A.size() - 1.0) * diff;
A variant of matrix_cl that schedules its destructor to be called, so it can be used on the AD stack.
Represents an arithmetic matrix on the OpenCL device.
auto sum_2d(T &&a)
Two dimensional sum - reduction of a kernel generator expression.
results_cl< T_results... > results(T_results &&... results)
Deduces types for constructing results_cl object.
elt_divide_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_divide(T_a &&a, T_b &&b)
expressions_cl< T_expressions... > expressions(T_expressions &&... expressions)
Deduces types for constructing expressions_cl object.
auto from_matrix_cl(const T &src)
Copies the source matrix that is stored on the OpenCL device to the destination Eigen matrix.
scalar_type_t< T > mean(const T &m)
Returns the sample mean (i.e., average) of the coefficients in the specified std vector,...
double variance(const T &a)
Return the sample variance of the var_value matrix Raise domain error if size is not greater than zer...
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...
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
fvar< T > square(const fvar< T > &x)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...