Stan Math Library  2.14.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 
7 #include <sstream>
8 #include <string>
9 
10 namespace stan {
11  namespace math {
12 
28  inline void check_range(const char* function,
29  const char* name,
30  int max,
31  int index,
32  int nested_level,
33  const char* error_msg) {
34  if ((index >= stan::error_index::value)
35  && (index < max + stan::error_index::value))
36  return;
37 
38  std::stringstream msg;
39  msg << "; index position = " << nested_level;
40  std::string msg_str(msg.str());
41 
42  out_of_range(function, max, index, msg_str.c_str(), error_msg);
43  }
44 
59  inline void check_range(const char* function,
60  const char* name,
61  int max,
62  int index,
63  const char* error_msg) {
64  if ((index >= stan::error_index::value)
65  && (index < max + stan::error_index::value))
66  return;
67 
68  out_of_range(function, max, index, error_msg);
69  }
70 
84  inline void check_range(const char* function,
85  const char* name,
86  int max,
87  int index) {
88  if ((index >= stan::error_index::value)
89  && (index < max + stan::error_index::value))
90  return;
91 
92  out_of_range(function, max, index);
93  }
94 
95  }
96 }
97 #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:28
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:22

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