| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

check_std_vector_index.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_STD_VECTOR_INDEX_HPP
2 #define STAN_MATH_PRIM_MAT_ERR_CHECK_STD_VECTOR_INDEX_HPP
3
4 #include <stan/math/prim/scal/err/out_of_range.hpp>
5
6 #include <sstream>
7 #include <string>
8 #include <vector>
9
10 namespace stan {
11 namespace math {
12
29 template <typename T>
30 inline bool check_std_vector_index(const char* function,
31 const char* name,
32 const std::vector<T>& y,
33 int i) {
34 if (i >= static_cast<int>(stan::error_index::value)
35 && i < static_cast<int>(y.size() + stan::error_index::value))
36 return true;
37
38 std::stringstream msg;
39 msg << " for " << name;
40 std::string msg_str(msg.str());
41 out_of_range(function, y.size(), i, msg_str.c_str());
42 return false;
43 }
44
45 }
46 }
47 #endif
stan
Definition: log_sum_exp.hpp:8
out_of_range.hpp
stan::math::check_std_vector_index
bool check_std_vector_index(const char *function, const char *name, const std::vector< T > &y, int i)
Return true if the specified index is valid in std vector.
Definition: check_std_vector_index.hpp:30
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:31

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