1 #ifndef STAN_LANG_AST_DEF_CPP 2 #define STAN_LANG_AST_DEF_CPP 4 #include <boost/variant/apply_visitor.hpp> 5 #include <boost/variant/recursive_variant.hpp> 73 return !(*
this == et);
125 for (
size_t i = 1; i < et.
num_dims(); ++i)
146 if (sigs_ == 0)
return;
159 std::pair<std::string,
162 user_defined_set_.insert(name_sig);
169 return user_defined_set_.find(name_sig) != user_defined_set_.end();
174 if (sigs_map_.find(name) == sigs_map_.end())
176 const std::vector<function_signature_t> sigs = sigs_map_[name];
177 for (
size_t i = 0; i < sigs.size(); ++i)
178 if (sig.second == sigs[i].second)
188 map<string, vector<function_signature_t> >::const_iterator it
189 = sigs_map_.find(fun);
190 if (it == sigs_map_.end())
192 const vector<function_signature_t> sigs = it->second;
193 for (
size_t i = 0; i < sigs.size(); ++i) {
194 if (sigs[i].second.size() == 0
195 || sigs[i].second[0].base_type_ !=
INT_T)
203 const std::vector<expr_type>& arg_types) {
208 std::vector<expr_type> arg_types;
209 add(name, result_type, arg_types);
214 std::vector<expr_type> arg_types;
215 arg_types.push_back(arg_type);
216 add(name, result_type, arg_types);
222 std::vector<expr_type> arg_types;
223 arg_types.push_back(arg_type1);
224 arg_types.push_back(arg_type2);
225 add(name, result_type, arg_types);
232 std::vector<expr_type> arg_types;
233 arg_types.push_back(arg_type1);
234 arg_types.push_back(arg_type2);
235 arg_types.push_back(arg_type3);
236 add(name, result_type, arg_types);
244 std::vector<expr_type> arg_types;
245 arg_types.push_back(arg_type1);
246 arg_types.push_back(arg_type2);
247 arg_types.push_back(arg_type3);
248 arg_types.push_back(arg_type4);
249 add(name, result_type, arg_types);
258 std::vector<expr_type> arg_types;
259 arg_types.push_back(arg_type1);
260 arg_types.push_back(arg_type2);
261 arg_types.push_back(arg_type3);
262 arg_types.push_back(arg_type4);
263 arg_types.push_back(arg_type5);
264 add(name, result_type, arg_types);
274 std::vector<expr_type> arg_types;
275 arg_types.push_back(arg_type1);
276 arg_types.push_back(arg_type2);
277 arg_types.push_back(arg_type3);
278 arg_types.push_back(arg_type4);
279 arg_types.push_back(arg_type5);
280 arg_types.push_back(arg_type6);
281 add(name, result_type, arg_types);
292 std::vector<expr_type> arg_types;
293 arg_types.push_back(arg_type1);
294 arg_types.push_back(arg_type2);
295 arg_types.push_back(arg_type3);
296 arg_types.push_back(arg_type4);
297 arg_types.push_back(arg_type5);
298 arg_types.push_back(arg_type6);
299 arg_types.push_back(arg_type7);
300 add(name, result_type, arg_types);
310 for (
size_t i = 0; i < 8; ++i) {
328 const std::vector<expr_type>& call_args,
329 const std::vector<expr_type>& sig_args) {
330 if (call_args.size() != sig_args.size()) {
333 int num_promotions = 0;
334 for (
size_t i = 0; i < call_args.size(); ++i) {
335 if (call_args[i] == sig_args[i]) {
338 && sig_args[i].is_primitive_double()) {
344 return num_promotions;
347 const std::vector<expr_type>& args,
349 if (!has_key(name))
return 0;
350 std::vector<function_signature_t> signatures = sigs_map_[name];
351 size_t min_promotions = std::numeric_limits<size_t>::max();
352 size_t num_matches = 0;
353 for (
size_t i = 0; i < signatures.size(); ++i) {
354 signature = signatures[i];
355 int promotions = num_promotions(args, signature.second);
356 if (promotions < 0)
continue;
357 size_t promotions_ui =
static_cast<size_t>(promotions);
358 if (promotions_ui < min_promotions) {
359 min_promotions = promotions_ui;
361 }
else if (promotions_ui == min_promotions) {
370 || name ==
"subtract" 371 || name ==
"multiply" 374 || name ==
"mdivide_left" 375 || name ==
"mdivide_right" 376 || name ==
"elt_multiply" 377 || name ==
"elt_divide";
381 return name ==
"minus" 382 || name ==
"logical_negation";
386 return name ==
"transpose";
397 if (name ==
"add")
return "+";
398 if (name ==
"subtract")
return "-";
399 if (name ==
"multiply")
return "*";
400 if (name ==
"divide")
return "/";
401 if (name ==
"modulus")
return "%";
402 if (name ==
"mdivide_left")
return "\\";
403 if (name ==
"mdivide_right")
return "/";
404 if (name ==
"elt_multiply")
return ".*";
405 if (name ==
"elt_divide")
return "./";
408 if (name ==
"minus")
return "-";
409 if (name ==
"logical_negation")
return "!";
412 if (name ==
"transpose")
return "'";
419 const std::vector<expr_type>& arg_types,
420 bool sampling_error_style,
421 std::ostream& msgs) {
422 static size_t OP_SIZE = std::string(
"operator").size();
424 if (name.size() > OP_SIZE && name.substr(0, OP_SIZE) ==
"operator") {
425 std::string operator_name = name.substr(OP_SIZE);
426 if (arg_types.size() == 2) {
427 msgs << arg_types[0] <<
" " << operator_name <<
" " << arg_types[1]
430 }
else if (arg_types.size() == 1) {
431 if (operator_name ==
"'")
432 msgs << arg_types[0] << operator_name << std::endl;
434 msgs << operator_name << arg_types[0] << std::endl;
439 msgs <<
"Operators must have 1 or 2 arguments." << std::endl;
442 if (sampling_error_style && arg_types.size() > 0)
443 msgs << arg_types[0] <<
" ~ ";
445 size_t start = sampling_error_style ? 1 : 0;
446 for (
size_t j = start; j < arg_types.size(); ++j) {
447 if (j > start) msgs <<
", ";
448 msgs << arg_types[j];
450 msgs <<
")" << std::endl;
454 const std::vector<expr_type>& args,
455 std::ostream& error_msgs,
456 bool sampling_error_style) {
457 std::vector<function_signature_t> signatures = sigs_map_[name];
458 size_t match_index = 0;
459 size_t min_promotions = std::numeric_limits<size_t>::max();
460 size_t num_matches = 0;
462 std::string display_name;
465 }
else if (sampling_error_style &&
ends_with(
"_log", name)) {
466 display_name = name.substr(0, name.size() - 4);
467 }
else if (sampling_error_style
469 display_name = name.substr(0, name.size() - 5);
474 for (
size_t i = 0; i < signatures.size(); ++i) {
475 int promotions = num_promotions(args, signatures[i].second);
476 if (promotions < 0)
continue;
477 size_t promotions_ui =
static_cast<size_t>(promotions);
478 if (promotions_ui < min_promotions) {
479 min_promotions = promotions_ui;
482 }
else if (promotions_ui == min_promotions) {
487 if (num_matches == 1)
488 return signatures[match_index].first;
492 if (num_matches == 0) {
493 error_msgs <<
"No matches for: " 494 << std::endl << std::endl;
496 error_msgs <<
"Ambiguous: " 497 << num_matches <<
" matches with " 498 << min_promotions <<
" integer promotions for: " 503 if (signatures.size() == 0) {
504 error_msgs << std::endl
505 << (sampling_error_style ?
"Distribution " :
"Function ")
506 << display_name <<
" not found.";
507 if (sampling_error_style)
508 error_msgs <<
" Require function with _lpdf or _lpmf or _log suffix";
509 error_msgs << std::endl;
511 error_msgs << std::endl
512 <<
"Available argument signatures for " 513 << display_name <<
":" << std::endl << std::endl;
515 for (
size_t i = 0; i < signatures.size(); ++i) {
517 sampling_error_style, error_msgs);
519 error_msgs << std::endl;
524 function_signatures::function_signatures() {
525 #include <stan/lang/function_signatures.h> 533 for (
set<pair<string, function_signature_t> >::const_iterator
534 it = user_defined_set_.begin();
535 it != user_defined_set_.end();
537 if (it->first == key)
549 for (map<
string, vector<function_signature_t> >::const_iterator
550 it = sigs_map_.begin();
551 it != sigs_map_.end();
553 result.insert(it->first);
558 return sigs_map_.find(key) != sigs_map_.end();
565 const std::string& name)
566 : arg_type_(arg_type),
570 std::vector<expression> dims;
578 const std::string& name,
579 const std::vector<arg_decl>& arg_decls,
582 : return_type_(return_type),
584 arg_decls_(arg_decls),
591 : decl_defs_(decl_defs) {
595 std::ostream& error_msgs)
596 : return_type_(return_type),
597 error_msgs_(error_msgs) {
600 error_msgs_ <<
"Expecting return, found nil statement." 605 error_msgs_ <<
"Expecting return, found assignment statement." 610 error_msgs_ <<
"Expecting return, found assignment statement." 615 error_msgs_ <<
"Expecting return, found sampling statement." 621 error_msgs_ <<
"Expecting return, found increment_log_prob statement." 626 error_msgs_ <<
"Expecting return, found increment_log_prob statement." 631 error_msgs_ <<
"Expecting return, found print statement." 636 error_msgs_ <<
"Expecting return, found reject statement." 641 error_msgs_ <<
"Expecting return, found no_op statement." 650 " statement sequence with empty body.")
670 <<
" does not match return type";
677 error_msgs_ << (
"Expecting return, found conditional" 678 " without final else.")
682 for (
size_t i = 0; i < st.
bodies_.size(); ++i)
691 "Returned expression does not match return type",
697 std::ostream& error_msgs) {
698 if (return_type ==
VOID_T)
701 return boost::apply_visitor(vis, statement.
statement_);
708 const std::vector<statement>& stmts)
709 : local_decl_(local_decl),
762 return boost::apply_visitor(vis,
expr_);
800 : var_map_(var_map) {
812 for (
size_t i = 0; i < e.
args_.size(); ++i)
813 if (boost::apply_visitor(*
this, e.
args_[i].expr_))
824 for (
size_t i = 0; i < e.
args_.size(); ++i)
825 if (boost::apply_visitor(*
this, e.
args_[i].expr_))
831 return boost::apply_visitor(*
this, e.
y0_.
expr_)
836 return boost::apply_visitor(*
this, e.
y0_.
expr_)
840 return boost::apply_visitor(*
this, e.
expr_.
expr_);
843 return boost::apply_visitor(*
this, e.
expr_.
expr_);
846 return boost::apply_visitor(*
this, e.
cond_.
expr_)
851 return boost::apply_visitor(*
this, e.
left.
expr_)
852 || boost::apply_visitor(*
this, e.
right.
expr_);
861 || name ==
"append_col" 864 || name ==
"diagonal" 867 || name ==
"negative_infinity" 868 || name ==
"not_a_number" 869 || name ==
"append_row" 870 || name ==
"rep_matrix" 871 || name ==
"rep_row_vector" 872 || name ==
"rep_vector" 875 || name ==
"positive_infinity" 877 || name ==
"subtract" 880 || name ==
"to_vector" 881 || name ==
"to_row_vector" 882 || name ==
"to_matrix" 883 || name ==
"to_array_1d" 884 || name ==
"to_array_2d" 885 || name ==
"transpose";
891 return boost::apply_visitor(vis, e.
expr_);
907 for (
size_t i = 0; i < e.
args_.size(); ++i)
908 if (boost::apply_visitor(*
this, e.
args_[i].expr_))
919 return boost::apply_visitor(*
this, e.
y0_.
expr_)
925 return boost::apply_visitor(*
this, e.
y0_.
expr_)
930 for (
size_t i = 0; i < e.
args_.size(); ++i)
931 if (boost::apply_visitor(*
this, e.
args_[i].expr_))
935 for (
size_t i = 0; i < e.
args_.size(); ++i)
942 return boost::apply_visitor(*
this, e.
expr_.
expr_);
945 return boost::apply_visitor(*
this, e.
expr_.
expr_);
969 if (e.
op ==
"*" || e.
op ==
"/")
981 return boost::apply_visitor(vis, e.
expr_);
990 const {
return false; }
1010 return boost::apply_visitor(ino, e.
expr_);
1015 std::vector<expression>
const& dims)
1076 const std::string& system_function_name,
1083 : integration_function_name_(integration_function_name),
1084 system_function_name_(system_function_name),
1095 const std::string& integration_function_name,
1096 const std::string& system_function_name,
1116 max_num_steps_(max_num_steps) {
1121 std::vector<expression>
const& args)
1126 size_t total_dims(
const std::vector<std::vector<expression> >& dimss) {
1128 for (
size_t i = 0; i < dimss.size(); ++i)
1129 total += dimss[i].size();
1134 size_t num_expr_dims,
1135 size_t num_index_dims) {
1136 if (num_index_dims <= num_expr_dims)
1137 return expr_type(expr_base_type, num_expr_dims - num_index_dims);
1138 if (num_index_dims == (num_expr_dims + 1)) {
1144 if (num_index_dims == (num_expr_dims + 2))
1153 size_t num_index_dims) {
1162 const std::vector<std::vector<expression> >& dimss)
1173 const std::vector<idx>& idxs)
1184 true_val_(true_val),
1185 false_val_(false_val),
1187 false_val.expression_type())) {
1192 const std::string& op,
1198 right.expression_type())) {
1238 : lb_(lb),
ub_(ub) {
1273 return boost::apply_visitor(v, idx.
idx_);
1295 o <<
"transformed data";
1299 o <<
"transformed parameter";
1301 o <<
"generated quantities";
1305 o <<
"function argument";
1307 o <<
"function argument '_lp' suffixed";
1309 o <<
"function argument '_rng' suffixed";
1311 o <<
"void function argument";
1313 o <<
"void function argument '_lp' suffixed";
1315 o <<
"void function argument '_rng' suffixed";
1317 o <<
"UNKNOWN ORIGIN=" << vo;
1323 : base_type_(base_type) {
1326 const std::vector<expression>& dims,
1330 const std::vector<expression>& dims,
1336 return map_.find(name) != map_.end();
1341 throw std::invalid_argument(
"variable does not exist");
1342 return map_.find(name)->second.first;
1350 return get(name).
dims_.size();
1355 throw std::invalid_argument(
"variable does not exist");
1356 return map_.find(name)->second.second;
1362 map_[name] =
range_t(base_decl, vo);
1373 std::string
const& name,
1374 std::vector<expression>
const& dims,
1385 std::string
const& name,
1386 std::vector<expression>
const& dims,
1397 std::string
const& name,
1398 std::vector<expression>
const& dims)
1408 std::string
const& name,
1409 std::vector<expression>
const& dims)
1419 std::string
const& name,
1420 std::vector<expression>
const& dims)
1430 std::string
const& name,
1431 std::vector<expression>
const& dims)
1440 std::string
const& name,
1441 std::vector<expression>
const& dims,
1451 std::string
const& name,
1452 std::vector<expression>
const& dims,
1463 std::string
const& name,
1464 std::vector<expression>
const& dims,
1477 std::string
const& name,
1478 std::vector<expression>
const& dims)
1488 std::string
const& name,
1489 std::vector<expression>
const& dims)
1497 std::string
const& name,
1498 std::vector<expression>
const& dims)
1505 std::string
const& name,
1506 std::vector<expression>
const& dims)
1617 return std::vector<expression>();
1907 return boost::apply_visitor(vis,
statement_);
1914 : log_prob_(log_prob) {
1922 : variable_(variable),
1930 : condition_(condition),
1942 const std::vector<statement>& bodies)
1943 : conditions_(conditions),
1949 : return_value_(expr) {
1955 : printables_(printables) {
1966 const std::vector<var_decl>& data_decl,
1967 const std::pair<std::vector<var_decl>,
1968 std::vector<statement> >& derived_data_decl,
1969 const std::vector<var_decl>& parameter_decl,
1970 const std::pair<std::vector<var_decl>,
1971 std::vector<statement> >& derived_decl,
1973 const std::pair<std::vector<var_decl>,
1974 std::vector<statement> >& generated_decl)
1975 : function_decl_defs_(function_decl_defs),
1976 data_decl_(data_decl),
1977 derived_data_decl_(derived_data_decl),
1978 parameter_decl_(parameter_decl),
1979 derived_decl_(derived_decl),
1981 generated_decl_(generated_decl) {
2007 : var_dims_(var_dims),
2012 : var_name_(e.name_) {
2031 for (
size_t i = 0; i < e.
args_.size(); ++i)
2032 if (boost::apply_visitor(*
this, e.
args_[i].expr_))
2044 return boost::apply_visitor(*
this, e.
expr_.
expr_);
2047 return boost::apply_visitor(*
this, e.
expr_.
expr_);
2050 return boost::apply_visitor(*
this, e.
cond_.
expr_)
2055 return boost::apply_visitor(*
this, e.
left.
expr_)
2056 || boost::apply_visitor(*
this, e.
right.
expr_);
2065 : lhs_var_(lhs_var), idxs_(idxs), rhs_(rhs) { }
2069 return boost::apply_visitor(vis,
rhs_.
expr_);
2083 const std::vector<idx>& idxs) {
2088 size_t unindexed_dims = base_dims;
2089 size_t out_dims = 0U;
2091 for ( ; unindexed_dims > 0 && i < idxs.size(); ++i, --unindexed_dims)
2094 if (idxs.size() - i == 0) {
2095 return expr_type(base_type, out_dims + unindexed_dims);
2096 }
else if (idxs.size() - i == 1) {
2102 }
else if (base_type ==
VECTOR_T) {
2115 }
else if (idxs.size() - i == 2) {
2172 const std::vector<expression>& args) {
2173 std::vector<expr_type> arg_types;
2174 for (
size_t i = 0; i < args.size(); ++i)
2175 arg_types.push_back(args[i].expression_type());
2182 std::pair<std::string, function_signature_t>
2183 name_sig(name, sig);
2189 const std::vector<expression>& params) {
2190 std::vector<expression> variate_params;
2191 variate_params.push_back(variate);
2192 for (
size_t i = 0; i < params.size(); ++i)
2193 variate_params.push_back(params[i]);
2203 const std::string& failure_message,
2204 std::ostream& error_msgs) {
2205 bool assignable =
true;
2208 error_msgs <<
"Mismatched array dimensions.";
2214 error_msgs <<
"Base type mismatch. ";
2217 error_msgs << failure_message
2219 <<
" LHS type = " << l_type
2220 <<
"; RHS type = " << r_type
2226 const std::string& s) {
2227 size_t idx = s.rfind(suffix);
2228 return idx != std::string::npos
2229 && idx == (s.size() - suffix.size());
2232 std::string
get_cdf(
const std::string& dist_name) {
2234 return dist_name +
"_cdf_log";
2236 return dist_name +
"_lcdf";
2243 return dist_name +
"_ccdf_log";
2245 return dist_name +
"_lccdf";
2252 return dist_name +
"_log";
2254 return dist_name +
"_lpdf";
2256 return dist_name +
"_lpmf";
2268 return fname.substr(0, fname.size() - 5);
2270 return fname.substr(0, fname.size() - 5);
2272 return fname.substr(0, fname.size() - 4);
2283 return fname.substr(0, fname.size() - 5);
2285 return fname.substr(0, fname.size() - 8);
2296 return fname.substr(0, fname.size() - 6);
2298 return fname.substr(0, fname.size() - 9);
expr_type get_result_type(const std::string &name, const std::vector< expr_type > &args, std::ostream &error_msgs, bool sampling_error_style=false)
bool operator()(const uni_idx &i) const
var_occurs_vis(const variable &e)
bool is_primitive_int() const
increment_log_prob_statement()
std::string strip_ccdf_suffix(const std::string &dist_fun)
bool is_ill_formed() const
void add(const std::string &name, const expr_type &result_type, const std::vector< expr_type > &arg_types)
const int function_argument_origin
bool is_no_op_statement() const
const variable_map & var_map_
std::string integration_function_name_
bool is_operator(const std::string &name)
bool has_lp_suffix(const std::string &s)
std::vector< statement > statements_
std::vector< expression > operator()(const nil &x) const
contains_var(const variable_map &var_map)
bool is_fun_origin(const var_origin &vo)
std::vector< expression > dims_
expression & operator-=(const expression &rhs)
std::string strip_cdf_suffix(const std::string &dist_fun)
const int parameter_origin
bool has_cdf_suffix(const std::string &name)
const int function_argument_origin_rng
bool operator()(const nil &st) const
Probability, optimization and sampling library.
size_t total_dims(const std::vector< std::vector< expression > > &dimss)
bool operator<=(const expr_type &et) const
std::string get_prob_fun(const std::string &dist_name)
static function_signatures & instance()
bool is_multi_index(const idx &idx)
bool is_unary_postfix_operator(const std::string &name)
std::pair< base_var_decl, var_origin > range_t
bool is_ill_formed() const
std::vector< expression > args_
void add(const std::string &name, const base_var_decl &base_decl, const var_origin &vo)
bool has_prob_fun_suffix(const std::string &name)
std::string get_cdf(const std::string &dist_name)
expr_type operator()(const nil &e) const
bool operator<(const expr_type &et) const
std::vector< statement > bodies_
bool is_assignable(const expr_type &l_type, const expr_type &r_type, const std::string &failure_message, std::ostream &error_msgs)
bool has_rng_suffix(const std::string &s)
Template specification of functions in std for Stan.
int num_promotions(const std::vector< expr_type > &call_args, const std::vector< expr_type > &sig_args)
bool is_primitive_double() const
std::vector< printable > printables_
int get_signature_matches(const std::string &name, const std::vector< expr_type > &args, function_signature_t &signature)
const int transformed_parameter_origin
positive_ordered_var_decl()
void add_binary(const ::std::string &name)
bool operator()(const nil &x) const
expr_type expression_type() const
bool operator()(const nil &e) const
void set_type(const base_expr_type &base_type, size_t num_dims)
contains_nonparam_var(const variable_map &var_map)
bool operator!=(const expr_type &et) const
std::string get_ccdf(const std::string &dist_name)
expression operator()(const nil &x) const
const int function_argument_origin_lp
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< unit_vector_var_decl >, boost::recursive_wrapper< ordered_var_decl >, boost::recursive_wrapper< positive_ordered_var_decl >, boost::recursive_wrapper< cholesky_factor_var_decl >, boost::recursive_wrapper< cholesky_corr_var_decl >, boost::recursive_wrapper< cov_matrix_var_decl >, boost::recursive_wrapper< corr_matrix_var_decl > > var_decl_t
bool has_user_defined_key(const std::string &name) const
bool is_unary_operator(const std::string &name)
const variable_map & var_map_
void print_var_origin(std::ostream &o, const var_origin &vo)
void add_unary(const ::std::string &name)
expression & operator*=(const expression &rhs)
bool is_nil(const expression &e)
array_literal & operator=(const array_literal &al)
void remove(const std::string &name)
base_var_decl base_decl() const
const int void_function_argument_origin_rng
bool discrete_first_arg(const std::string &name) const
void add_nullary(const ::std::string &name)
bool fun_name_exists(const std::string &name)
const int model_name_origin
bool operator>(const expr_type &et) const
bool exists(const std::string &name) const
size_t get_num_dims(const std::string &name) const
bool ends_with(const std::string &suffix, const std::string &s)
bool returns_type(const expr_type &return_type, const statement &statement, std::ostream &error_msgs)
expression & operator+=(const expression &rhs)
bool operator()(const nil &st) const
bool operator()(const nil &x) const
boost::variant< boost::recursive_wrapper< nil >, boost::recursive_wrapper< assignment >, boost::recursive_wrapper< assgn >, boost::recursive_wrapper< sample >, boost::recursive_wrapper< increment_log_prob_statement >, boost::recursive_wrapper< expression >, boost::recursive_wrapper< statements >, boost::recursive_wrapper< for_statement >, boost::recursive_wrapper< conditional_statement >, boost::recursive_wrapper< while_statement >, boost::recursive_wrapper< break_continue_statement >, boost::recursive_wrapper< print_statement >, boost::recursive_wrapper< reject_statement >, boost::recursive_wrapper< return_statement >, boost::recursive_wrapper< no_op_statement > > statement_t
bool is_user_defined_prob_function(const std::string &name, const expression &variate, const std::vector< expression > ¶ms)
bool is_defined(const std::string &name, const function_signature_t &sig)
bool lhs_var_occurs_on_rhs() const
void add_quaternary(const ::std::string &name)
base_expr_type type() const
var_origin get_origin(const std::string &name) const
expr_type indexed_type(const expression &e, const std::vector< idx > &idxs)
Return the type of the expression indexed by the generalized index sequence.
bool is_user_defined(const std::pair< std::string, function_signature_t > &name_sig)
expr_type promote_primitive(const expr_type &et)
const int void_function_argument_origin
base_expr_type base_type_
bool operator>=(const expr_type &et) const
void print_signature(const std::string &name, const std::vector< expr_type > &arg_types, bool sampling_error_style, std::ostream &msgs)
std::ostream & operator<<(std::ostream &o, const expr_type &et)
std::pair< expr_type, std::vector< expr_type > > function_signature_t
boost::variant< boost::recursive_wrapper< std::string >, boost::recursive_wrapper< expression > > printable_t
bool has_non_param_var(const expression &e, const variable_map &var_map)
Returns true if the specified expression contains a variable that is defined as a transformed paramet...
const int void_function_argument_origin_lp
base_expr_type base_type_
bool is_binary_operator(const std::string &name)
bool is_data_origin(const var_origin &vo)
expr_type infer_type_indexing(const base_expr_type &expr_base_type, size_t num_expr_dims, size_t num_index_dims)
std::vector< expression > conditions_
std::string system_function_name_
std::string operator()(const nil &x) const
bool has_var(const expression &e, const variable_map &var_map)
Returns true if the specified expression contains a variable that is defined as a parameter...
bool is_linear_function(const std::string &name)
int_literal & operator=(const int_literal &il)
const std::string var_name_
bool is_primitive() const
base_var_decl operator()(const nil &x) const
bool has_ccdf_suffix(const std::string &name)
base_var_decl base_variable_declaration()
void add_ternary(const ::std::string &name)
std::set< std::string > key_set() const
double_literal & operator=(const double_literal &dl)
std::string strip_prob_fun_suffix(const std::string &dist_fun)
bool has_key(const std::string &key) const
std::vector< expression > args_
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< integrate_ode >, boost::recursive_wrapper< integrate_ode_control >, boost::recursive_wrapper< fun >, boost::recursive_wrapper< index_op >, boost::recursive_wrapper< index_op_sliced >, boost::recursive_wrapper< conditional_op >, boost::recursive_wrapper< binary_op >, boost::recursive_wrapper< unary_op > > expression_t
std::ostream & write_base_expr_type(std::ostream &o, base_expr_type type)
void set_user_defined(const std::pair< std::string, function_signature_t > &name_sig)
cholesky_factor_var_decl()
bool is_user_defined(const std::string &name, const std::vector< expression > &args)
void add_unary_vectorized(const ::std::string &name)
bool operator==(const expr_type &et) const
returns_type_vis(const expr_type &return_type, std::ostream &error_msgs)
break_continue_statement()
std::vector< std::vector< expression > > dimss_
bool operator()(const nil &e) const
std::string fun_name_to_operator(const std::string &name)
Placeholder struct for boost::variant default ctors.
bool operator()(const nil &e) const
base_expr_type get_base_type(const std::string &name) const
expression & operator/=(const expression &rhs)
unary_op(char op, expression const &subject)
const int transformed_data_origin
base_var_decl get(const std::string &name) const
std::vector< expression > dims() const
std::ostream & error_msgs_