Automatic Differentiation
 
Loading...
Searching...
No Matches
rep_vector.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUN_REP_VECTOR_HPP
2#define STAN_MATH_REV_FUN_REP_VECTOR_HPP
3
9
10namespace stan {
11namespace math {
12
20template <typename T_ret, require_var_matrix_t<T_ret>* = nullptr,
21 require_eigen_col_vector_t<value_type_t<T_ret>>* = nullptr>
22inline auto rep_vector(var x, int n) {
23 return make_callback_var(rep_vector(x.val(), n), [x](auto& vi) mutable {
24 forward_as<var>(x).adj() += vi.adj().sum();
25 });
26}
27
28} // namespace math
29} // namespace stan
30
31#endif
auto rep_vector(const scalar_type_t< T > &x, int n)
Creates a matrix_cl representing a vector by replicating the input value.
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 ...