Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
validate_matching_dims.hpp
Go to the documentation of this file.
1 #ifndef __STAN__MATH__MATRIX__VALIDATE_MATCHING_DIMS_HPP__
2 #define __STAN__MATH__MATRIX__VALIDATE_MATCHING_DIMS_HPP__
3 
4 #include <sstream>
5 #include <stdexcept>
7 
8 namespace stan {
9  namespace math {
10 
11  template <typename T1, int R1, int C1, typename T2, int R2, int C2>
12  inline void validate_matching_dims(const Eigen::Matrix<T1,R1,C1>& x1,
13  const Eigen::Matrix<T2,R2,C2>& x2,
14  const char* msg) {
15  if (x1.rows() == x2.rows()
16  && x1.cols() == x2.cols()) return;
17  std::stringstream ss;
18  ss << "error in call to " << msg
19  << "; require matching dimensions, but found"
20  << " arg1(rows=" << x1.rows() << ",cols=" << x1.cols() << ");"
21  << " arg2(rows=" << x2.rows() << ",cols=" << x2.cols() << ")";
22  throw std::domain_error(ss.str());
23  }
24 
25  }
26 }
27 #endif

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