1#ifndef STAN_MATH_REV_FUN_REP_MATRIX_HPP
2#define STAN_MATH_REV_FUN_REP_MATRIX_HPP
23template <
typename Ret,
typename T, require_var_matrix_t<Ret>* =
nullptr,
24 require_var_t<T>* =
nullptr>
25inline auto rep_matrix(
const T& x,
int m,
int n) {
29 value_type_t<Ret>::Constant(m, n, x.val()),
30 [x](
auto& rep)
mutable { x.adj() += rep.adj().sum(); });
43template <
typename Ret,
typename Vec, require_var_matrix_t<Ret>* =
nullptr,
44 require_var_matrix_t<Vec>* =
nullptr>
49 x.adj() += rep.adj().colwise().sum();
54 x.adj() += rep.adj().rowwise().sum();
auto rep_matrix(const value_type_t< T > &x, int n, int m)
Creates a matrix_cl by replicating the given value of arithmetic type.
void check_nonnegative(const char *function, const char *name, const T_y &y)
Check if y is non-negative.
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...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
If the input type T has a static comple time constant type RowsAtCompileTime equal to 1 this has a st...