Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
elt_multiply.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__MATRIX__ELT_MULTIPLY_HPP
2 #define STAN__MATH__MATRIX__ELT_MULTIPLY_HPP
3 
4 #include <boost/math/tools/promotion.hpp>
7 
8 namespace stan {
9  namespace math {
10 
23  template <typename T1, typename T2, int R, int C>
24  Eigen::Matrix<typename boost::math::tools::promote_args<T1,T2>::type, R, C>
25  elt_multiply(const Eigen::Matrix<T1,R,C>& m1,
26  const Eigen::Matrix<T2,R,C>& m2) {
27  stan::math::check_matching_dims("elt_multiply(%1%)",m1,"m1",
28  m2,"m2",(double*)0);
29  Eigen::Matrix<typename boost::math::tools::promote_args<T1,T2>::type, R, C>
30  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 
36  }
37 }
38 #endif
bool check_matching_dims(const char *function, const Eigen::Matrix< T1, R1, C1 > &y1, const char *name1, const Eigen::Matrix< T2, R2, C2 > &y2, const char *name2, T_result *result)
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R, C > elt_multiply(const Eigen::Matrix< T1, R, C > &m1, const Eigen::Matrix< T2, R, C > &m2)
Return the elementwise multiplication of the specified matrices.

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