Stan Math Library: stan/math/prim/mat/fun/get_base1.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

get_base1.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_GET_BASE1_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_GET_BASE1_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 const T&
27 get_base1(const 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 const T&
53 get_base1(const 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(x[i1 - 1], i2, error_msg, idx+1);
61 }
62
79 template <typename T>
80 inline const T&
81 get_base1(const 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(x[i1 - 1], i2, i3, error_msg, idx+1);
90 }
91
109 template <typename T>
110 inline const T&
111 get_base1(const std::vector<std::vector<std::vector<std::vector<T> > > >& x,
112 size_t i1,
113 size_t i2,
114 size_t i3,
115 size_t i4,
116 const char* error_msg,
117 size_t idx) {
118 using stan::math::check_range;
119 check_range("[]", "x", x.size(), i1, idx, error_msg);
120 return get_base1(x[i1 - 1], i2, i3, i4, error_msg, idx+1);
121 }
122
141 template <typename T>
142 inline const T&
143 get_base1(const std::vector<std::vector<std::vector<std::vector
144 <std::vector<T> > > > >& x,
145 size_t i1,
146 size_t i2,
147 size_t i3,
148 size_t i4,
149 size_t i5,
150 const char* error_msg,
151 size_t idx) {
152 using stan::math::check_range;
153 check_range("[]", "x", x.size(), i1, idx, error_msg);
154 return get_base1(x[i1 - 1], i2, i3, i4, i5, error_msg, idx+1);
155 }
156
176 template <typename T>
177 inline const T&
178 get_base1(const std::vector<std::vector<std::vector<std::vector
179 <std::vector<std::vector<T> > > > > >& x,
180 size_t i1,
181 size_t i2,
182 size_t i3,
183 size_t i4,
184 size_t i5,
185 size_t i6,
186 const char* error_msg,
187 size_t idx) {
188 using stan::math::check_range;
189 check_range("[]", "x", x.size(), i1, idx, error_msg);
190 return get_base1(x[i1 - 1], i2, i3, i4, i5, i6, error_msg, idx+1);
191 }
192
193
214 template <typename T>
215 inline const T&
216 get_base1(const std::vector<std::vector<std::vector<std::vector
217 <std::vector<std::vector<std::vector<T> > > > > > >& x,
218 size_t i1,
219 size_t i2,
220 size_t i3,
221 size_t i4,
222 size_t i5,
223 size_t i6,
224 size_t i7,
225 const char* error_msg,
226 size_t idx) {
227 using stan::math::check_range;
228 check_range("[]", "x", x.size(), i1, idx, error_msg);
229 return get_base1(x[i1 - 1], i2, i3, i4, i5, i6, i7, error_msg, idx+1);
230 }
231
232
254 template <typename T>
255 inline const T&
256 get_base1(const std::vector<std::vector<std::vector
257 <std::vector<std::vector<std::vector
258 <std::vector<std::vector<T> > > > > > > >& x,
259 size_t i1,
260 size_t i2,
261 size_t i3,
262 size_t i4,
263 size_t i5,
264 size_t i6,
265 size_t i7,
266 size_t i8,
267 const char* error_msg,
268 size_t idx) {
269 using stan::math::check_range;
270 check_range("[]", "x", x.size(), i1, idx, error_msg);
271 return get_base1(x[i1 - 1], i2, i3, i4, i5, i6, i7, i8, error_msg, idx+1);
272 }
273
274
275
295 template <typename T>
296 inline Eigen::Matrix<T, 1, Eigen::Dynamic>
297 get_base1(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& x,
298 size_t m,
299 const char* error_msg,
300 size_t idx) {
301 using stan::math::check_range;
302 check_range("[]", "rows of x", x.rows(), m, idx, error_msg);
303 return x.block(m-1, 0, 1, x.cols());
304 }
305
322 template <typename T>
323 inline const T&
324 get_base1(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& x,
325 size_t m,
326 size_t n,
327 const char* error_msg,
328 size_t idx) {
329 using stan::math::check_range;
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
349 template <typename T>
350 inline
351 const T& get_base1(const Eigen::Matrix<T, Eigen::Dynamic, 1>& x,
352 size_t m,
353 const char* error_msg,
354 size_t idx) {
355 using stan::math::check_range;
356 check_range("[]", "x", x.size(), m, idx, error_msg);
357 return x(m - 1);
358 }
359
374 template <typename T>
375 inline const T&
376 get_base1(const Eigen::Matrix<T, 1, Eigen::Dynamic>& x,
377 size_t n,
378 const char* error_msg,
379 size_t idx) {
380 using stan::math::check_range;
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
stan::math::get_base1
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...
Definition: get_base1.hpp:27
Eigen.hpp
check_range.hpp

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