| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

multiply.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_MULTIPLY_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_MULTIPLY_HPP
3
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5 #include <stan/math/prim/arr/err/check_matching_sizes.hpp>
6 #include <stan/math/prim/mat/err/check_multiplicable.hpp>
7 #include <boost/type_traits/is_arithmetic.hpp>
8 #include <boost/utility/enable_if.hpp>
9
10 namespace stan {
11 namespace math {
12
21 template <int R, int C, typename T>
22 inline
23 typename boost::enable_if_c<boost::is_arithmetic<T>::value,
24 Eigen::Matrix<double, R, C> >::type
25 multiply(const Eigen::Matrix<double, R, C>& m,
26 T c) {
27 return c * m;
28 }
29
38 template <int R, int C, typename T>
39 inline
40 typename boost::enable_if_c<boost::is_arithmetic<T>::value,
41 Eigen::Matrix<double, R, C> >::type
42 multiply(T c,
43 const Eigen::Matrix<double, R, C>& m) {
44 return c * m;
45 }
46
57 template<int R1, int C1, int R2, int C2>
58 inline Eigen::Matrix<double, R1, C2>
59 multiply(const Eigen::Matrix<double, R1, C1>& m1,
60 const Eigen::Matrix<double, R2, C2>& m2) {
61 check_multiplicable("multiply",
62 "m1", m1,
63 "m2", m2);
64 return m1*m2;
65 }
66
76 template<int C1, int R2>
77 inline double multiply(const Eigen::Matrix<double, 1, C1>& rv,
78 const Eigen::Matrix<double, R2, 1>& v) {
79 check_matching_sizes("multiply",
80 "rv", rv,
81 "v", v);
82 return rv.dot(v);
83 }
84
85 }
86 }
87 #endif
check_multiplicable.hpp
stan
Definition: log_sum_exp.hpp:8
stan::math::multiply
Eigen::Matrix< fvar< T >, R1, C1 > multiply(const Eigen::Matrix< fvar< T >, R1, C1 > &m, const fvar< T > &c)
Definition: multiply.hpp:20
check_matching_sizes.hpp
stan::math::check_multiplicable
bool check_multiplicable(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Return true if the matrices can be multiplied.
Definition: check_multiplicable.hpp:32
stan::math::check_matching_sizes
bool check_matching_sizes(const char *function, const char *name1, const T_y1 &y1, const char *name2, const T_y2 &y2)
Return true if two structures at the same size.
Definition: check_matching_sizes.hpp:29
Eigen.hpp

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