| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5 #include <stan/math/prim/mat/err/check_range.hpp>
6 #include <vector>
7
8 namespace stan {
9 namespace math {
10
26 template <typename T>
27 inline
28 T& get_base1_lhs(std::vector<T>& x,
29 size_t i,
30 const char* error_msg,
31 size_t idx) {
32 check_range("[]", "x", x.size(), i, idx, error_msg);
33 return x[i - 1];
34 }
35
52 template <typename T>
53 inline
54 T& get_base1_lhs(std::vector<std::vector<T> >& x,
55 size_t i1,
56 size_t i2,
57 const char* error_msg,
58 size_t idx) {
59 check_range("[]", "x", x.size(), i1, idx, error_msg);
60 return get_base1_lhs(x[i1 - 1], i2, error_msg, idx+1);
61 }
62
80 template <typename T>
81 inline
82 T& get_base1_lhs(std::vector<std::vector<std::vector<T> > >& x,
83 size_t i1,
84 size_t i2,
85 size_t i3,
86 const char* error_msg,
87 size_t idx) {
88 check_range("[]", "x", x.size(), i1, idx, error_msg);
89 return get_base1_lhs(x[i1 - 1], i2, i3, error_msg, idx+1);
90 }
91
110 template <typename T>
111 inline
112 T& get_base1_lhs(std::vector<std::vector<std::vector
113 <std::vector<T> > > >& x,
114 size_t i1,
115 size_t i2,
116 size_t i3,
117 size_t i4,
118 const char* error_msg,
119 size_t idx) {
120 check_range("[]", "x", x.size(), i1, idx, error_msg);
121 return get_base1_lhs(x[i1 - 1], i2, i3, i4, error_msg, idx+1);
122 }
123
143 template <typename T>
144 inline
145 T& get_base1_lhs(std::vector<std::vector<std::vector<std::vector
146 <std::vector<T> > > > >& x,
147 size_t i1,
148 size_t i2,
149 size_t i3,
150 size_t i4,
151 size_t i5,
152 const char* error_msg,
153 size_t idx) {
154 check_range("[]", "x", x.size(), i1, idx, error_msg);
155 return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, error_msg, idx+1);
156 }
157
178 template <typename T>
179 inline
180 T& get_base1_lhs(std::vector<std::vector<std::vector<std::vector
181 <std::vector<std::vector<T> > > > > >& x,
182 size_t i1,
183 size_t i2,
184 size_t i3,
185 size_t i4,
186 size_t i5,
187 size_t i6,
188 const char* error_msg,
189 size_t idx) {
190 check_range("[]", "x", x.size(), i1, idx, error_msg);
191 return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, i6, error_msg, idx+1);
192 }
193
215 template <typename T>
216 inline
217 T& get_base1_lhs(std::vector<std::vector<std::vector<std::vector
218 <std::vector<std::vector
219 <std::vector<T> > > > > > >& x,
220 size_t i1,
221 size_t i2,
222 size_t i3,
223 size_t i4,
224 size_t i5,
225 size_t i6,
226 size_t i7,
227 const char* error_msg,
228 size_t idx) {
229 check_range("[]", "x", x.size(), i1, idx, error_msg);
230 return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, i6, i7, error_msg, idx+1);
231 }
232
255 template <typename T>
256 inline
257 T& get_base1_lhs(std::vector<std::vector<std::vector<std::vector
258 <std::vector<std::vector<std::vector
259 <std::vector<T> > > > > > > >& x,
260 size_t i1,
261 size_t i2,
262 size_t i3,
263 size_t i4,
264 size_t i5,
265 size_t i6,
266 size_t i7,
267 size_t i8,
268 const char* error_msg,
269 size_t idx) {
270 check_range("[]", "x", x.size(), i1, idx, error_msg);
271 return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, i6, i7, i8,
272 error_msg, idx+1);
273 }
274
295 template <typename T>
296 inline
297 Eigen::Block<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> >
298 get_base1_lhs(Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& x,
299 size_t m,
300 const char* error_msg,
301 size_t idx) {
302 check_range("[]", "rows of x", x.rows(), m, idx, error_msg);
303 return x.block(m-1, 0, 1, x.cols());
304 }
305
323 template <typename T>
324 inline
325 T& get_base1_lhs(Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& x,
326 size_t m,
327 size_t n,
328 const char* error_msg,
329 size_t idx) {
330 check_range("[]", "rows of x", x.rows(), m, idx, error_msg);
331 check_range("[]", "cols of x", x.cols(), n, idx + 1, error_msg);
332 return x(m - 1, n - 1);
333 }
334
350 template <typename T>
351 inline
352 T& get_base1_lhs(Eigen::Matrix<T, Eigen::Dynamic, 1>& x,
353 size_t m,
354 const char* error_msg,
355 size_t idx) {
356 check_range("[]", "x", x.size(), m, idx, error_msg);
357 return x(m - 1);
358 }
359
375 template <typename T>
376 inline
377 T& get_base1_lhs(Eigen::Matrix<T, 1, Eigen::Dynamic>& x,
378 size_t n,
379 const char* error_msg,
380 size_t idx) {
381 check_range("[]", "x", x.size(), n, idx, error_msg);
382 return x(n - 1);
383 }
384
385 }
386 }
387 #endif
stan
Definition: log_sum_exp.hpp:8
stan::math::check_range
bool check_range(const char *function, const char *name, const int max, const int index, const int nested_level, const char *error_msg)
Return true if specified index is within range.
Definition: check_range.hpp:29
Eigen.hpp
stan::math::get_base1_lhs
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...
Definition: get_base1_lhs.hpp:28
check_range.hpp

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