Automatic Differentiation
 
Loading...
Searching...
No Matches
validate_non_negative_index.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_ERR_VALIDATE_NON_NEGATIVE_INDEX_HPP
2#define STAN_MATH_PRIM_ERR_VALIDATE_NON_NEGATIVE_INDEX_HPP
3
5#include <sstream>
6#include <stdexcept>
7#include <string>
8
9namespace stan {
10namespace math {
11
12inline void validate_non_negative_index(const char* var_name, const char* expr,
13 int val) {
14 if (val < 0) {
15 [&]() STAN_COLD_PATH {
16 std::stringstream msg;
17 msg << "Found negative dimension size in variable declaration"
18 << "; variable=" << var_name << "; dimension size expression=" << expr
19 << "; expression value=" << val;
20 std::string msg_str(msg.str());
21 throw std::invalid_argument(msg_str.c_str());
22 }();
23 }
24}
25
26} // namespace math
27} // namespace stan
28#endif
#define STAN_COLD_PATH
void validate_non_negative_index(const char *var_name, const char *expr, int val)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9