| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
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
25 template <typename T>
26 inline
27 T& get_base1_lhs(std::vector<T>& x,
28 size_t i,
29 const char* error_msg,
30 size_t idx) {
31 using stan::math::check_range;
32 check_range("[]", "x", x.size(), i, idx, error_msg);
33 return x[i - 1];
34 }
35
51 template <typename T>
52 inline
53 T& get_base1_lhs(std::vector<std::vector<T> >& x,
54 size_t i1,
55 size_t i2,
56 const char* error_msg,
57 size_t idx) {
58 using stan::math::check_range;
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
79 template <typename T>
80 inline
81 T& get_base1_lhs(std::vector<std::vector<std::vector<T> > >& x,
82 size_t i1,
83 size_t i2,
84 size_t i3,
85 const char* error_msg,
86 size_t idx) {
87 using stan::math::check_range;
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
109 template <typename T>
110 inline
111 T& get_base1_lhs(std::vector<std::vector<std::vector
112 <std::vector<T> > > >& x,
113 size_t i1,
114 size_t i2,
115 size_t i3,
116 size_t i4,
117 const char* error_msg,
118 size_t idx) {
119 using stan::math::check_range;
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
142 template <typename T>
143 inline
144 T& get_base1_lhs(std::vector<std::vector<std::vector<std::vector
145 <std::vector<T> > > > >& x,
146 size_t i1,
147 size_t i2,
148 size_t i3,
149 size_t i4,
150 size_t i5,
151 const char* error_msg,
152 size_t idx) {
153 using stan::math::check_range;
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
177 template <typename T>
178 inline
179 T& get_base1_lhs(std::vector<std::vector<std::vector<std::vector
180 <std::vector<std::vector<T> > > > > >& x,
181 size_t i1,
182 size_t i2,
183 size_t i3,
184 size_t i4,
185 size_t i5,
186 size_t i6,
187 const char* error_msg,
188 size_t idx) {
189 using stan::math::check_range;
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
194
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 using stan::math::check_range;
230 check_range("[]", "x", x.size(), i1, idx, error_msg);
231 return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, i6, i7, error_msg, idx+1);
232 }
233
234
256 template <typename T>
257 inline
258 T& get_base1_lhs(std::vector<std::vector<std::vector<std::vector
259 <std::vector<std::vector<std::vector
260 <std::vector<T> > > > > > > >& x,
261 size_t i1,
262 size_t i2,
263 size_t i3,
264 size_t i4,
265 size_t i5,
266 size_t i6,
267 size_t i7,
268 size_t i8,
269 const char* error_msg,
270 size_t idx) {
271 using stan::math::check_range;
272 check_range("[]", "x", x.size(), i1, idx, error_msg);
273 return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, i6, i7, i8,
274 error_msg, idx+1);
275 }
276
277
278
298 template <typename T>
299 inline
300 Eigen::Block<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> >
301 get_base1_lhs(Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& x,
302 size_t m,
303 const char* error_msg,
304 size_t idx) {
305 using stan::math::check_range;
306 check_range("[]", "rows of x", x.rows(), m, idx, error_msg);
307 return x.block(m-1, 0, 1, x.cols());
308 }
309
326 template <typename T>
327 inline
328 T& get_base1_lhs(Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& x,
329 size_t m,
330 size_t n,
331 const char* error_msg,
332 size_t idx) {
333 using stan::math::check_range;
334 check_range("[]", "rows of x", x.rows(), m, idx, error_msg);
335 check_range("[]", "cols of x", x.cols(), n, idx + 1, error_msg);
336 return x(m - 1, n - 1);
337 }
338
353 template <typename T>
354 inline
355 T& get_base1_lhs(Eigen::Matrix<T, Eigen::Dynamic, 1>& x,
356 size_t m,
357 const char* error_msg,
358 size_t idx) {
359 using stan::math::check_range;
360 check_range("[]", "x", x.size(), m, idx, error_msg);
361 return x(m - 1);
362 }
363
378 template <typename T>
379 inline
380 T& get_base1_lhs(Eigen::Matrix<T, 1, Eigen::Dynamic>& x,
381 size_t n,
382 const char* error_msg,
383 size_t idx) {
384 using stan::math::check_range;
385 check_range("[]", "x", x.size(), n, idx, error_msg);
386 return x(n - 1);
387 }
388
389 }
390 }
391 #endif
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:27
check_range.hpp

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