Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
check_consistent_sizes.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__ERROR_HANDLING__CHECK_CONSISTENT_SIZES_HPP
2 #define STAN__MATH__ERROR_HANDLING__CHECK_CONSISTENT_SIZES_HPP
3 
6 #include <stan/meta/traits.hpp>
7 
8 namespace stan {
9  namespace math {
10 
11  // NOTE: this will not throw if nan is passed in.
12  template <typename T1, typename T2, typename T_result>
13  inline bool check_consistent_sizes(const char* function,
14  const T1& x1,
15  const T2& x2,
16  const char* name1,
17  const char* name2,
18  T_result* result) {
19  size_t max_size = std::max(size_of(x1),
20  size_of(x2));
21  return check_consistent_size(max_size,function,x1,name1,result)
22  && check_consistent_size(max_size,function,x2,name2,result);
23  }
24 
25  template <typename T1, typename T2, typename T3, typename T_result>
26  inline bool check_consistent_sizes(const char* function,
27  const T1& x1,
28  const T2& x2,
29  const T3& x3,
30  const char* name1,
31  const char* name2,
32  const char* name3,
33  T_result* result) {
34  size_t max_size = std::max(size_of(x1),
35  std::max(size_of(x2),size_of(x3)));
36  return check_consistent_size(max_size,function,x1,name1,result)
37  && check_consistent_size(max_size,function,x2,name2,result)
38  && check_consistent_size(max_size,function,x3,name3,result);
39  }
40  template <typename T1, typename T2, typename T3, typename T4, typename T_result>
41  inline bool check_consistent_sizes(const char* function,
42  const T1& x1,
43  const T2& x2,
44  const T3& x3,
45  const T4& x4,
46  const char* name1,
47  const char* name2,
48  const char* name3,
49  const char* name4,
50  T_result* result) {
51  size_t max_size = std::max(size_of(x1),
52  std::max(size_of(x2),
53  std::max(size_of(x3), size_of(x4))));
54  return check_consistent_size(max_size,function,x1,name1,result)
55  && check_consistent_size(max_size,function,x2,name2,result)
56  && check_consistent_size(max_size,function,x3,name3,result)
57  && check_consistent_size(max_size,function,x4,name4,result);
58  }
59 
60  }
61 }
62 #endif
double max(const double a, const double b)
Definition: max.hpp:7
bool check_consistent_size(size_t max_size, const char *function, const T &x, const char *name, T_result *result)
size_t size_of(const T &x)
Definition: traits.hpp:186
bool check_consistent_sizes(const char *function, const T1 &x1, const T2 &x2, const char *name1, const char *name2, T_result *result)
size_t max_size(const T1 &x1, const T2 &x2)
Definition: traits.hpp:191

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