generate_bare_type.hpp
Go to the documentation of this file.
1 #ifndef STAN_LANG_GENERATOR_GENERATE_BARE_TYPE_HPP
2 #define STAN_LANG_GENERATOR_GENERATE_BARE_TYPE_HPP
3 
4 #include <stan/lang/ast.hpp>
5 #include <ostream>
6 #include <string>
7 
8 namespace stan {
9  namespace lang {
10 
11 
12  /**
13  * Generate the basic type for the specified expression type
14  * without dimensions, using the specified scalar type string,
15  * writing to the specified stream.
16  *
17  * @param[in] t expression type
18  * @param[in] scalar_t_name name of scalar type for double values
19  * and containers
20  * @param[in] o stream for generating
21  */
23  const std::string& scalar_t_name,
24  std::ostream& o) {
25  for (size_t d = 0; d < t.num_dims_; ++d)
26  o << "std::vector<";
27  bool is_template_type = false;
28  if (t.base_type_.is_int_type()) {
29  o << "int";
30  is_template_type = false;
31  } else if (t.base_type_.is_double_type()) {
32  o << scalar_t_name;
33  is_template_type = false;
34  } else if (t.base_type_.is_vector_type()) {
35  o << "Eigen::Matrix<"
36  << scalar_t_name
37  << ", Eigen::Dynamic,1>";
38  is_template_type = true;
39  } else if (t.base_type_.is_row_vector_type()) {
40  o << "Eigen::Matrix<"
41  << scalar_t_name
42  << ", 1,Eigen::Dynamic>";
43  is_template_type = true;
44  } else if (t.base_type_.is_matrix_type()) {
45  o << "Eigen::Matrix<"
46  << scalar_t_name
47  << ", Eigen::Dynamic,Eigen::Dynamic>";
48  is_template_type = true;
49  } else if (t.base_type_.is_void_type()) {
50  o << "void";
51  } else {
52  o << "UNKNOWN TYPE";
53  }
54  for (size_t d = 0; d < t.num_dims_; ++d) {
55  if (d > 0 || is_template_type)
56  o << " ";
57  o << ">";
58  }
59  }
60 
61  }
62 }
63 #endif
std::size_t num_dims_
Definition: expr_type.hpp:31
double lang
Definition: runWimpSim.h:113
Float_t d
Definition: plot.C:236
void generate_bare_type(const expr_type &t, const std::string &scalar_t_name, std::ostream &o)
base_expr_type base_type_
Definition: expr_type.hpp:26
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154