Automatic Differentiation
 
Loading...
Searching...
No Matches
check_vector_index.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_ERR_CHECK_VECTOR_INDEX_HPP
2#define STAN_MATH_PRIM_ERR_CHECK_VECTOR_INDEX_HPP
3
7#include <sstream>
8#include <string>
9
10namespace stan {
11namespace math {
12
24template <
25 typename T,
26 require_any_t<is_vector<T>, is_prim_or_rev_kernel_expression<T>>* = nullptr>
27inline void check_vector_index(const char* function, const char* name,
28 const T& y, size_t i) {
31 && i < static_cast<size_t>(y.size()) + stan::error_index::value)) {
32 [&]() STAN_COLD_PATH {
33 std::stringstream msg;
34 msg << " for size of " << name;
35 std::string msg_str(msg.str());
36 out_of_range(function, y.rows(), i, msg_str.c_str());
37 }();
38 }
39}
40
41} // namespace math
42} // namespace stan
43#endif
#define STAN_COLD_PATH
#define STAN_NO_RANGE_CHECKS_RETURN
Turns all range and size checks into no-ops.
void check_vector_index(const char *function, const char *name, const T &y, size_t i)
Check if the specified index is a valid element of the row or column vector This check is 1-indexed b...
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.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...