1#ifndef STAN_MATH_PRIM_FUNCTOR_APPLY_VECTOR_UNARY_HPP
2#define STAN_MATH_PRIM_FUNCTOR_APPLY_VECTOR_UNARY_HPP
16template <
typename T,
typename Enable =
void>
43 template <
typename F,
typename T2 = T,
45 static inline auto apply(
const T& x,
const F& f) {
46 return make_holder([](
const auto& a) {
return a.matrix().derived(); },
50 template <
typename F,
typename T2 = T,
52 static inline auto apply(
const T& x,
const F& f) {
53 return make_holder([](
const auto& a) {
return a.array().derived(); }, f(x));
68 template <
typename F,
typename T2 = T,
71 return f(x).matrix().derived();
74 template <
typename F,
typename T2 = T,
77 return f(x).array().derived();
92 static inline auto reduce(
const T& x,
const F& f) {
109 using T_map =
typename Eigen::Map<
const Eigen::Matrix<
T_vt, -1, 1>>;
121 template <
typename F>
122 static inline auto apply(
const T& x,
const F& f) {
124 std::vector<T_return> result(x.size());
125 Eigen::Map<Eigen::Matrix<T_return, -1, 1>>(result.data(), result.size())
141 template <
typename F>
156 template <
typename F>
157 static inline auto reduce(
const T& x,
const F& f) {
188 template <
typename F>
189 static inline auto apply(
const T& x,
const F& f) {
192 std::vector<T_return> result(x.size());
193 std::transform(x.begin(), x.end(), result.begin(), [&f](
auto&& xx) {
194 return apply_vector_unary<T_vt>::apply_no_holder(xx, f);
210 template <
typename F>
225 template <
typename F>
226 static inline auto reduce(
const T& x,
const F& f) {
227 size_t x_size = x.size();
229 std::vector<T_return> result(x_size);
230 for (
size_t i = 0; i < x_size; ++i)
require_t< is_eigen< std::decay_t< T > > > require_eigen_t
Require type satisfies is_eigen.
auto as_column_vector_or_scalar(T &&a)
as_column_vector_or_scalar of a kernel generator expression.
require_t< container_type_check_base< is_std_vector, value_type_t, TypeCheck, Check... > > require_std_vector_vt
Require type satisfies is_std_vector.
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
auto make_holder(const F &func, Args &&... args)
Constructs an expression from given arguments using given functor.
constexpr decltype(auto) apply(F &&f, Tuple &&t, PreArgs &&... pre_args)
typename plain_type< T >::type plain_type_t
bool_constant< math::disjunction< is_container< Container >, is_var_matrix< Container > >::value > is_container_or_var_matrix
Deduces whether type is eigen matrix, standard vector, or var<Matrix>.
std::enable_if_t< Check::value > require_t
If condition is true, template is enabled.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Checks if decayed type is a var, fvar, or arithmetic.
static auto reduce(const T &x, const F &f)
Member function for applying a functor to a vector and subsequently returning a scalar.
static auto apply(const T &x, const F &f)
Member function for applying a functor to a vector and subsequently returning a vector.
static auto apply_no_holder(const T &x, const F &f)
Member function for applying a functor to a vector and subsequently returning a vector.
static auto reduce(const T &x, const F &f)
Member function for applying a functor to each container in an std::vector and subsequently returning...
static auto apply(const T &x, const F &f)
Member function for applying a functor to each container in an std::vector and subsequently returning...
static auto apply_no_holder(const T &x, const F &f)
Member function for applying a functor to each container in an std::vector and subsequently returning...
static auto apply(const T &x, const F &f)
Member function for applying a functor to a vector and subsequently returning a vector.
static auto apply_no_holder(const T &x, const F &f)
Member function for applying a functor to each container in an std::vector and subsequently returning...
typename Eigen::Map< const Eigen::Matrix< T_vt, -1, 1 > > T_map
static auto reduce(const T &x, const F &f)
Member function for applying a functor to a vector and subsequently returning a scalar.