Stan  1.0
probability, sampling & optimization
ast.hpp
Go to the documentation of this file.
1 #ifndef __STAN__GM__AST_HPP__
2 #define __STAN__GM__AST_HPP__
3 
4 #include <map>
5 #include <vector>
6 
7 #include <boost/variant/recursive_variant.hpp>
8 
9 namespace stan {
10 
11  namespace gm {
12 
15  struct nil { };
16 
17  // components of abstract syntax tree
18  struct array_literal;
19  struct assignment;
20  struct binary_op;
21  struct conditional_statement;
22  struct distribution;
23  struct double_var_decl;
24  struct double_literal;
25  struct expression;
26  struct for_statement;
27  struct fun;
28  struct identifier;
29  struct index_op;
30  struct int_literal;
31  struct inv_var_decl;
32  struct matrix_var_decl;
33  struct no_op_statement;
34  struct ordered_var_decl;
36  struct print_statement;
37  struct program;
38  struct range;
39  struct row_vector_var_decl;
40  struct sample;
41  struct simplex_var_decl;
42  struct statement;
43  struct statements;
44  struct unary_op;
45  struct variable;
46  struct variable_dims;
47  struct var_decl;
48  struct var_type;
49  struct vector_var_decl;
50  struct while_statement;
51 
52  // forward declarable enum hack (can't fwd-decl enum)
53  typedef int base_expr_type;
54  const int INT_T = 1;
55  const int DOUBLE_T = 2;
56  const int VECTOR_T = 3;
57  const int ROW_VECTOR_T = 4;
58  const int MATRIX_T = 5;
59  const int ILL_FORMED_T = 6;
60 
61  std::ostream& write_base_expr_type(std::ostream& o, base_expr_type type);
62 
63  struct expr_type {
65  size_t num_dims_;
66  expr_type();
67  expr_type(const base_expr_type base_type);
68  expr_type(const base_expr_type base_type,
69  size_t num_dims);
70  bool operator==(const expr_type& et) const;
71  bool operator!=(const expr_type& et) const;
72  bool is_primitive() const;
73  bool is_primitive_int() const;
74  bool is_primitive_double() const;
75  bool is_ill_formed() const;
76  base_expr_type type() const;
77  size_t num_dims() const;
78  };
79 
80  std::ostream& operator<<(std::ostream& o, const expr_type& et);
81 
83 
85  const expr_type& et2);
86 
87  typedef std::pair<expr_type, std::vector<expr_type> > function_signature_t;
88 
90  public:
91  static function_signatures& instance();
92  void add(const std::string& name,
93  const expr_type& result_type,
94  const std::vector<expr_type>& arg_types);
95  void add(const std::string& name,
96  const expr_type& result_type);
97  void add(const std::string& name,
98  const expr_type& result_type,
99  const expr_type& arg_type);
100  void add(const std::string& name,
101  const expr_type& result_type,
102  const expr_type& arg_type1,
103  const expr_type& arg_type2);
104  void add(const std::string& name,
105  const expr_type& result_type,
106  const expr_type& arg_type1,
107  const expr_type& arg_type2,
108  const expr_type& arg_type3);
109  void add(const std::string& name,
110  const expr_type& result_type,
111  const expr_type& arg_type1,
112  const expr_type& arg_type2,
113  const expr_type& arg_type3,
114  const expr_type& arg_type4);
115  void add(const std::string& name,
116  const expr_type& result_type,
117  const expr_type& arg_type1,
118  const expr_type& arg_type2,
119  const expr_type& arg_type3,
120  const expr_type& arg_type4,
121  const expr_type& arg_type5);
122  void add_nullary(const::std::string& name);
123  void add_unary(const::std::string& name);
124  void add_binary(const::std::string& name);
125  void add_ternary(const::std::string& name);
126  void add_quaternary(const::std::string& name);
127  int num_promotions(const std::vector<expr_type>& call_args,
128  const std::vector<expr_type>& sig_args);
129  expr_type get_result_type(const std::string& name,
130  const std::vector<expr_type>& args,
131  std::ostream& error_msgs);
132  private:
135  std::map<std::string, std::vector<function_signature_t> > sigs_map_;
136  static function_signatures* sigs_; // init below outside of class
137  };
138 
139  struct statements {
140  std::vector<var_decl> local_decl_;
141  std::vector<statement> statements_;
142  statements();
143  statements(const std::vector<var_decl>& local_decl,
144  const std::vector<statement>& stmts);
145  };
146 
147 
148  struct distribution {
149  std::string family_;
150  std::vector<expression> args_;
151  };
152 
153  struct expression_type_vis : public boost::static_visitor<expr_type> {
154  expr_type operator()(const nil& e) const;
155  expr_type operator()(const int_literal& e) const;
156  expr_type operator()(const double_literal& e) const;
157  expr_type operator()(const array_literal& e) const;
158  expr_type operator()(const variable& e) const;
159  expr_type operator()(const fun& e) const;
160  expr_type operator()(const index_op& e) const;
161  expr_type operator()(const binary_op& e) const;
162  expr_type operator()(const unary_op& e) const;
163  // template <typename T> expr_type operator()(const T& e) const;
164  };
165 
166 
167 
168 
169  struct expression;
170 
171  struct expression {
172  typedef boost::variant<boost::recursive_wrapper<nil>,
173  boost::recursive_wrapper<int_literal>,
174  boost::recursive_wrapper<double_literal>,
175  boost::recursive_wrapper<array_literal>,
176  boost::recursive_wrapper<variable>,
177  boost::recursive_wrapper<fun>,
178  boost::recursive_wrapper<index_op>,
179  boost::recursive_wrapper<binary_op>,
180  boost::recursive_wrapper<unary_op> >
182 
183  expression();
184  expression(const expression& e);
185 
186  // template <typename Expr> expression(const Expr& expr);
187  expression(const nil& expr);
188  expression(const int_literal& expr);
189  expression(const double_literal& expr);
190  expression(const array_literal& expr);
191  expression(const variable& expr);
192  expression(const fun& expr);
193  expression(const index_op& expr);
194  expression(const binary_op& expr);
195  expression(const unary_op& expr);
196  expression(const expression_t& expr_);
197 
198  expr_type expression_type() const;
199 
200  expression& operator+=(const expression& rhs);
201  expression& operator-=(const expression& rhs);
202  expression& operator*=(const expression& rhs);
203  expression& operator/=(const expression& rhs);
204 
206  };
207 
208  // struct contains_var : public boost::static_visitor<bool> {
209  // const variable_map& var_map_;
210  // contains_var(const variable_map& var_map);
211  // bool operator()(const nil& e) const;
212  // bool operator()(const int_literal& e) const;
213  // bool operator()(const double_literal& e) const;
214  // bool operator()(const array_literal& e) const;
215  // bool operator()(const variable& e) const;
216  // bool operator()(const fun& e) const;
217  // bool operator()(const index_op& e) const;
218  // bool operator()(const binary_op& e) const;
219  // bool operator()(const unary_op& e) const;
220  // };
221 
222  struct printable {
223  typedef boost::variant<boost::recursive_wrapper<std::string>,
224  boost::recursive_wrapper<expression> >
226 
227  printable();
229  printable(const std::string& msg);
231  printable(const printable& printable);
232 
234  };
235 
236  struct is_nil_op : public boost::static_visitor<bool> {
237  bool operator()(const nil& x) const;
238  bool operator()(const int_literal& x) const;
239  bool operator()(const double_literal& x) const;
240  bool operator()(const array_literal& x) const;
241  bool operator()(const variable& x) const;
242  bool operator()(const fun& x) const;
243  bool operator()(const index_op& x) const;
244  bool operator()(const binary_op& x) const;
245  bool operator()(const unary_op& x) const;
246 
247  // template <typename T>
248  // bool operator()(const T& x) const;
249  };
250 
251  bool is_nil(const expression& e);
252 
253  struct variable_dims {
254  std::string name_;
255  std::vector<expression> dims_;
256  variable_dims();
257  variable_dims(std::string const& name,
258  std::vector<expression> const& dims);
259  };
260 
261 
262  struct int_literal {
263  int val_;
265  int_literal();
266  int_literal(int val);
267  int_literal(const int_literal& il);
268  int_literal& operator=(const int_literal& il);
269  };
270 
271 
272  struct double_literal {
273  double val_;
275  double_literal();
276  double_literal(double val);
278  };
279 
280  struct array_literal {
281  std::vector<expression> args_;
283  array_literal();
284  array_literal(const std::vector<expression>& args);
286  };
287 
288  struct variable {
289  std::string name_;
291  variable();
292  variable(std::string name);
293  void set_type(const base_expr_type& base_type,
294  size_t num_dims);
295  };
296 
297  struct fun {
298  std::string name_;
299  std::vector<expression> args_;
301  fun();
302  fun(std::string const& name,
303  std::vector<expression> const& args);
304  void infer_type(); // FIXME: is this used anywhere?
305  };
306 
307  size_t total_dims(const std::vector<std::vector<expression> >& dimss);
308 
309  expr_type infer_type_indexing(const base_expr_type& expr_base_type,
310  size_t num_expr_dims,
311  size_t num_index_dims);
312 
314  size_t num_index_dims);
315 
316 
317  struct index_op {
319  std::vector<std::vector<expression> > dimss_;
321  index_op();
322  // vec of vec for e.g., e[1,2][3][4,5,6]
323  index_op(const expression& expr,
324  const std::vector<std::vector<expression> >& dimss);
325  void infer_type();
326  };
327 
328 
329  struct binary_op {
330  std::string op;
334  binary_op();
335  binary_op(const expression& left,
336  const std::string& op,
337  const expression& right);
338  };
339 
340  struct unary_op {
341  char op;
344  unary_op(char op,
345  expression const& subject);
346  };
347 
348  struct range {
351  range();
352  range(expression const& low,
353  expression const& high);
354  bool has_low() const;
355  bool has_high() const;
356  };
357 
358  typedef int var_origin;
359  const int data_origin = 1;
360  const int transformed_data_origin = 2;
361  const int parameter_origin = 3;
363  const int derived_origin = 5;
364  const int local_origin = 6;
365 
366 
367 
368  void print_var_origin(std::ostream& o, const var_origin& vo);
369 
370  struct base_var_decl {
371  std::string name_;
372  std::vector<expression> dims_;
374  base_var_decl();
375  base_var_decl(const base_expr_type& base_type);
376  base_var_decl(const std::string& name,
377  const std::vector<expression>& dims,
378  const base_expr_type& base_type);
379  };
380 
381  struct variable_map {
382  typedef std::pair<base_var_decl,var_origin> range_t;
383  std::map<std::string, range_t> map_;
384  bool exists(const std::string& name) const;
385  base_var_decl get(const std::string& name) const;
386  base_expr_type get_base_type(const std::string& name) const;
387  size_t get_num_dims(const std::string& name) const;
388  var_origin get_origin(const std::string& name) const;
389  void add(const std::string& name,
390  const base_var_decl& base_decl,
391  const var_origin& vo);
392  void remove(const std::string& name);
393  };
394 
395  struct int_var_decl : public base_var_decl {
397  int_var_decl();
398  int_var_decl(range const& range,
399  std::string const& name,
400  std::vector<expression> const& dims);
401  };
402 
403 
404  struct double_var_decl : public base_var_decl {
406  double_var_decl();
407  double_var_decl(range const& range,
408  std::string const& name,
409  std::vector<expression> const& dims);
410  };
411 
412  struct simplex_var_decl : public base_var_decl {
415  simplex_var_decl(expression const& K,
416  std::string const& name,
417  std::vector<expression> const& dims);
418  };
419 
420  struct ordered_var_decl : public base_var_decl {
423  ordered_var_decl(expression const& K,
424  std::string const& name,
425  std::vector<expression> const& dims);
426  };
427 
432  std::string const& name,
433  std::vector<expression> const& dims);
434  };
435 
436  struct vector_var_decl : public base_var_decl {
439  vector_var_decl();
440  vector_var_decl(range const& range,
441  expression const& M,
442  std::string const& name,
443  std::vector<expression> const& dims);
444  };
445 
451  expression const& N,
452  std::string const& name,
453  std::vector<expression> const& dims);
454  };
455 
456  struct matrix_var_decl : public base_var_decl {
460  matrix_var_decl();
461  matrix_var_decl(range const& range,
462  expression const& M,
463  expression const& N,
464  std::string const& name,
465  std::vector<expression> const& dims);
466  };
467 
468 
469 
470 
471 
476  std::string const& name,
477  std::vector<expression> const& dims);
478  };
479 
480 
481 
486  std::string const& name,
487  std::vector<expression> const& dims);
488  };
489 
490 
491 
492  struct name_vis : public boost::static_visitor<std::string> {
493  name_vis();
494  std::string operator()(const nil& x) const;
495  std::string operator()(const int_var_decl& x) const;
496  std::string operator()(const double_var_decl& x) const;
497  std::string operator()(const vector_var_decl& x) const;
498  std::string operator()(const row_vector_var_decl& x) const;
499  std::string operator()(const matrix_var_decl& x) const;
500  std::string operator()(const simplex_var_decl& x) const;
501  std::string operator()(const ordered_var_decl& x) const;
502  std::string operator()(const positive_ordered_var_decl& x) const;
503  std::string operator()(const cov_matrix_var_decl& x) const;
504  std::string operator()(const corr_matrix_var_decl& x) const;
505  };
506 
507 
508 
509 
510  struct var_decl {
511  typedef boost::variant<boost::recursive_wrapper<nil>,
512  boost::recursive_wrapper<int_var_decl>,
513  boost::recursive_wrapper<double_var_decl>,
514  boost::recursive_wrapper<vector_var_decl>,
515  boost::recursive_wrapper<row_vector_var_decl>,
516  boost::recursive_wrapper<matrix_var_decl>,
517  boost::recursive_wrapper<simplex_var_decl>,
518  boost::recursive_wrapper<ordered_var_decl>,
519  boost::recursive_wrapper<positive_ordered_var_decl>,
520  boost::recursive_wrapper<cov_matrix_var_decl>,
521  boost::recursive_wrapper<corr_matrix_var_decl> >
523 
525 
526  var_decl();
527 
528  // template <typename Decl>
529  // var_decl(Decl const& decl);
530  var_decl(const var_decl_t& decl);
531  var_decl(const nil& decl);
532  var_decl(const int_var_decl& decl);
533  var_decl(const double_var_decl& decl);
534  var_decl(const vector_var_decl& decl);
535  var_decl(const row_vector_var_decl& decl);
536  var_decl(const matrix_var_decl& decl);
537  var_decl(const simplex_var_decl& decl);
538  var_decl(const ordered_var_decl& decl);
539  var_decl(const positive_ordered_var_decl& decl);
540  var_decl(const cov_matrix_var_decl& decl);
541  var_decl(const corr_matrix_var_decl& decl);
542 
543  std::string name() const;
544  };
545 
546  struct statement {
547  typedef boost::variant<boost::recursive_wrapper<nil>,
548  boost::recursive_wrapper<assignment>,
549  boost::recursive_wrapper<sample>,
550  boost::recursive_wrapper<statements>,
551  boost::recursive_wrapper<for_statement>,
552  boost::recursive_wrapper<conditional_statement>,
553  boost::recursive_wrapper<while_statement>,
554  boost::recursive_wrapper<print_statement>,
555  boost::recursive_wrapper<no_op_statement> >
557 
559 
560  statement();
561  statement(const statement_t& st);
562 
563  statement(const nil& st);
564  statement(const assignment& st);
565  statement(const sample& st);
566  statement(const statements& st);
567  statement(const for_statement& st);
568  statement(const conditional_statement& st);
569  statement(const while_statement& st);
570  statement(const print_statement& st);
571  statement(const no_op_statement& st);
572 
573  // template <typename Statement>
574  // statement(const Statement& statement);
575  };
576 
577  struct for_statement {
578  std::string variable_;
581  for_statement();
582  for_statement(std::string& variable,
583  range& range,
584  statement& stmt);
585  };
586 
587  // bodies may be 1 longer than conditions due to else
589  std::vector<expression> conditions_;
590  std::vector<statement> bodies_;
592  conditional_statement(const std::vector<expression>& conditions,
593  const std::vector<statement>& statements);
594  };
595 
599  while_statement();
600  while_statement(const expression& condition,
601  const statement& body);
602  };
603 
605  std::vector<printable> printables_;
606  print_statement();
607  print_statement(const std::vector<printable>& printables);
608  };
609 
610 
612  // no op, no data
613  };
614 
615 
616 
617  struct program {
618  std::vector<var_decl> data_decl_;
619  std::pair<std::vector<var_decl>,std::vector<statement> >
621  std::vector<var_decl> parameter_decl_;
622  std::pair<std::vector<var_decl>,std::vector<statement> >
625  std::pair<std::vector<var_decl>,std::vector<statement> > generated_decl_;
626  program();
627  program(const std::vector<var_decl>& data_decl,
628  const std::pair<std::vector<var_decl>,
629  std::vector<statement> >& derived_data_decl,
630  const std::vector<var_decl>& parameter_decl,
631  const std::pair<std::vector<var_decl>,
632  std::vector<statement> >& derived_decl,
633  const statement& st,
634  const std::pair<std::vector<var_decl>,
635  std::vector<statement> >& generated_decl);
636 
637 
638  };
639 
640  struct sample {
644  sample();
646  distribution& dist);
647  bool is_ill_formed() const;
648  };
649 
650  struct assignment {
651  variable_dims var_dims_; // lhs_var[dim0,...,dimN-1]
652  expression expr_; // = rhs
653  base_var_decl var_type_; // type of lhs_var
654  assignment();
655  assignment(variable_dims& var_dims,
656  expression& expr);
657  };
658 
659  // FIXME: is this next necessary dependency?
660  // from generator.hpp
661  void generate_expression(const expression& e, std::ostream& o);
662 
663 
664 }
665  }
666 
667 #endif
void add_ternary(const ::std::string &name)
Definition: ast_def.cpp:193
void add(const std::string &name, const expr_type &result_type, const std::vector< expr_type > &arg_types)
Definition: ast_def.cpp:118
void add_binary(const ::std::string &name)
Definition: ast_def.cpp:190
void add_nullary(const ::std::string &name)
Definition: ast_def.cpp:184
void add_quaternary(const ::std::string &name)
Definition: ast_def.cpp:196
static function_signatures & instance()
Definition: ast_def.cpp:112
int num_promotions(const std::vector< expr_type > &call_args, const std::vector< expr_type > &sig_args)
Definition: ast_def.cpp:199
void add_unary(const ::std::string &name)
Definition: ast_def.cpp:187
expr_type get_result_type(const std::string &name, const std::vector< expr_type > &args, std::ostream &error_msgs)
Definition: ast_def.cpp:218
size_t total_dims(const std::vector< std::vector< expression > > &dimss)
Definition: ast_def.cpp:471
const int parameter_origin
Definition: ast.hpp:361
expr_type infer_type_indexing(const base_expr_type &expr_base_type, size_t num_expr_dims, size_t num_index_dims)
Definition: ast_def.cpp:479
const int ROW_VECTOR_T
Definition: ast.hpp:57
std::ostream & write_base_expr_type(std::ostream &o, base_expr_type type)
Definition: ast_def.cpp:23
const int INT_T
Definition: ast.hpp:54
int var_origin
Definition: ast.hpp:358
const int ILL_FORMED_T
Definition: ast.hpp:59
expr_type promote_primitive(const expr_type &et)
Definition: ast_def.cpp:99
void generate_expression(const expression &e, std::ostream &o)
Definition: generator.hpp:191
const int transformed_data_origin
Definition: ast.hpp:360
const int DOUBLE_T
Definition: ast.hpp:55
bool is_nil(const expression &e)
Definition: ast_def.cpp:392
const int VECTOR_T
Definition: ast.hpp:56
const int data_origin
Definition: ast.hpp:359
std::pair< expr_type, std::vector< expr_type > > function_signature_t
Definition: ast.hpp:87
const int transformed_parameter_origin
Definition: ast.hpp:362
int base_expr_type
Definition: ast.hpp:50
const int local_origin
Definition: ast.hpp:364
std::ostream & operator<<(std::ostream &o, const expr_type &et)
Definition: ast_def.cpp:92
const int derived_origin
Definition: ast.hpp:363
const int MATRIX_T
Definition: ast.hpp:58
void print_var_origin(std::ostream &o, const var_origin &vo)
Definition: ast_def.cpp:550
double e()
Return the base of the natural logarithm.
double dist(const std::vector< double > &x, const std::vector< double > &y)
Definition: util.hpp:61
Probability, optimization and sampling library.
Definition: agrad.cpp:6
std::vector< expression > args_
Definition: ast.hpp:281
array_literal & operator=(const array_literal &al)
Definition: ast_def.cpp:445
variable_dims var_dims_
Definition: ast.hpp:651
base_var_decl var_type_
Definition: ast.hpp:653
expression expr_
Definition: ast.hpp:652
std::vector< expression > dims_
Definition: ast.hpp:372
base_expr_type base_type_
Definition: ast.hpp:373
std::string name_
Definition: ast.hpp:371
expression left
Definition: ast.hpp:331
expr_type type_
Definition: ast.hpp:333
expression right
Definition: ast.hpp:332
std::string op
Definition: ast.hpp:330
std::vector< expression > conditions_
Definition: ast.hpp:589
std::vector< statement > bodies_
Definition: ast.hpp:590
std::vector< expression > args_
Definition: ast.hpp:150
std::string family_
Definition: ast.hpp:149
double_literal & operator=(const double_literal &dl)
Definition: ast_def.cpp:430
bool is_primitive() const
Definition: ast_def.cpp:70
bool operator==(const expr_type &et) const
Definition: ast_def.cpp:63
bool operator!=(const expr_type &et) const
Definition: ast_def.cpp:67
bool is_primitive_int() const
Definition: ast_def.cpp:74
base_expr_type type() const
Definition: ast_def.cpp:85
bool is_primitive_double() const
Definition: ast_def.cpp:78
bool is_ill_formed() const
Definition: ast_def.cpp:82
size_t num_dims_
Definition: ast.hpp:65
size_t num_dims() const
Definition: ast_def.cpp:88
base_expr_type base_type_
Definition: ast.hpp:64
expr_type operator()(const nil &e) const
Definition: ast_def.cpp:268
expression & operator*=(const expression &rhs)
Definition: ast_def.cpp:890
expr_type expression_type() const
Definition: ast_def.cpp:306
expression & operator+=(const expression &rhs)
Definition: ast_def.cpp:880
expression & operator/=(const expression &rhs)
Definition: ast_def.cpp:895
expression & operator-=(const expression &rhs)
Definition: ast_def.cpp:885
boost::variant< boost::recursive_wrapper< nil >, boost::recursive_wrapper< int_literal >, boost::recursive_wrapper< double_literal >, boost::recursive_wrapper< array_literal >, boost::recursive_wrapper< variable >, boost::recursive_wrapper< fun >, boost::recursive_wrapper< index_op >, boost::recursive_wrapper< binary_op >, boost::recursive_wrapper< unary_op > > expression_t
Definition: ast.hpp:181
expression_t expr_
Definition: ast.hpp:205
statement statement_
Definition: ast.hpp:580
std::string variable_
Definition: ast.hpp:578
void infer_type()
Definition: ast_def.cpp:466
std::string name_
Definition: ast.hpp:298
std::vector< expression > args_
Definition: ast.hpp:299
expr_type type_
Definition: ast.hpp:300
std::vector< std::vector< expression > > dimss_
Definition: ast.hpp:319
expression expr_
Definition: ast.hpp:318
expr_type type_
Definition: ast.hpp:320
int_literal & operator=(const int_literal &il)
Definition: ast_def.cpp:416
expr_type type_
Definition: ast.hpp:264
bool operator()(const nil &x) const
Definition: ast_def.cpp:379
std::string operator()(const nil &x) const
Definition: ast_def.cpp:720
Placeholder struct for boost::variant default ctors.
Definition: ast.hpp:15
std::vector< printable > printables_
Definition: ast.hpp:605
boost::variant< boost::recursive_wrapper< std::string >, boost::recursive_wrapper< expression > > printable_t
Definition: ast.hpp:225
printable_t printable_
Definition: ast.hpp:233
std::pair< std::vector< var_decl >, std::vector< statement > > derived_decl_
Definition: ast.hpp:623
std::vector< var_decl > data_decl_
Definition: ast.hpp:618
statement statement_
Definition: ast.hpp:624
std::pair< std::vector< var_decl >, std::vector< statement > > generated_decl_
Definition: ast.hpp:625
std::vector< var_decl > parameter_decl_
Definition: ast.hpp:621
std::pair< std::vector< var_decl >, std::vector< statement > > derived_data_decl_
Definition: ast.hpp:620
expression high_
Definition: ast.hpp:350
bool has_low() const
Definition: ast_def.cpp:543
bool has_high() const
Definition: ast_def.cpp:546
expression low_
Definition: ast.hpp:349
bool is_ill_formed() const
Definition: ast_def.cpp:862
expression expr_
Definition: ast.hpp:641
distribution dist_
Definition: ast.hpp:642
range truncation_
Definition: ast.hpp:643
statement_t statement_
Definition: ast.hpp:558
boost::variant< boost::recursive_wrapper< nil >, boost::recursive_wrapper< assignment >, boost::recursive_wrapper< sample >, boost::recursive_wrapper< statements >, boost::recursive_wrapper< for_statement >, boost::recursive_wrapper< conditional_statement >, boost::recursive_wrapper< while_statement >, boost::recursive_wrapper< print_statement >, boost::recursive_wrapper< no_op_statement > > statement_t
Definition: ast.hpp:556
std::vector< var_decl > local_decl_
Definition: ast.hpp:140
std::vector< statement > statements_
Definition: ast.hpp:141
expression subject
Definition: ast.hpp:342
expr_type type_
Definition: ast.hpp:343
unary_op(char op, expression const &subject)
Definition: ast_def.cpp:529
var_decl_t decl_
Definition: ast.hpp:524
boost::variant< boost::recursive_wrapper< nil >, boost::recursive_wrapper< int_var_decl >, boost::recursive_wrapper< double_var_decl >, boost::recursive_wrapper< vector_var_decl >, boost::recursive_wrapper< row_vector_var_decl >, boost::recursive_wrapper< matrix_var_decl >, boost::recursive_wrapper< simplex_var_decl >, boost::recursive_wrapper< ordered_var_decl >, boost::recursive_wrapper< positive_ordered_var_decl >, boost::recursive_wrapper< cov_matrix_var_decl >, boost::recursive_wrapper< corr_matrix_var_decl > > var_decl_t
Definition: ast.hpp:522
std::string name() const
Definition: ast_def.cpp:778
std::string name_
Definition: ast.hpp:254
std::vector< expression > dims_
Definition: ast.hpp:255
base_expr_type get_base_type(const std::string &name) const
Definition: ast_def.cpp:588
std::map< std::string, range_t > map_
Definition: ast.hpp:383
void add(const std::string &name, const base_var_decl &base_decl, const var_origin &vo)
Definition: ast_def.cpp:599
std::pair< base_var_decl, var_origin > range_t
Definition: ast.hpp:382
base_var_decl get(const std::string &name) const
Definition: ast_def.cpp:583
var_origin get_origin(const std::string &name) const
Definition: ast_def.cpp:594
void remove(const std::string &name)
Definition: ast_def.cpp:604
bool exists(const std::string &name) const
Definition: ast_def.cpp:580
size_t get_num_dims(const std::string &name) const
Definition: ast_def.cpp:591
expr_type type_
Definition: ast.hpp:290
void set_type(const base_expr_type &base_type, size_t num_dims)
Definition: ast_def.cpp:453
std::string name_
Definition: ast.hpp:289
expression condition_
Definition: ast.hpp:597

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