Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs 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 
7 #include <stan/meta/traits.hpp>
8 
9 namespace stan {
10  namespace math {
11 
12  template <typename T1, typename T2, typename T_result,
13  class Policy>
14  inline bool check_consistent_sizes(const char* function,
15  const T1& x1,
16  const T2& x2,
17  const char* name1,
18  const char* name2,
19  T_result* result,
20  const Policy&) {
21  size_t max_size = std::max(size_of(x1),
22  size_of(x2));
23  return check_consistent_size(max_size,function,x1,name1,result,Policy())
24  && check_consistent_size(max_size,function,x2,name2,result,Policy());
25  }
26  template <typename T1, typename T2, typename T_result>
27  inline bool check_consistent_sizes(const char* function,
28  const T1& x1,
29  const T2& x2,
30  const char* name1,
31  const char* name2,
32  T_result* result) {
33  return check_consistent_sizes(function,x1,x2,name1,name2,
34  result,default_policy());
35  }
36 
37  template <typename T1, typename T2, typename T3, typename T_result,
38  class Policy>
39  inline bool check_consistent_sizes(const char* function,
40  const T1& x1,
41  const T2& x2,
42  const T3& x3,
43  const char* name1,
44  const char* name2,
45  const char* name3,
46  T_result* result,
47  const Policy&) {
48  size_t max_size = std::max(size_of(x1),
49  std::max(size_of(x2),size_of(x3)));
50  return check_consistent_size(max_size,function,x1,name1,result,Policy())
51  && check_consistent_size(max_size,function,x2,name2,result,Policy())
52  && check_consistent_size(max_size,function,x3,name3,result,Policy());
53  }
54  template <typename T1, typename T2, typename T3, typename T_result>
55  inline bool check_consistent_sizes(const char* function,
56  const T1& x1,
57  const T2& x2,
58  const T3& x3,
59  const char* name1,
60  const char* name2,
61  const char* name3,
62  T_result* result) {
63  return check_consistent_sizes(function,x1,x2,x3,name1,name2,name3,
64  result,default_policy());
65  }
66  template <typename T1, typename T2, typename T3, typename T4,
67  typename T_result,
68  class Policy>
69  inline bool check_consistent_sizes(const char* function,
70  const T1& x1,
71  const T2& x2,
72  const T3& x3,
73  const T4& x4,
74  const char* name1,
75  const char* name2,
76  const char* name3,
77  const char* name4,
78  T_result* result,
79  const Policy&) {
80  size_t max_size = std::max(size_of(x1),
81  std::max(size_of(x2),
82  std::max(size_of(x3), size_of(x4))));
83  return check_consistent_size(max_size,function,x1,name1,result,Policy())
84  && check_consistent_size(max_size,function,x2,name2,result,Policy())
85  && check_consistent_size(max_size,function,x3,name3,result,Policy())
86  && check_consistent_size(max_size,function,x4,name4,result,Policy());
87  }
88  template <typename T1, typename T2, typename T3, typename T4, typename T_result>
89  inline bool check_consistent_sizes(const char* function,
90  const T1& x1,
91  const T2& x2,
92  const T3& x3,
93  const T4& x4,
94  const char* name1,
95  const char* name2,
96  const char* name3,
97  const char* name4,
98  T_result* result) {
99  return check_consistent_sizes(function,x1,x2,x3,x4,
100  name1,name2,name3,name4,
101  result,default_policy());
102  }
103 
104  }
105 }
106 #endif

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