Automatic Differentiation
 
Loading...
Searching...
No Matches
check_consistent_sizes_mvt.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_ERR_CHECK_CONSISTENT_SIZES_MVT_HPP
2#define STAN_MATH_PRIM_ERR_CHECK_CONSISTENT_SIZES_MVT_HPP
3
7#include <algorithm>
8#include <sstream>
9#include <string>
10
11namespace stan {
12namespace math {
13
15inline void check_consistent_sizes_mvt(const char*) { return; }
16
21template <typename T1>
22inline void check_consistent_sizes_mvt(const char*, const char*, const T1&) {
23 return;
24}
25
45template <typename T1, typename T2, typename... Ts>
46inline void check_consistent_sizes_mvt(const char* function, const char* name1,
47 const T1& x1, const char* name2,
48 const T2& x2,
49 const Ts&... names_and_xs) {
51 check_consistent_sizes_mvt(function, name2, x2, name1, x1, names_and_xs...);
52 } else if (!is_std_vector<T2>::value) {
53 check_consistent_sizes_mvt(function, name1, x1, names_and_xs...);
54 } else if (stan::math::size(x1) == stan::math::size(x2)) {
55 check_consistent_sizes_mvt(function, name1, x1, names_and_xs...);
56 } else {
57 [&]() STAN_COLD_PATH {
58 size_t size_x1 = stan::math::size(x1);
59 size_t size_x2 = stan::math::size(x2);
60 std::stringstream msg;
61 msg << ", but " << name2 << " has size " << size_x2
62 << "; and they must be the same size.";
63 std::string msg_str(msg.str());
64 invalid_argument(function, name1, size_x1,
65 "has size = ", msg_str.c_str());
66 }();
67 }
68}
69
70} // namespace math
71} // namespace stan
72#endif
#define STAN_COLD_PATH
int64_t size(const T &m)
Returns the size (number of the elements) of a matrix_cl or var_value<matrix_cl<T>>.
Definition size.hpp:19
void check_consistent_sizes_mvt(const char *)
Trivial no input case, this function is a no-op.
void invalid_argument(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw an invalid_argument exception with a consistently formatted message.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Base implementation for checking if type is std vector.
Definition is_vector.hpp:19