Stan Math Library  2.15.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  namespace math {
9 
10  template <typename T>
11  inline std::vector<T>
12  rep_array(const T& x, int n) {
13  check_nonnegative("rep_array", "n", n);
14  return std::vector<T>(n, x);
15  }
16 
17  template <typename T>
18  inline std::vector<std::vector<T> >
19  rep_array(const T& x, int m, int n) {
20  using std::vector;
21  check_nonnegative("rep_array", "rows", m);
22  check_nonnegative("rep_array", "cols", n);
23  return vector<vector<T> >(m, vector<T>(n, x));
24  }
25 
26  template <typename T>
27  inline std::vector<std::vector<std::vector<T> > >
28  rep_array(const T& x, int k, int m, int n) {
29  using std::vector;
30  check_nonnegative("rep_array", "shelfs", k);
31  check_nonnegative("rep_array", "rows", m);
32  check_nonnegative("rep_array", "cols", n);
33  return vector<vector<vector<T> > >(k,
34  vector<vector<T> >(m,
35  vector<T>(n, x)));
36  }
37 
38  }
39 }
40 
41 #endif
void check_nonnegative(const char *function, const char *name, const T_y &y)
Check if y is non-negative.
std::vector< T > rep_array(const T &x, int n)
Definition: rep_array.hpp:12

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