Stan Math Library  2.20.0
reverse mode automatic differentiation
get_base1_lhs.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_GET_BASE1_LHS_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_GET_BASE1_LHS_HPP
3 
6 #include <vector>
7 
8 namespace stan {
9 namespace math {
10 
26 template <typename T>
27 inline 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 
49 template <typename T>
50 inline 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 
73 template <typename T>
74 inline 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 
99 template <typename T>
100 inline T& get_base1_lhs(
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 
126 template <typename T>
127 inline T& get_base1_lhs(
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 
155 template <typename T>
156 inline T& get_base1_lhs(
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 
186 template <typename T>
187 inline T& get_base1_lhs(
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 
218 template <typename T>
219 inline T& get_base1_lhs(
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 
249 template <typename T>
250 inline Eigen::Block<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> >
251 get_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 
274 template <typename T>
275 inline 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 
297 template <typename T>
298 inline 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 
319 template <typename T>
320 inline 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 #endif
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.
Definition: check_range.hpp:24
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...

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