Automatic Differentiation
 
Loading...
Searching...
No Matches
get_base1_lhs.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_GET_BASE1_LHS_HPP
2#define STAN_MATH_PRIM_FUN_GET_BASE1_LHS_HPP
3
6#include <vector>
7
8namespace stan {
9namespace math {
10
26template <typename T>
27inline T& get_base1_lhs(std::vector<T>& x, size_t i, const char* error_msg,
28 size_t idx) {
29 check_range("[]", "x", x.size(), i, idx, error_msg);
30 return x[i - 1];
31}
32
49template <typename T>
50inline T& get_base1_lhs(std::vector<std::vector<T> >& x, size_t i1, size_t i2,
51 const char* error_msg, size_t idx) {
52 check_range("[]", "x", x.size(), i1, idx, error_msg);
53 return get_base1_lhs(x[i1 - 1], i2, error_msg, idx + 1);
54}
55
73template <typename T>
74inline T& get_base1_lhs(std::vector<std::vector<std::vector<T> > >& x,
75 size_t i1, size_t i2, size_t i3, const char* error_msg,
76 size_t idx) {
77 check_range("[]", "x", x.size(), i1, idx, error_msg);
78 return get_base1_lhs(x[i1 - 1], i2, i3, error_msg, idx + 1);
79}
80
99template <typename T>
101 std::vector<std::vector<std::vector<std::vector<T> > > >& x, size_t i1,
102 size_t i2, size_t i3, size_t i4, const char* error_msg, size_t idx) {
103 check_range("[]", "x", x.size(), i1, idx, error_msg);
104 return get_base1_lhs(x[i1 - 1], i2, i3, i4, error_msg, idx + 1);
105}
106
126template <typename T>
128 std::vector<std::vector<std::vector<std::vector<std::vector<T> > > > >& x,
129 size_t i1, size_t i2, size_t i3, size_t i4, size_t i5,
130 const char* error_msg, size_t idx) {
131 check_range("[]", "x", x.size(), i1, idx, error_msg);
132 return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, error_msg, idx + 1);
133}
134
155template <typename T>
157 std::vector<std::vector<
158 std::vector<std::vector<std::vector<std::vector<T> > > > > >& x,
159 size_t i1, size_t i2, size_t i3, size_t i4, size_t i5, size_t i6,
160 const char* error_msg, size_t idx) {
161 check_range("[]", "x", x.size(), i1, idx, error_msg);
162 return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, i6, error_msg, idx + 1);
163}
164
186template <typename T>
188 std::vector<std::vector<std::vector<
189 std::vector<std::vector<std::vector<std::vector<T> > > > > > >& x,
190 size_t i1, size_t i2, size_t i3, size_t i4, size_t i5, size_t i6, size_t i7,
191 const char* error_msg, size_t idx) {
192 check_range("[]", "x", x.size(), i1, idx, error_msg);
193 return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, i6, i7, error_msg, idx + 1);
194}
195
218template <typename T>
220 std::vector<std::vector<std::vector<std::vector<
221 std::vector<std::vector<std::vector<std::vector<T> > > > > > > >& x,
222 size_t i1, size_t i2, size_t i3, size_t i4, size_t i5, size_t i6, size_t i7,
223 size_t i8, const char* error_msg, size_t idx) {
224 check_range("[]", "x", x.size(), i1, idx, error_msg);
225 return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, i6, i7, i8, error_msg,
226 idx + 1);
227}
228
249template <typename T>
250inline Eigen::Block<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> >
251get_base1_lhs(Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& x, size_t m,
252 const char* error_msg, size_t idx) {
253 check_range("[]", "rows of x", x.rows(), m, idx, error_msg);
254 return x.block(m - 1, 0, 1, x.cols());
255}
256
274template <typename T>
275inline T& get_base1_lhs(Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& x,
276 size_t m, size_t n, const char* error_msg, size_t idx) {
277 check_range("[]", "rows of x", x.rows(), m, idx, error_msg);
278 check_range("[]", "cols of x", x.cols(), n, idx + 1, error_msg);
279 return x(m - 1, n - 1);
280}
281
297template <typename T>
298inline T& get_base1_lhs(Eigen::Matrix<T, Eigen::Dynamic, 1>& x, size_t m,
299 const char* error_msg, size_t idx) {
300 check_range("[]", "x", x.size(), m, idx, error_msg);
301 return x(m - 1);
302}
303
319template <typename T>
320inline T& get_base1_lhs(Eigen::Matrix<T, 1, Eigen::Dynamic>& x, size_t n,
321 const char* error_msg, size_t idx) {
322 check_range("[]", "x", x.size(), n, idx, error_msg);
323 return x(n - 1);
324}
325
326} // namespace math
327} // namespace stan
328
329#endif
T & get_base1_lhs(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.
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.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9