Automatic Differentiation
 
Loading...
Searching...
No Matches
elt_divide.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_ELT_DIVIDE_HPP
2#define STAN_MATH_PRIM_FUN_ELT_DIVIDE_HPP
3
8
9namespace stan {
10namespace math {
11
22template <typename Mat1, typename Mat2,
23 require_all_eigen_t<Mat1, Mat2>* = nullptr,
24 require_all_not_st_var<Mat1, Mat2>* = nullptr>
25auto elt_divide(const Mat1& m1, const Mat2& m2) {
26 check_matching_dims("elt_divide", "m1", m1, "m2", m2);
27 return (m1.array() / m2.array()).matrix();
28}
29
41template <typename Mat, typename Scal, require_matrix_t<Mat>* = nullptr,
42 require_stan_scalar_t<Scal>* = nullptr>
43auto elt_divide(const Mat& m, Scal s) {
44 return divide(m, s);
45}
46
58template <typename Scal, typename Mat, require_stan_scalar_t<Scal>* = nullptr,
59 require_eigen_t<Mat>* = nullptr>
60auto elt_divide(Scal s, const Mat& m) {
61 return (s / m.array()).matrix();
62}
63
64template <typename Scal1, typename Scal2,
66auto elt_divide(Scal1 s1, Scal2 s2) {
67 return s1 / s2;
68}
69
70} // namespace math
71} // namespace stan
72
73#endif
elt_divide_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_divide(T_a &&a, T_b &&b)
auto divide(T_a &&a, double d)
Returns the elementwise division of the kernel generator expression.
Definition divide.hpp:20
require_all_t< is_stan_scalar< std::decay_t< Types > >... > require_all_stan_scalar_t
Require all of the types satisfy is_stan_scalar.
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.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...