Stan Math Library  2.20.0
reverse mode automatic differentiation
elt_divide.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_ELT_DIVIDE_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_ELT_DIVIDE_HPP
3 
4 #include <boost/math/tools/promotion.hpp>
7 
8 namespace stan {
9 namespace math {
10 
22 template <typename T1, typename T2, int R, int C>
23 Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type, R, C>
24 elt_divide(const Eigen::Matrix<T1, R, C>& m1,
25  const Eigen::Matrix<T2, R, C>& m2) {
26  check_matching_dims("elt_divide", "m1", m1, "m2", m2);
27 
28  return m1.array() / m2.array();
29 }
30 
43 template <typename T1, typename T2, int R, int C>
44 Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type, R, C>
45 elt_divide(const Eigen::Matrix<T1, R, C>& m, T2 s) {
46  return m.array() / s;
47 }
48 
61 template <typename T1, typename T2, int R, int C>
62 Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type, R, C>
63 elt_divide(T1 s, const Eigen::Matrix<T2, R, C>& m) {
64  return s / m.array();
65 }
66 
67 } // namespace math
68 } // namespace stan
69 #endif
void check_matching_dims(const char *function, const char *name1, const matrix_cl &y1, const char *name2, const matrix_cl &y2)
Check if two matrix_cls have the same dimensions.
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R, C > elt_divide(const Eigen::Matrix< T1, R, C > &m1, const Eigen::Matrix< T2, R, C > &m2)
Return the elementwise division of the specified matrices.
Definition: elt_divide.hpp:24

     [ Stan Home Page ] © 2011–2018, Stan Development Team.