Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
multiply.hpp
Go to the documentation of this file.
1 #ifndef __STAN__MATH__MATRIX__MULTIPLY_HPP__
2 #define __STAN__MATH__MATRIX__MULTIPLY_HPP__
3 
4 #include <stdexcept>
8 
9 namespace stan {
10  namespace math {
11 
20  template <int R, int C>
21  inline
22  Eigen::Matrix<double,R,C>
23  multiply(const Eigen::Matrix<double,R,C>& m,
24  double c) {
25  return c * m;
26  }
35  template <int R, int C>
36  inline
37  Eigen::Matrix<double,R,C>
38  multiply(double c,
39  const Eigen::Matrix<double,R,C>& m) {
40  return c * m;
41  }
42 
43 
54  template<int R1,int C1,int R2,int C2>
55  inline Eigen::Matrix<double,R1,C2> multiply(const Eigen::Matrix<double,R1,C1>& m1,
56  const Eigen::Matrix<double,R2,C2>& m2) {
57 
58  validate_multiplicable(m1,m2,"multiply");
59  return m1*m2;
60  }
61 
71  template<int C1,int R2>
72  inline double multiply(const Eigen::Matrix<double,1,C1>& rv,
73  const Eigen::Matrix<double,R2,1>& v) {
74  stan::math::validate_matching_sizes(rv,v,"multiply");
75  if (rv.size() != v.size())
76  throw std::domain_error("rv.size() != v.size()");
77  return rv.dot(v);
78  }
79 
80  }
81 }
82 #endif

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