1 #ifndef STAN_MATH_PRIM_MAT_FUN_SUBTRACT_HPP 2 #define STAN_MATH_PRIM_MAT_FUN_SUBTRACT_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>
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);
38 template <
typename T1,
typename T2,
int R,
int C>
40 Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type, R, C>
42 const Eigen::Matrix<T2, R, C>& m) {
43 Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type,
45 result(m.rows(), m.cols());
46 for (
int i = 0; i < m.size(); ++i)
51 template <
typename T1,
typename T2,
int R,
int C>
53 Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type, R, C>
56 Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type,
58 result(m.rows(), m.cols());
59 for (
int i = 0; i < m.size(); ++i)
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R, C > subtract(const Eigen::Matrix< T1, R, C > &m1, const Eigen::Matrix< T2, R, C > &m2)
Return the result of subtracting the second specified matrix from the first specified matrix...
void 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)
Check if the two matrices are of the same size.