| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
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
4 #include <stan/math/prim/scal/err/check_consistent_size.hpp>
5
6 #include <algorithm>
7
8 namespace stan {
9 namespace math {
10
30 template <typename T1, typename T2>
31 inline bool check_consistent_sizes(const char* function,
32 const char* name1,
33 const T1& x1,
34 const char* name2,
35 const T2& x2) {
36 using stan::is_vector;
37 size_t max_size = std::max(is_vector<T1>::value * size_of(x1),
38 is_vector<T2>::value * size_of(x2));
39 return check_consistent_size(function, name1, x1, max_size)
40 && check_consistent_size(function, name2, x2, max_size);
41 }
42
65 template <typename T1, typename T2, typename T3>
66 inline bool check_consistent_sizes(const char* function,
67 const char* name1,
68 const T1& x1,
69 const char* name2,
70 const T2& x2,
71 const char* name3,
72 const T3& x3) {
73 size_t max_size = std::max(is_vector<T1>::value * size_of(x1),
74 std::max(is_vector<T2>::value * size_of(x2),
75 is_vector<T3>::value * size_of(x3)));
76 return check_consistent_size(function, name1, x1, max_size)
77 && check_consistent_size(function, name2, x2, max_size)
78 && check_consistent_size(function, name3, x3, max_size);
79 }
80
106 template <typename T1, typename T2, typename T3, typename T4>
107 inline bool check_consistent_sizes(const char* function,
108 const char* name1,
109 const T1& x1,
110 const char* name2,
111 const T2& x2,
112 const char* name3,
113 const T3& x3,
114 const char* name4,
115 const T4& x4) {
116 size_t max_size
117 = std::max(is_vector<T1>::value * size_of(x1),
118 std::max(is_vector<T2>::value * size_of(x2),
119 std::max(is_vector<T3>::value * size_of(x3),
120 is_vector<T4>::value * size_of(x4))));
121 return check_consistent_size(function, name1, x1, max_size)
122 && check_consistent_size(function, name2, x2, max_size)
123 && check_consistent_size(function, name3, x3, max_size)
124 && check_consistent_size(function, name4, x4, max_size);
125 }
126 template <typename T1, typename T2, typename T3, typename T4,
127 typename T5>
128 inline bool check_consistent_sizes(const char* function,
129 const char* name1,
130 const T1& x1,
131 const char* name2,
132 const T2& x2,
133 const char* name3,
134 const T3& x3,
135 const char* name4,
136 const T4& x4,
137 const char* name5,
138 const T5& x5) {
139 size_t max_size = std::max(size_of(x1),
140 std::max(size_of(x2),
141 std::max(size_of(x3),
142 std::max(size_of(x4),
143 size_of(x5)))));
144 return check_consistent_size(function, name1, x1, max_size)
145 && check_consistent_size(function, name2, x2, max_size)
146 && check_consistent_size(function, name3, x3, max_size)
147 && check_consistent_size(function, name4, x4, max_size)
148 && check_consistent_size(function, name5, x5, max_size);
149 }
150
151 }
152 }
153 #endif
check_consistent_size.hpp
stan::is_vector
Definition: is_vector.hpp:10
stan::math::check_consistent_size
bool check_consistent_size(const char *function, const char *name, const T &x, size_t expected_size)
Return true if the dimension of x is consistent, which is defined to be expected_size if x is a vecto...
Definition: check_consistent_size.hpp:29
stan::size_of
size_t size_of(const T &x)
Definition: size_of.hpp:27
stan::max_size
size_t max_size(const T1 &x1, const T2 &x2)
Definition: max_size.hpp:9
stan::math::max
int max(const std::vector< int > &x)
Returns the maximum coefficient in the specified column vector.
Definition: max.hpp:21
stan::math::check_consistent_sizes
bool check_consistent_sizes(const char *function, const char *name1, const T1 &x1, const char *name2, const T2 &x2)
Return true if the dimension of x1 is consistent with x2.
Definition: check_consistent_sizes.hpp:31

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