1#ifndef STAN_MATH_PRIM_FUN_AS_ARRAY_OR_SCALAR_HPP
2#define STAN_MATH_PRIM_FUN_AS_ARRAY_OR_SCALAR_HPP
18template <
typename T, require_stan_scalar_t<T>* =
nullptr>
20 return std::forward<T>(v);
30template <
typename T, require_stan_scalar_t<T>* =
nullptr>
42template <
typename T, require_eigen_array_t<T>* =
nullptr>
44 return std::forward<T>(v);
54template <
typename T,
typename = require_eigen_t<T>,
55 require_not_eigen_array_t<T>* =
nullptr>
57 return make_holder([](
auto& x) {
return x.array(); }, std::forward<T>(v));
67template <
typename T, require_std_vector_t<T>* =
nullptr,
68 require_not_std_vector_t<value_type_t<T>>* =
nullptr>
71 = Eigen::Map<const Eigen::Array<value_type_t<T>, Eigen::Dynamic, 1>>;
72 return make_holder([](
auto& x) {
return T_map(x.data(), x.size()); },
83template <
typename T, require_std_vector_vt<is_std_vector, T>* =
nullptr,
84 require_std_vector_vt<is_stan_scalar, value_type_t<T>>* =
nullptr>
86 Eigen::Array<scalar_type_t<T>, -1, -1> ret(v.size(), v[0].size());
87 for (
size_t i = 0; i < v.size(); ++i) {
88 ret.row(i) = Eigen::Map<const Eigen::Array<scalar_type_t<T>, 1, -1>>(
89 v[i].data(), v[i].size());
T as_array_or_scalar(T &&v)
Returns specified input value.
auto make_holder(const F &func, Args &&... args)
Constructs an expression from given arguments using given functor.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...