Stan Math Library  2.10.0
reverse mode automatic differentiation
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 
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) {
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;
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;
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
std::vector< T > rep_array(const T &x, int n)
Definition: rep_array.hpp:13
bool check_nonnegative(const char *function, const char *name, const T_y &y)
Return true if y is non-negative.

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