Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
check_size_match.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_SIZE_MATCH_HPP
2 #define STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_SIZE_MATCH_HPP
3 
4 #include <sstream>
5 #include <boost/type_traits/common_type.hpp>
7 
8 namespace stan {
9  namespace math {
10 
11  // FIXME: update warnings
12  template <typename T_size1, typename T_size2, typename T_result>
13  inline bool check_size_match(const char* function,
14  T_size1 i,
15  const char* name_i,
16  T_size2 j,
17  const char* name_j,
18  T_result* result) {
19  typedef typename boost::common_type<T_size1,T_size2>::type common_type;
20  if (static_cast<common_type>(i) == static_cast<common_type>(j))
21  return true;
22 
23  std::ostringstream msg;
24  msg << name_i << " (%1%) and "
25  << name_j << " (" << j << ") must match in size";
26  std::string tmp(msg.str());
27  return dom_err(function,i,name_i,
28  tmp.c_str(),"",
29  result);
30  }
31 
32  }
33 }
34 #endif
bool dom_err(const char *function, const T &y, const char *name, const char *error_msg, const T_msg error_msg2, T_result *result)
Definition: dom_err.hpp:36
bool check_size_match(const char *function, T_size1 i, const char *name_i, T_size2 j, const char *name_j, T_result *result)

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