| Stan Math Library 2.11.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

rep_array.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_ARR_FUN_REP_ARRAY_HPP
2 #define STAN_MATH_PRIM_ARR_FUN_REP_ARRAY_HPP
3
4 #include <stan/math/prim/scal/err/check_nonnegative.hpp>
5 #include <vector>
6
7 namespace stan {
8
9 namespace math {
10
11 template <typename T>
12 inline std::vector<T>
13 rep_array(const T& x, int n) {
14 using stan::math::check_nonnegative;
15 check_nonnegative("rep_array", "n", n);
16 return std::vector<T>(n, x);
17 }
18
19 template <typename T>
20 inline std::vector<std::vector<T> >
21 rep_array(const T& x, int m, int n) {
22 using std::vector;
23 using stan::math::check_nonnegative;
24 check_nonnegative("rep_array", "rows", m);
25 check_nonnegative("rep_array", "cols", n);
26 return vector<vector<T> >(m, vector<T>(n, x));
27 }
28
29 template <typename T>
30 inline std::vector<std::vector<std::vector<T> > >
31 rep_array(const T& x, int k, int m, int n) {
32 using std::vector;
33 using stan::math::check_nonnegative;
34 check_nonnegative("rep_array", "shelfs", k);
35 check_nonnegative("rep_array", "rows", m);
36 check_nonnegative("rep_array", "cols", n);
37 return vector<vector<vector<T> > >(k,
38 vector<vector<T> >(m,
39 vector<T>(n, x)));
40 }
41
42 }
43 }
44
45 #endif
stan
Definition: log_sum_exp.hpp:8
stan::math::rep_array
std::vector< T > rep_array(const T &x, int n)
Definition: rep_array.hpp:13
check_nonnegative.hpp
stan::math::check_nonnegative
bool check_nonnegative(const char *function, const char *name, const T_y &y)
Return true if y is non-negative.
Definition: check_nonnegative.hpp:66

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