1#ifndef STAN_MATH_REV_CORE_SAVE_VARIS_HPP
2#define STAN_MATH_REV_CORE_SAVE_VARIS_HPP
15template <
typename... Pargs>
18template <
typename VarVec, require_std_vector_vt<is_var, VarVec>* =
nullptr,
22template <
typename VecContainer,
23 require_std_vector_st<is_var, VecContainer>* =
nullptr,
24 require_std_vector_vt<is_container, VecContainer>* =
nullptr,
28template <
typename EigT, require_eigen_vt<is_var, EigT>* =
nullptr,
32template <
typename Arith, require_st_arithmetic<Arith>* =
nullptr,
50template <
typename... Pargs>
53 return save_varis(dest + 1, std::forward<Pargs>(args)...);
69template <
typename VarVec, require_std_vector_vt<is_var, VarVec>*,
72 for (
int i = 0; i < x.size(); ++i) {
75 return save_varis(dest + x.size(), std::forward<Pargs>(args)...);
91template <
typename VecContainer, require_std_vector_st<is_var, VecContainer>*,
92 require_std_vector_vt<is_container, VecContainer>*,
typename... Pargs>
94 for (
size_t i = 0; i < x.size(); ++i) {
97 return save_varis(dest, std::forward<Pargs>(args)...);
113template <
typename EigT, require_eigen_vt<is_var, EigT>*,
typename... Pargs>
115 for (
int i = 0; i < x.size(); ++i) {
116 dest[i] = x.coeff(i).vi_;
118 return save_varis(dest + x.size(), std::forward<Pargs>(args)...);
134template <
typename Arith, require_st_arithmetic<Arith>*,
typename... Pargs>
136 return save_varis(dest, std::forward<Pargs>(args)...);
vari_value< double > vari
vari ** save_varis(vari **dest, const var &x, Pargs &&... args)
Save the vari pointer in x into the memory pointed to by dest, increment the dest storage pointer,...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...