1#ifndef STAN_MATH_PRIM_FUNCTOR_APPLY_SCALAR_TERNARY_HPP
2#define STAN_MATH_PRIM_FUNCTOR_APPLY_SCALAR_TERNARY_HPP
37template <
typename F,
typename T1,
typename T2,
typename T3,
38 require_all_stan_scalar_t<T1, T2, T3>* =
nullptr>
59template <
typename F,
typename T1,
typename T2,
typename T3,
65 [](
auto&& f_inner,
auto&& x_inner,
auto&& y_inner,
auto&& z_inner) {
66 return Eigen::CwiseTernaryOp<
67 std::decay_t<
decltype(f_inner)>, std::decay_t<
decltype(x_inner)>,
68 std::decay_t<
decltype(y_inner)>, std::decay_t<
decltype(z_inner)>>(
69 x_inner, y_inner, z_inner, f_inner);
71 std::forward<F>(f), std::forward<T1>(x), std::forward<T2>(y),
94template <
typename F,
typename T1,
typename T2,
typename T3,
103 using T_return = std::decay_t<
decltype(f(x[0], y[0], z[0]))>;
104 std::vector<T_return> result(x.size());
105 Eigen::Map<Eigen::Matrix<T_return, -1, 1>>(result.data(), result.size())
126template <
typename F,
typename T1,
typename T2,
typename T3,
135 size_t y_size = y.size();
136 std::vector<T_return> result(y_size);
137 for (
size_t i = 0; i < y_size; ++i) {
159template <
typename F,
typename T1,
typename T2,
typename T3,
160 require_any_container_t<T1, T2>* =
nullptr,
161 require_stan_scalar_t<T3>* =
nullptr>
165 x, y, [f, z](
const auto& a,
const auto& b) {
return f(a, b, z); });
184template <
typename F,
typename T1,
typename T2,
typename T3,
190 x, z, [f, y](
const auto& a,
const auto& c) {
return f(a, y, c); });
209template <
typename F,
typename T1,
typename T2,
typename T3,
210 require_container_t<T3>* =
nullptr,
211 require_stan_scalar_t<T1>* =
nullptr>
215 y, z, [f, x](
const auto& b,
const auto& c) {
return f(x, b, c); });
require_all_t< is_container< std::decay_t< Types > >... > require_all_container_t
Require all of the types satisfy is_container.
require_all_t< is_eigen< std::decay_t< Types > >... > require_all_eigen_t
Require all of the types satisfy is_eigen.
auto as_column_vector_or_scalar(T &&a)
as_column_vector_or_scalar of a kernel generator expression.
require_t< is_stan_scalar< std::decay_t< T > > > require_stan_scalar_t
Require type satisfies is_stan_scalar.
require_all_t< container_type_check_base< is_std_vector, value_type_t, TypeCheck, Check >... > require_all_std_vector_vt
Require all of the types satisfy is_std_vector.
auto make_holder(const F &func, Args &&... args)
Constructs an expression from given arguments using given functor.
void check_matching_dims(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Check if the two containers have the same dimensions.
void check_matching_sizes(const char *function, const char *name1, const T_y1 &y1, const char *name2, const T_y2 &y2)
Check if two structures at the same size.
auto apply_scalar_ternary(const F &f, const T1 &x, const T2 &y, const T3 &z)
Base template function for vectorization of ternary scalar functions defined by applying a functor to...
auto apply_scalar_binary(const T1 &x, const T2 &y, const F &f)
Base template function for vectorization of binary scalar functions defined by applying a functor to ...
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>.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...