| 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
validate_non_negative_index.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_ERR_VALIDATE_NON_NEGATIVE_INDEX_HPP
2 #define STAN_MATH_PRIM_MAT_ERR_VALIDATE_NON_NEGATIVE_INDEX_HPP
3
4 #include <sstream>
5 #include <stdexcept>
6 #include <string>
7
8 namespace stan {
9 namespace math {
10
11 inline void
12 validate_non_negative_index(const char* var_name,
13 const char* expr,
14 int val) {
15 if (val < 0) {
16 std::stringstream msg;
17 msg << "Found negative dimension size in variable declaration"
18 << "; variable=" << var_name
19 << "; dimension size expression=" << expr
20 << "; expression value=" << val;
21 std::string msg_str(msg.str());
22 throw std::invalid_argument(msg_str.c_str());
23 }
24 }
25
26 }
27 }
28 #endif
stan::math::validate_non_negative_index
void validate_non_negative_index(const char *var_name, const char *expr, int val)
Definition: validate_non_negative_index.hpp:12
stan::math::invalid_argument
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.
Definition: invalid_argument.hpp:31

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