Stan Math Library  2.15.0
reverse mode automatic differentiation
out_of_range.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_ERR_OUT_OF_RANGE_HPP
2 #define STAN_MATH_PRIM_SCAL_ERR_OUT_OF_RANGE_HPP
3 
5 #include <typeinfo>
6 #include <string>
7 #include <sstream>
8 #include <stdexcept>
9 
10 namespace stan {
11  namespace math {
12 
31  inline void out_of_range(const char* function,
32  int max,
33  int index,
34  const char* msg1 = "",
35  const char* msg2 = "") {
36  std::ostringstream message;
37 
38  message << function << ": accessing element out of range. "
39  << "index " << index << " out of range; "
40  << "expecting index to be between "
41  << stan::error_index::value << " and "
42  << stan::error_index::value - 1 + max
43  << msg1
44  << msg2;
45 
46  throw std::out_of_range(message.str());
47  }
48 
49  }
50 }
51 #endif
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.