Stan Math Library  2.20.0
reverse mode automatic differentiation
subtract.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_SUBTRACT_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_SUBTRACT_HPP
3 
4 #include <boost/math/tools/promotion.hpp>
7 
8 namespace stan {
9 namespace math {
10 
24 template <typename T1, typename T2, int R, int C>
25 inline Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type, R,
26  C>
27 subtract(const Eigen::Matrix<T1, R, C>& m1, const Eigen::Matrix<T2, R, C>& m2) {
28  check_matching_dims("subtract", "m1", m1, "m2", m2);
29  return m1 - m2;
30 }
31 
32 template <typename T1, typename T2, int R, int C>
33 inline Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type, R,
34  C>
35 subtract(const T1& c, const Eigen::Matrix<T2, R, C>& m) {
36  return c - m.array();
37 }
38 
39 template <typename T1, typename T2, int R, int C>
40 inline Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type, R,
41  C>
42 subtract(const Eigen::Matrix<T1, R, C>& m, const T2& c) {
43  return m.array() - c;
44 }
45 
46 } // namespace math
47 } // namespace stan
48 #endif
auto subtract(const matrix_cl &A, const matrix_cl &B)
Matrix subtraction on the OpenCL device Subtracts the second matrix from the first matrix and stores ...
Definition: subtract.hpp:28
void check_matching_dims(const char *function, const char *name1, const matrix_cl &y1, const char *name2, const matrix_cl &y2)
Check if two matrix_cls have the same dimensions.

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