Stan Math Library
2.20.0
reverse mode automatic differentiation
stan
math
prim
mat
err
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 <
stan/math/prim/meta.hpp
>
5
#include <sstream>
6
#include <stdexcept>
7
#include <string>
8
9
namespace
stan
{
10
namespace
math {
11
12
inline
void
validate_non_negative_index
(
const
char
* var_name,
const
char
* expr,
13
int
val) {
14
if
(val < 0) {
15
std::stringstream msg;
16
msg <<
"Found negative dimension size in variable declaration"
17
<<
"; variable="
<< var_name <<
"; dimension size expression="
<< expr
18
<<
"; expression value="
<< val;
19
std::string msg_str(msg.str());
20
throw
std::invalid_argument
(msg_str.c_str());
21
}
22
}
23
24
}
// namespace math
25
}
// namespace stan
26
#endif
stan
Definition:
log_sum_exp.hpp:8
meta.hpp
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:27
[
Stan Home Page
]
© 2011–2018, Stan Development Team.