1#ifndef STAN_MATH_PRIM_FUN_GET_BASE1_HPP
2#define STAN_MATH_PRIM_FUN_GET_BASE1_HPP
28inline const T&
get_base1(
const std::vector<T>& x,
size_t i,
29 const char* error_msg,
size_t idx) {
30 check_range(
"[]",
"x", x.size(), i, idx, error_msg);
51inline const T&
get_base1(
const std::vector<std::vector<T> >& x,
size_t i1,
52 size_t i2,
const char* error_msg,
size_t idx) {
53 check_range(
"[]",
"x", x.size(), i1, idx, error_msg);
54 return get_base1(x[i1 - 1], i2, error_msg, idx + 1);
75inline const T&
get_base1(
const std::vector<std::vector<std::vector<T> > >& x,
76 size_t i1,
size_t i2,
size_t i3,
77 const char* error_msg,
size_t idx) {
78 check_range(
"[]",
"x", x.size(), i1, idx, error_msg);
79 return get_base1(x[i1 - 1], i2, i3, error_msg, idx + 1);
102 const std::vector<std::vector<std::vector<std::vector<T> > > >& x,
103 size_t i1,
size_t i2,
size_t i3,
size_t i4,
const char* error_msg,
105 check_range(
"[]",
"x", x.size(), i1, idx, error_msg);
106 return get_base1(x[i1 - 1], i2, i3, i4, error_msg, idx + 1);
131 std::vector<std::vector<std::vector<std::vector<T> > > > >& x,
132 size_t i1,
size_t i2,
size_t i3,
size_t i4,
size_t i5,
133 const char* error_msg,
size_t idx) {
134 check_range(
"[]",
"x", x.size(), i1, idx, error_msg);
135 return get_base1(x[i1 - 1], i2, i3, i4, i5, error_msg, idx + 1);
160 const std::vector<std::vector<
161 std::vector<std::vector<std::vector<std::vector<T> > > > > >& x,
162 size_t i1,
size_t i2,
size_t i3,
size_t i4,
size_t i5,
size_t i6,
163 const char* error_msg,
size_t idx) {
164 check_range(
"[]",
"x", x.size(), i1, idx, error_msg);
165 return get_base1(x[i1 - 1], i2, i3, i4, i5, i6, error_msg, idx + 1);
191 const std::vector<std::vector<std::vector<
192 std::vector<std::vector<std::vector<std::vector<T> > > > > > >& x,
193 size_t i1,
size_t i2,
size_t i3,
size_t i4,
size_t i5,
size_t i6,
size_t i7,
194 const char* error_msg,
size_t idx) {
195 check_range(
"[]",
"x", x.size(), i1, idx, error_msg);
196 return get_base1(x[i1 - 1], i2, i3, i4, i5, i6, i7, error_msg, idx + 1);
223 const std::vector<std::vector<std::vector<std::vector<
224 std::vector<std::vector<std::vector<std::vector<T> > > > > > > >& x,
225 size_t i1,
size_t i2,
size_t i3,
size_t i4,
size_t i5,
size_t i6,
size_t i7,
226 size_t i8,
const char* error_msg,
size_t idx) {
227 check_range(
"[]",
"x", x.size(), i1, idx, error_msg);
228 return get_base1(x[i1 - 1], i2, i3, i4, i5, i6, i7, i8, error_msg, idx + 1);
251template <
typename EigMat, require_eigen_t<EigMat>* =
nullptr,
252 require_not_eigen_vector_t<EigMat>* =
nullptr>
253inline Eigen::Matrix<value_type_t<EigMat>, 1, Eigen::Dynamic>
get_base1(
254 const EigMat& x,
size_t m,
const char* error_msg,
size_t idx) {
255 check_range(
"[]",
"rows of x", x.rows(), m, idx, error_msg);
276template <
typename EigMat, require_eigen_t<EigMat>* =
nullptr>
278 size_t n,
const char* error_msg,
280 check_range(
"[]",
"rows of x", x.rows(), m, idx, error_msg);
281 check_range(
"[]",
"cols of x", x.cols(), n, idx + 1, error_msg);
282 return x.coeff(m - 1, n - 1);
300template <
typename EigVec, require_eigen_vector_t<EigVec>* =
nullptr>
302 const char* error_msg,
304 check_range(
"[]",
"x", x.size(), m, idx, error_msg);
305 return x.coeff(m - 1);
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
void check_range(const char *function, const char *name, int max, int index, int nested_level, const char *error_msg)
Check if specified index is within range.
const T & get_base1(const std::vector< T > &x, size_t i, const char *error_msg, size_t idx)
Return a reference to the value of the specified vector at the specified base-one index.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...