Automatic Differentiation
 
Loading...
Searching...
No Matches
validate_unit_vector_index.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_ERR_VALIDATE_UNIT_VECTOR_INDEX_HPP
2#define STAN_MATH_PRIM_ERR_VALIDATE_UNIT_VECTOR_INDEX_HPP
3
5#include <sstream>
6#include <stdexcept>
7#include <string>
8
9namespace stan {
10namespace math {
11
20inline void validate_unit_vector_index(const char* var_name, const char* expr,
21 int val) {
22 if (val <= 1) {
23 [&]() STAN_COLD_PATH {
24 std::stringstream msg;
25 if (val == 1) {
26 msg << "Found dimension size one in unit vector declaration."
27 << " One-dimensional unit vector is discrete"
28 << " but the target distribution must be continuous."
29 << " variable=" << var_name
30 << "; dimension size expression=" << expr;
31 } else {
32 msg << "Found dimension size less than one in unit vector declaration"
33 << "; variable=" << var_name
34 << "; dimension size expression=" << expr
35 << "; expression value=" << val;
36 }
37 std::string msg_str(msg.str());
38 throw std::invalid_argument(msg_str.c_str());
39 }();
40 }
41}
42
43} // namespace math
44} // namespace stan
45#endif
#define STAN_COLD_PATH
void validate_unit_vector_index(const char *var_name, const char *expr, int val)
Check that unit vector is at least size 2.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...