Automatic Differentiation
 
Loading...
Searching...
No Matches
check_consistent_size.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_ERR_CHECK_CONSISTENT_SIZE_HPP
2#define STAN_MATH_PRIM_ERR_CHECK_CONSISTENT_SIZE_HPP
3
7#include <sstream>
8#include <string>
9
10namespace stan {
11namespace math {
12
24template <typename T>
25inline void check_consistent_size(const char* function, const char* name,
26 const T& x, size_t expected_size) {
28 || (is_vector<T>::value && expected_size == stan::math::size(x)))) {
29 [&]() STAN_COLD_PATH {
30 std::stringstream msg;
31 msg << ", expecting dimension = " << expected_size
32 << "; a function was called with arguments of different "
33 << "scalar, array, vector, or matrix types, and they were not "
34 << "consistently sized; all arguments must be scalars or "
35 << "multidimensional values of the same shape.";
36 std::string msg_str(msg.str());
37
38 invalid_argument(function, name, stan::math::size(x),
39 "has dimension = ", msg_str.c_str());
40 }();
41 }
42}
43
44} // namespace math
45} // namespace stan
46#endif
#define STAN_COLD_PATH
size_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:18
void check_consistent_size(const char *function, const char *name, const T &x, size_t expected_size)
Check if x is consistent with size expected_size.
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 ...
Definition fvar.hpp:9
If the input type T is either an eigen matrix with 1 column or 1 row at compile time or a standard ve...