Stan Math Library  2.14.0
reverse mode automatic differentiation
check_positive_size.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_ERR_CHECK_POSITIVE_SIZE_HPP
2 #define STAN_MATH_PRIM_SCAL_ERR_CHECK_POSITIVE_SIZE_HPP
3 
5 #include <sstream>
6 #include <string>
7 
8 namespace stan {
9  namespace math {
10 
22  inline void check_positive_size(const char* function,
23  const char* name,
24  const char* expr,
25  int size) {
26  if (size <= 0) {
27  std::stringstream msg;
28  msg << "; dimension size expression = " << expr;
29  std::string msg_str(msg.str());
30  invalid_argument(function, name, size,
31  "must have a positive size, but is ",
32  msg_str.c_str());
33  }
34  }
35 
36  }
37 }
38 #endif
void check_positive_size(const char *function, const char *name, const char *expr, int size)
Check if size is positive.
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.
int size(const std::vector< T > &x)
Return the size of the specified standard vector.
Definition: size.hpp:17

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