1#ifndef STAN_MATH_REV_CORE_DEEP_COPY_VARS_HPP
2#define STAN_MATH_REV_CORE_DEEP_COPY_VARS_HPP
24template <
typename Arith,
typename = require_arithmetic_t<scalar_type_t<Arith>>>
26 return std::forward<Arith>(
arg);
46template <
typename VarVec, require_std_vector_vt<is_var, VarVec>* =
nullptr>
48 std::vector<var> copy_vec(
arg.size());
49 for (
size_t i = 0; i <
arg.size(); ++i) {
50 copy_vec[i] =
new vari(
arg[i].val(),
false);
62template <
typename VecContainer,
66 std::vector<value_type_t<VecContainer>> copy_vec(
arg.size());
67 for (
size_t i = 0; i <
arg.size(); ++i) {
80template <
typename EigT, require_eigen_vt<is_var, EigT>* =
nullptr>
82 return arg.unaryExpr([](
auto&& x) {
return var(
new vari(x.val(),
false)); })
93template <
typename Tuple, require_tuple_t<Tuple>* =
nullptr>
96 [](
auto&&... tuple_args) {
98 deep_copy_vars(std::forward<
decltype(tuple_args)>(tuple_args))...);
100 std::forward<Tuple>(
arg));
require_t< container_type_check_base< is_std_vector, value_type_t, TypeCheck, Check... > > require_std_vector_vt
Require type satisfies is_std_vector.
require_t< container_type_check_base< is_std_vector, scalar_type_t, TypeCheck, Check... > > require_std_vector_st
Require type satisfies is_std_vector.
fvar< T > arg(const std::complex< fvar< T > > &z)
Return the phase angle of the complex argument.
T eval(T &&arg)
Inputs which have a plain_type equal to the own time are forwarded unmodified (for Eigen expressions ...
constexpr auto make_holder_tuple(Types &&... args)
Holds ownership of rvalues and forwards lvalues into a tuple.
vari_value< double > vari
Arith deep_copy_vars(Arith &&arg)
Forward arguments that do not contain vars.
constexpr decltype(auto) apply(F &&f, Tuple &&t, PreArgs &&... pre_args)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...