1 #ifndef STAN_MATH_PRIM_MAT_FUN_ADD_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_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,
32 result(m1.rows(), m1.cols());
33 for (
int i = 0; i < result.size(); ++i)
34 result(i) = m1(i) + m2(i);
47 template <
typename T1,
typename T2,
int R,
int C>
49 Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type, R, C>
50 add(
const Eigen::Matrix<T1, R, C>& m,
52 Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type,
54 result(m.rows(), m.cols());
55 for (
int i = 0; i < result.size(); ++i)
69 template <
typename T1,
typename T2,
int R,
int C>
71 Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type, R, C>
73 const Eigen::Matrix<T2, R, C>& m) {
74 Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type,
76 result(m.rows(), m.cols());
77 for (
int i = 0; i < result.size(); ++i)
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 > add(const Eigen::Matrix< T1, R, C > &m1, const Eigen::Matrix< T2, R, C > &m2)
Return the sum of the specified matrices.