Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
stan_print.hpp
Go to the documentation of this file.
1 #ifndef __STAN__MATH__MATRIX__STAN_PRINT_HPP__
2 #define __STAN__MATH__MATRIX__STAN_PRINT_HPP__
3 
4 #include <vector>
6 
7 namespace stan {
8  namespace math {
9  // prints used in generator for print() statements in modeling language
10 
11  template <typename T>
12  void stan_print(std::ostream* o, const T& x) {
13  *o << x;
14  }
15 
16  template <typename T>
17  void stan_print(std::ostream* o, const std::vector<T>& x) {
18  *o << '[';
19  for (int i = 0; i < x.size(); ++i) {
20  if (i > 0) *o << ',';
21  stan_print(o,x[i]);
22  }
23  *o << ']';
24  }
25 
26  template <typename T>
27  void stan_print(std::ostream* o, const Eigen::Matrix<T,Eigen::Dynamic,1>& x) {
28  *o << '[';
29  for (int i = 0; i < x.size(); ++i) {
30  if (i > 0) *o << ',';
31  stan_print(o,x(i));
32  }
33  *o << ']';
34  }
35 
36  template <typename T>
37  void stan_print(std::ostream* o, const Eigen::Matrix<T,1,Eigen::Dynamic>& x) {
38  *o << '[';
39  for (int i = 0; i < x.size(); ++i) {
40  if (i > 0) *o << ',';
41  stan_print(o,x(i));
42  }
43  *o << ']';
44  }
45 
46  template <typename T>
47  void stan_print(std::ostream* o,
48  const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic>& x) {
49  *o << '[';
50  for (int i = 0; i < x.rows(); ++i) {
51  if (i > 0) *o << ',';
52  stan_print(o,x.row(i));
53  }
54  *o << ']';
55  }
56 
57  }
58 }
59 #endif

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