Stan Math Library  2.20.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 
6 #include <vector>
7 
8 namespace stan {
9 namespace math {
10 
11 template <typename T>
12 inline std::vector<T> 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> > rep_array(const T& x, int m, int n) {
19  using std::vector;
20  check_nonnegative("rep_array", "rows", m);
21  check_nonnegative("rep_array", "cols", n);
22  return vector<vector<T> >(m, vector<T>(n, x));
23 }
24 
25 template <typename T>
26 inline std::vector<std::vector<std::vector<T> > > rep_array(const T& x, int k,
27  int m, int n) {
28  using std::vector;
29  check_nonnegative("rep_array", "shelfs", k);
30  check_nonnegative("rep_array", "rows", m);
31  check_nonnegative("rep_array", "cols", n);
32  return vector<vector<vector<T> > >(k, vector<vector<T> >(m, vector<T>(n, x)));
33 }
34 
35 } // namespace math
36 } // namespace stan
37 
38 #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–2018, Stan Development Team.