Automatic Differentiation
 
Loading...
Searching...
No Matches
apply_scalar_binary.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUNCTOR_APPLY_SCALAR_BINARY_HPP
2#define STAN_MATH_REV_FUNCTOR_APPLY_SCALAR_BINARY_HPP
3
9#include <vector>
10
11namespace stan {
12namespace math {
13
28template <typename T1, typename T2, typename F,
29 require_any_var_matrix_t<T1, T2>* = nullptr,
30 require_all_matrix_t<T1, T2>* = nullptr>
31inline auto apply_scalar_binary(const T1& x, const T2& y, const F& f) {
32 check_matching_dims("Binary function", "x", x, "y", y);
33 return f(x, y);
34}
35
48template <typename T1, typename T2, typename F,
49 require_any_var_matrix_t<T1, T2>* = nullptr,
50 require_any_std_vector_vt<std::is_integral, T1, T2>* = nullptr>
51inline auto apply_scalar_binary(const T1& x, const T2& y, const F& f) {
52 check_matching_sizes("Binary function", "x", x, "y", y);
53 return f(x, y);
54}
55
70template <typename T1, typename T2, typename F,
71 require_any_std_vector_vt<is_std_vector, T1, T2>* = nullptr,
72 require_any_std_vector_st<std::is_integral, T1, T2>* = nullptr,
73 require_any_var_matrix_t<T1, T2>* = nullptr>
74inline auto apply_scalar_binary(const T1& x, const T2& y, const F& f) {
75 return f(x, y);
76}
77
93template <typename T1, typename T2, typename F,
94 require_any_stan_scalar_t<T1, T2>* = nullptr,
95 require_any_var_matrix_t<T1, T2>* = nullptr>
96inline auto apply_scalar_binary(const T1& x, const T2& y, const F& f) {
97 return f(x, y);
98}
99
100} // namespace math
101} // namespace stan
102#endif
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_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 ...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...