Stan Math Library: stan/math/prim/mat/err/check_range.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/scal/err/out_of_range.hpp>
5 #include <stan/math/prim/mat/meta/index_type.hpp>
6 #include <stan/math/prim/scal/meta/error_index.hpp>
7 #include <sstream>
8 #include <string>
9
10 namespace stan {
11 namespace math {
12
29 inline bool check_range(const char* function,
30 const char* name,
31 const int max,
32 const int index,
33 const int nested_level,
34 const char* error_msg) {
35 if ((index >= stan::error_index::value)
36 && (index < max + stan::error_index::value))
37 return true;
38
39 std::stringstream msg;
40 msg << "; index position = " << nested_level;
41 std::string msg_str(msg.str());
42
43 out_of_range(function, max, index, msg_str.c_str(), error_msg);
44 return false;
45 }
46
62 inline bool check_range(const char* function,
63 const char* name,
64 const int max,
65 const int index,
66 const char* error_msg) {
67 if ((index >= stan::error_index::value)
68 && (index < max + stan::error_index::value))
69 return true;
70
71 out_of_range(function, max, index, error_msg);
72 return false;
73 }
74
89 inline bool check_range(const char* function,
90 const char* name,
91 const int max,
92 const int index) {
93 if ((index >= stan::error_index::value)
94 && (index < max + stan::error_index::value))
95 return true;
96
97 out_of_range(function, max, index);
98 return false;
99 }
100
101
102 }
103 }
104 #endif
stan
Definition: log_sum_exp.hpp:8
out_of_range.hpp
stan::math::check_range
bool check_range(const char *function, const char *name, const int max, const int index, const int nested_level, const char *error_msg)
Return true if specified index is within range.
Definition: check_range.hpp:29
index_type.hpp
stan::error_index::value
Definition: error_index.hpp:7
stan::math::out_of_range
void out_of_range(const char *function, const int max, const int index, const char *msg1="", const char *msg2="")
Throw an out_of_range exception with a consistently formatted message.
Definition: out_of_range.hpp:30
stan::math::max
int max(const std::vector< int > &x)
Returns the maximum coefficient in the specified column vector.
Definition: max.hpp:21
error_index.hpp

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