Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
check_range.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__MATRIX__CHECK_RANGE_HPP
2 #define STAN__MATH__MATRIX__CHECK_RANGE_HPP
3 
4 #include <sstream>
5 #include <stdexcept>
6 
7 namespace stan {
8  namespace math {
9 
10  namespace {
11 
12  void raise_range_error(size_t max,
13  size_t i,
14  const char* msg,
15  size_t idx) {
16  std::stringstream s;
17  s << "INDEX OPERATOR [] OUT OF BOUNDS"
18  << "; index=" << i
19  << "; lower bound=1"
20  << "; upper bound=" << max
21  << "; index position=" << idx
22  << "; " << msg
23  << std::endl;
24  throw std::out_of_range(s.str());
25  }
26 
27  }
28 
29  inline
30  void check_range(size_t max,
31  size_t i,
32  const char* msg,
33  size_t idx) {
34  if (i < 1 || i > max)
35  raise_range_error(max,i,msg,idx);
36  }
37 
38 
39  }
40 }
41 #endif
double max(const double a, const double b)
Definition: max.hpp:7
void check_range(size_t max, size_t i, const char *msg, size_t idx)
Definition: check_range.hpp:30

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