Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
stan
math
prim
mat
err
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
13
/**
14
* Check if the specified index is valid in std vector
15
*
16
* This check is 1-indexed by default. This behavior can be changed
17
* by setting <code>stan::error_index::value</code>.
18
*
19
* @tparam T Scalar type
20
*
21
* @param function Function name (for error messages)
22
* @param name Variable name (for error messages)
23
* @param y <code>std::vector</code> to test
24
* @param i Index
25
*
26
* @throw <code>std::out_of_range</code> if the index is out of range.
27
*/
28
template
<
typename
T>
29
inline
void
check_std_vector_index
(
const
char
*
function
,
const
char
*
name
,
30
const
std::vector<T>&
y
,
int
i
) {
31
if
(i >= static_cast<int>(
stan::error_index::value
)
32
&& i < static_cast<int>(y.size() +
stan::error_index::value
))
33
return
;
34
35
std::stringstream
msg
;
36
msg <<
" for "
<<
name
;
37
std::string
msg_str(msg.str());
38
out_of_range
(
function
, y.size(),
i
, msg_str.c_str());
39
}
40
41
}
// namespace math
42
}
// namespace stan
43
#endif
name
const XML_Char * name
Definition:
expat.h:151
lem_server.msg
msg
Definition:
lem_server.py:603
stan
Definition:
StanTypedefs.h:9
out_of_range.hpp
MECModelEnuComparisons.i
int i
Definition:
MECModelEnuComparisons.py:63
submit_syst.y
y
Definition:
submit_syst.py:249
stan::math::check_std_vector_index
void check_std_vector_index(const char *function, const char *name, const std::vector< T > &y, int i)
Definition:
check_std_vector_index.hpp:29
math
stan::math::out_of_range
void out_of_range(const char *function, int max, int index, const char *msg1="", const char *msg2="")
Definition:
out_of_range.hpp:30
stan::error_index::value
Definition:
error_index.hpp:8
string
enum BeamMode string
Generated on Wed Feb 24 2021 14:14:49 for NOvA by
1.8.11