1 #ifndef __STAN__MATH__MATRIX__ADD_HPP__
2 #define __STAN__MATH__MATRIX__ADD_HPP__
4 #include <boost/math/tools/promotion.hpp>
24 template <
typename T1,
typename T2,
int R,
int C>
26 Eigen::Matrix<typename boost::math::tools::promote_args<T1,T2>::type,R,C>
27 add(
const Eigen::Matrix<T1,R,C>& m1,
28 const Eigen::Matrix<T2,R,C>& m2) {
30 Eigen::Matrix<typename boost::math::tools::promote_args<T1,T2>::type,R,C>
31 result(m1.rows(),m1.cols());
32 for (
int i = 0; i < result.size(); ++i)
33 result(i) = m1(i) + m2(i);
46 template <
typename T1,
typename T2,
int R,
int C>
48 Eigen::Matrix<typename boost::math::tools::promote_args<T1,T2>::type,R,C>
49 add(
const Eigen::Matrix<T1,R,C>& m,
51 Eigen::Matrix<typename boost::math::tools::promote_args<T1,T2>::type,R,C>
52 result(m.rows(),m.cols());
53 for (
int i = 0; i < result.size(); ++i)
67 template <
typename T1,
typename T2,
int R,
int C>
69 Eigen::Matrix<typename boost::math::tools::promote_args<T1,T2>::type,R,C>
71 const Eigen::Matrix<T2,R,C>& m) {
72 Eigen::Matrix<typename boost::math::tools::promote_args<T1,T2>::type,R,C>
73 result(m.rows(),m.cols());
74 for (
int i = 0; i < result.size(); ++i)