Stan Math Library  2.20.0
reverse mode automatic differentiation
check_range.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_RANGE_HPP
2 #define STAN_MATH_PRIM_MAT_ERR_CHECK_RANGE_HPP
3 
6 #include <sstream>
7 #include <string>
8 
9 namespace stan {
10 namespace math {
11 
24 inline void check_range(const char* function, const char* name, int max,
25  int index, int nested_level, const char* error_msg) {
26  if ((index >= stan::error_index::value)
27  && (index < max + stan::error_index::value))
28  return;
29 
30  std::stringstream msg;
31  msg << "; index position = " << nested_level;
32  std::string msg_str(msg.str());
33 
34  out_of_range(function, max, index, msg_str.c_str(), error_msg);
35 }
36 
48 inline void check_range(const char* function, const char* name, int max,
49  int index, const char* error_msg) {
50  if ((index >= stan::error_index::value)
51  && (index < max + stan::error_index::value))
52  return;
53 
54  out_of_range(function, max, index, error_msg);
55 }
56 
67 inline void check_range(const char* function, const char* name, int max,
68  int index) {
69  if ((index >= stan::error_index::value)
70  && (index < max + stan::error_index::value))
71  return;
72 
73  out_of_range(function, max, index);
74 }
75 
76 } // namespace math
77 } // namespace stan
78 #endif
void check_range(const char *function, const char *name, int max, int index, int nested_level, const char *error_msg)
Check if specified index is within range.
Definition: check_range.hpp:24
void out_of_range(const char *function, int max, int index, const char *msg1="", const char *msg2="")
Throw an out_of_range exception with a consistently formatted message.
int max(const std::vector< int > &x)
Returns the maximum coefficient in the specified column vector.
Definition: max.hpp:21

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