Stan Math Library  2.20.0
reverse mode automatic differentiation
check_consistent_sizes.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_ERR_CHECK_CONSISTENT_SIZES_HPP
2 #define STAN_MATH_PRIM_SCAL_ERR_CHECK_CONSISTENT_SIZES_HPP
3 
6 #include <algorithm>
7 
8 namespace stan {
9 namespace math {
10 
24 template <typename T1, typename T2>
25 inline void check_consistent_sizes(const char* function, const char* name1,
26  const T1& x1, const char* name2,
27  const T2& x2) {
30  check_consistent_size(function, name1, x1, max_size);
31  check_consistent_size(function, name2, x2, max_size);
32 }
33 
50 template <typename T1, typename T2, typename T3>
51 inline void check_consistent_sizes(const char* function, const char* name1,
52  const T1& x1, const char* name2,
53  const T2& x2, const char* name3,
54  const T3& x3) {
58  check_consistent_size(function, name1, x1, max_size);
59  check_consistent_size(function, name2, x2, max_size);
60  check_consistent_size(function, name3, x3, max_size);
61 }
62 
82 template <typename T1, typename T2, typename T3, typename T4>
83 inline void check_consistent_sizes(const char* function, const char* name1,
84  const T1& x1, const char* name2,
85  const T2& x2, const char* name3,
86  const T3& x3, const char* name4,
87  const T4& x4) {
88  size_t max_size
93  check_consistent_size(function, name1, x1, max_size);
94  check_consistent_size(function, name2, x2, max_size);
95  check_consistent_size(function, name3, x3, max_size);
96  check_consistent_size(function, name4, x4, max_size);
97 }
98 template <typename T1, typename T2, typename T3, typename T4, typename T5>
99 inline void check_consistent_sizes(const char* function, const char* name1,
100  const T1& x1, const char* name2,
101  const T2& x2, const char* name3,
102  const T3& x3, const char* name4,
103  const T4& x4, const char* name5,
104  const T5& x5) {
105  size_t max_size = std::max(
106  size_of(x1),
107  std::max(size_of(x2),
108  std::max(size_of(x3), std::max(size_of(x4), size_of(x5)))));
109  check_consistent_size(function, name1, x1, max_size);
110  check_consistent_size(function, name2, x2, max_size);
111  check_consistent_size(function, name3, x3, max_size);
112  check_consistent_size(function, name4, x4, max_size);
113  check_consistent_size(function, name5, x5, max_size);
114 }
115 
116 } // namespace math
117 } // namespace stan
118 #endif
void check_consistent_size(const char *function, const char *name, const T &x, size_t expected_size)
Check if the dimension of x is consistent, which is defined to be expected_size if x is a vector or 1...
size_t size_of(const T &x)
Returns the size of the provided vector or the constant 1 if the input argument is not a vector...
Definition: size_of.hpp:27
size_t max_size(const T1 &x1, const T2 &x2)
Definition: max_size.hpp:9
int max(const std::vector< int > &x)
Returns the maximum coefficient in the specified column vector.
Definition: max.hpp:21
void check_consistent_sizes(const char *function, const char *name1, const T1 &x1, const char *name2, const T2 &x2)
Check if the dimension of x1 is consistent with x2.

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