Stan Math Library  2.15.0
reverse mode automatic differentiation
check_consistent_size.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_ERR_CHECK_CONSISTENT_SIZE_HPP
2 #define STAN_MATH_PRIM_SCAL_ERR_CHECK_CONSISTENT_SIZE_HPP
3 
6 #include <sstream>
7 #include <string>
8 
9 namespace stan {
10  namespace math {
11 
26  template <typename T>
27  inline void check_consistent_size(const char* function,
28  const char* name,
29  const T& x,
30  size_t expected_size) {
32  return;
33  if (is_vector<T>::value && expected_size == stan::size_of(x))
34  return;
35 
36  std::stringstream msg;
37  msg << ", expecting dimension = "
38  << expected_size
39  << "; a function was called with arguments of different "
40  << "scalar, array, vector, or matrix types, and they were not "
41  << "consistently sized; all arguments must be scalars or "
42  << "multidimensional values of the same shape.";
43  std::string msg_str(msg.str());
44 
45  invalid_argument(function, name, stan::size_of(x),
46  "has dimension = ",
47  msg_str.c_str());
48  }
49 
50  }
51 }
52 #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)
Definition: size_of.hpp:24
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.

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