Stan Math Library  2.8.0
reverse mode automatic differentiation
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
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) {
27  "m1", m1,
28  "m2", m2);
29  Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type,
30  R, C> result(m1.rows(), m2.cols());
31  for (int i = 0; i < m1.size(); ++i)
32  result(i) = m1(i) / m2(i);
33  return result;
34  }
35 
48  template <typename T1, typename T2, int R, int C>
49  Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type, R, C>
50  elt_divide(const Eigen::Matrix<T1, R, C>& m, T2 s) {
51  return m / s;
52  }
53 
66  template <typename T1, typename T2, int R, int C>
67  Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type, R, C>
68  elt_divide(T1 s,
69  const Eigen::Matrix<T2, R, C>& m) {
70  Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type,
71  R, C> result(m.rows(), m.cols());
72  for (int i = 0; i < m.size(); ++i)
73  result(i) = s / m(i);
74  return result;
75  }
76 
77  }
78 }
79 #endif
bool check_matching_dims(const char *function, const char *name1, const Eigen::Matrix< T1, R1, C1 > &y1, const char *name2, const Eigen::Matrix< T2, R2, C2 > &y2)
Return true if the two matrices are of the same size.
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–2015, Stan Development Team.