| Stan Math Library 2.12.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
26 template <typename T>
27 inline const T&
28 get_base1(const 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 const T&
54 get_base1(const 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(x[i1 - 1], i2, error_msg, idx+1);
61 }
62
80 template <typename T>
81 inline const T&
82 get_base1(const 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(x[i1 - 1], i2, i3, error_msg, idx+1);
90 }
91
110 template <typename T>
111 inline const T&
112 get_base1(const std::vector<std::vector<std::vector<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 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
142 template <typename T>
143 inline const T&
144 get_base1(const 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 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
177 template <typename T>
178 inline const T&
179 get_base1(const 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 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
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 check_range("[]", "x", x.size(), i1, idx, error_msg);
228 return get_base1(x[i1 - 1], i2, i3, i4, i5, i6, i7, error_msg, idx+1);
229 }
230
253 template <typename T>
254 inline const T&
255 get_base1(const std::vector<std::vector<std::vector
256 <std::vector<std::vector<std::vector
257 <std::vector<std::vector<T> > > > > > > >& x,
258 size_t i1,
259 size_t i2,
260 size_t i3,
261 size_t i4,
262 size_t i5,
263 size_t i6,
264 size_t i7,
265 size_t i8,
266 const char* error_msg,
267 size_t idx) {
268 check_range("[]", "x", x.size(), i1, idx, error_msg);
269 return get_base1(x[i1 - 1], i2, i3, i4, i5, i6, i7, i8, error_msg, idx+1);
270 }
271
292 template <typename T>
293 inline Eigen::Matrix<T, 1, Eigen::Dynamic>
294 get_base1(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& x,
295 size_t m,
296 const char* error_msg,
297 size_t idx) {
298 check_range("[]", "rows of x", x.rows(), m, idx, error_msg);
299 return x.block(m-1, 0, 1, x.cols());
300 }
301
319 template <typename T>
320 inline const T&
321 get_base1(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& x,
322 size_t m,
323 size_t n,
324 const char* error_msg,
325 size_t idx) {
326 check_range("[]", "rows of x", x.rows(), m, idx, error_msg);
327 check_range("[]", "cols of x", x.cols(), n, idx + 1, error_msg);
328 return x(m - 1, n - 1);
329 }
330
346 template <typename T>
347 inline
348 const T& get_base1(const Eigen::Matrix<T, Eigen::Dynamic, 1>& x,
349 size_t m,
350 const char* error_msg,
351 size_t idx) {
352 check_range("[]", "x", x.size(), m, idx, error_msg);
353 return x(m - 1);
354 }
355
371 template <typename T>
372 inline const T&
373 get_base1(const Eigen::Matrix<T, 1, Eigen::Dynamic>& x,
374 size_t n,
375 const char* error_msg,
376 size_t idx) {
377 check_range("[]", "x", x.size(), n, idx, error_msg);
378 return x(n - 1);
379 }
380
381 }
382 }
383 #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:28
Eigen.hpp
check_range.hpp

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