Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rep_array.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__REP_ARRAY_HPP
2 #define STAN__MATH__REP_ARRAY_HPP
3 
4 #include <vector>
5 
7 
8 namespace stan {
9 
10  namespace math {
11 
12  template <typename T>
13  inline std::vector<T>
14  rep_array(const T& x, int n) {
15  check_nonnegative("rep_array(%1%)", n,"n", (double*)0);
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  check_nonnegative("rep_array(%1%)", m,"rows", (double*)0);
24  check_nonnegative("rep_array(%1%)", n,"cols", (double*)0);
25  return vector<vector<T> >(m, vector<T>(n, x));
26  }
27 
28  template <typename T>
29  inline std::vector<std::vector<std::vector<T> > >
30  rep_array(const T& x, int k, int m, int n) {
31  using std::vector;
32  check_nonnegative("rep_array(%1%)", k,"shelfs", (double*)0);
33  check_nonnegative("rep_array(%1%)", m,"rows", (double*)0);
34  check_nonnegative("rep_array(%1%)", n,"cols", (double*)0);
35  return vector<vector<vector<T> > >(k,
36  vector<vector<T> >(m,
37  vector<T>(n, x)));
38  }
39 
40  }
41 }
42 
43 #endif
std::vector< T > rep_array(const T &x, int n)
Definition: rep_array.hpp:14
bool check_nonnegative(const char *function, const T_y &y, const char *name, T_result *result)

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