1#ifndef STAN_MATH_REV_FUN_TO_ARENA_HPP
2#define STAN_MATH_REV_FUN_TO_ARENA_HPP
25template <
typename T, require_not_same_t<T, arena_t<T>>* =
nullptr,
26 require_not_container_t<T>* =
nullptr,
27 require_not_matrix_cl_t<T>* =
nullptr>
29 return std::forward<T>(a);
46template <
typename T, require_same_t<T, arena_t<T>>* =
nullptr,
47 require_not_matrix_cl_t<T>* =
nullptr,
48 require_not_std_vector_t<T>* =
nullptr>
49inline std::remove_reference_t<T>
to_arena(T&& a) {
52 return std::forward<T>(a);
65template <
typename T, require_eigen_t<T>* =
nullptr,
66 require_not_same_t<T, arena_t<T>>* =
nullptr>
82inline std::vector<T, arena_allocator<T>>
to_arena(
88 std::vector<T, arena_allocator<T>> res;
89 std::memcpy(
static_cast<void*
>(&res),
static_cast<const void*
>(&a),
108template <
typename T, require_same_t<T, arena_t<T>>* =
nullptr>
110 return {a.begin(), a.end()};
126template <
typename T, require_not_same_t<T, arena_t<T>>* =
nullptr>
129 res.reserve(a.size());
130 for (
const T& i : a) {
144template <
bool Condition,
typename T, std::enable_if_t<!Condition>* =
nullptr>
146 return std::forward<T>(a);
149template <
bool Condition,
typename T, std::enable_if_t<Condition>* =
nullptr>
arena_t< T > to_arena(const T &a)
Converts given argument into a type that either has any dynamic allocation on AD stack or schedules i...
T to_arena_if(T &&a)
If the condition is true, converts given argument into a type that has any dynamic allocation on AD s...
typename internal::arena_type_impl< std::decay_t< T > >::type arena_t
Determines a type that can be used in place of T that does any dynamic allocations on the AD stack.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
std library compatible allocator that uses AD stack.